npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

twelvedata

v3.0.1

Published

A simple wrapper around the twelve data API

Downloads

450

Readme

Twelvedata

Tests License: MIT

A npm package to access Twelve Data's stock market APIs. NodeJS and Browser (Vanila JS or frameworks like ReactJS) supported using Javascript or Typescript.

https://twelvedata.com/docs

Install

$ yarn add twelvedata

// or

$ npm install twelvedata --save

Import on NodeJS or ReactJS

// CommonJS import for NodeJS.
const twelvedata = require("twelvedata");

// or

// ES6 import for React/NodeJS versions > 15.3.0
import twelvedata from "twelvedata";

// "type": "module" on your package.json file will be required.

Load straight on the browser in your HTML page

// Your .html file
<script type="module" src="./app.js"></script>
// App.js file
import twelvedata from "https://unpkg.com/twelvedata@latest/dist-esm/twelvedata.js?module";

Use it

// setup the config

const config = {
  key: "API_KEY",
};

// initialize and use the client

const client = twelvedata(config);

// time series

let params = {
  symbol: "AAPL",
  interval: "1min",
  outputsize: 5,
};

client
  .timeSeries(params)
  .then((data) => {
    // consume array of data
  })
  .catch((error) => {
    // handle error
  });

// earnings

params = {
  symbol: "AAPL",
};

client
  .earnings(params)
  .then((data) => {
    // use earnings data
  })
  .catch((error) => {
    // handle error
  });

// api usage

client
  .apiUsage()
  .then((data) => {
    console.log(data);
    // {"timestamp":"2020-10-07 03:53:25","current_usage":0,"plan_limit":55}
  })
  .catch((error) => {
    // handle error
  });

// complex data (batched requests)

params = {
  symbols: ["AAPL", "MSFT", "GOOG"],
  intervals: ["5min", "1day"],
  outputsize: 5,
  methods: [
    "time_series",
    {
      name: "ema",
      time_period: 12,
    },
  ],
};

client
  .complexData(params)
  .then((data) => {
    // consume array of data
  })
  .catch((error) => {
    // handle error
  });

// price

params = {
  symbol: "AAPL",
};

client
  .price(params)
  .then((data) => {
    console.log(data);
    // {"price":"113.16000"}
  })
  .catch((error) => {
    // handle error
  });

// technical indicators

params = {
  symbol: "AAPL",
  interval: "1min",
  outputsize: 5,
  indicator: "stoch",
};

client
  .technicalIndicators(params)
  .then((data) => {
    // use technical indicator data
  })
  .catch((error) => {
    // handle error
  });

The available API methods are following an universal approach, which is inline with the available backend endpoints.

  • cryptocurrencyExchanges
  • earliestTimestamp
  • earningsCalendar
  • etf
  • exchanges
  • forexPairs
  • indices
  • symbolSearch
  • quote

Notice

This is NOT an official Twelve Data library, and the authors of this library are not affiliated with Twelve Data in any way, shape or form. Twelve Data APIs and data are Copyright © 2020 Twelve Data Pte. Ltd.

Contributing

If you want to contribute, feel free to submit a pull request.

Donating

If you found this project useful, consider donating.

BTC: bc1qy3vudcfalr6ur9x2wqldlxja9hjah6hts0cje5
ETH: 0x6b71bd471142f064B4A9E083f3766214999ED0D5
LTC: MNsnZ2ENbrseegGiwPcPK5KVhoh4pwLPmV