Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

twelvedata

Package Overview
Dependencies
Maintainers
2
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

twelvedata

A simple wrapper around the twelve data API

  • 3.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
104
increased by8.33%
Maintainers
2
Weekly downloads
 
Created
Source

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

Keywords

FAQs

Package last updated on 23 Oct 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc