Twelvedata
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
const twelvedata = require("twelvedata");
import twelvedata from "twelvedata";
Load straight on the browser in your HTML page
<script type="module" src="./app.js"></script>
import twelvedata from "https://unpkg.com/twelvedata@latest/dist-esm/twelvedata.js?module";
Use it
const config = {
key: "API_KEY",
};
const client = twelvedata(config);
let params = {
symbol: "AAPL",
interval: "1min",
outputsize: 5,
};
client
.timeSeries(params)
.then((data) => {
})
.catch((error) => {
});
params = {
symbol: "AAPL",
};
client
.earnings(params)
.then((data) => {
})
.catch((error) => {
});
client
.apiUsage()
.then((data) => {
console.log(data);
})
.catch((error) => {
});
params = {
symbols: ["AAPL", "MSFT", "GOOG"],
intervals: ["5min", "1day"],
outputsize: 5,
methods: [
"time_series",
{
name: "ema",
time_period: 12,
},
],
};
client
.complexData(params)
.then((data) => {
})
.catch((error) => {
});
params = {
symbol: "AAPL",
};
client
.price(params)
.then((data) => {
console.log(data);
})
.catch((error) => {
});
params = {
symbol: "AAPL",
interval: "1min",
outputsize: 5,
indicator: "stoch",
};
client
.technicalIndicators(params)
.then((data) => {
})
.catch((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