The Trading Economics NPM package provides direct access to our data. It allows you to request millions of rows of economic historical data, to query our real-time economic calendar and to subscribe to updates.
Using NPM
npm install -g tradingeconomics
Using GitHub
git clone https://github.com/tradingeconomics/tradingeconomics-js.git
cd tradingeconomics-js
npm i
const te = require('tradingeconomics');
Authentication using Environment Variable (more secure)
apikey="key:secret" node app.js
Authentication using inline code
te.login('guest:guest'); # replace with your key
te.getHistoricalData(country = 'mexico', indicator = 'gdp').then(function(data){
console.log(data)
});
te.getCalendar().then(function(data){
console.log(data)
});
te.getEarnings(symbol = 'aapl:us', start_date = '2016-01-01', end_date = '2017-12-31')
.then((data) => {
console.log(data);
})
.catch((err) => console.log(err));
https://github.com/tradingeconomics/tradingeconomics-js/tree/main/Examples
Please set apikey with your credentials
docker run --rm -it --init --name te-nodejs -e apikey='guest:guest' tradingeconomics/nodejs:latest sh
node Calendar/events.js
node Indicators/historical.js
node Markets/marketForecast.js
ls # to view for more examples