NAV Navbar
Logo
Python Excel R jQuery NodeJS C# Java PHP

Introduction

The Trading Economics Application Programming Interface (API) provides direct access to 300.000 economic indicators, exchange rates, stock market indexes, government bond yields and commodity prices. It allows you to download millions of rows of historical data, to query our real-time economic calendar and to subscribe to updates. Providing several request methods to query our databases, with samples available in different programming languages, it is the best way to export data in XML, CSV or JSON format. The API can be used to feed a custom developed application, a public website or just off-the-shelf software like Microsoft Excel. More at Trading Economics.

You can get Python from: https://www.python.org/downloads/
We support Python 2.7. Then you need to install the tradingeconomics package. You can do so in a variety of ways.


Install the tradingeconomics package using pip, a package management system used to install and manage software packages written in Python. In Windows Command Prompt or Linux bash type:

pip install tradingeconomics

Download the Trading Economics Excel Add In installer, launch it and follow the instructions.
We support Excel 2010, 2013, 2016 (32bit and 64bit).


After installing the Trading Economics Excel Add In click on TE tab and than click on login button and follow instructions.

You can get R from the official website: https://cran.r-project.org/ Then you need to install the tradingeconomics package. At this moment our package is available to download from the GitHub repository. See below how to install a package that’s sitting on GitHub.


Install the devtools package. You can do this from CRAN. Invoke R and then type:

install.packages("devtools")

Load the devtools package.

library(devtools)

Install the tradingeconomics package.

install_github("ieconomics/open-api/R/tradingeconomics")

To start using the Trading Economics R package, type in command window:

library(tradingeconomics)

If you already have an APIkey then type:

login('Your_Key:Your_Secret')

If you don’t have an APIkey and just want to try a demo of our API:

login()

To start using the Trading Economics Python package, open the python command line, and type:

import tradingeconomics as te

If you already have an APIkey then type:

te.login('Your_Key:Your_Secret')

If you don’t have an APIkey and just want to try a demo of our API:

te.login()

Before proceeding select your language tab on the right.

Multiple Parameters

Almost all of the Trading Economics WEB API methods support multiple parameters.
Whenever a method requires a country name or indicator name to be specified, you can provide more than one of each, separated by commas.
Here is a practical example:
historical/country/portugal,brazil,russia/indicator/gdp,currency

Multiple Parameters

Almost all of the Trading Economics WEB API methods support multiple parameters.
Whenever a method requires a country name or indicator name to be specified, you can provide more than one of each, separated by commas.
Here is a practical example:
historical/country/portugal,brazil,russia/indicator/gdp,currency

Multiple Parameters

Almost all of the Trading Economics WEB API methods support multiple parameters.
Whenever a method requires a country name or indicator name to be specified, you can provide more than one of each, separated by commas.
Here is a practical example:
historical/country/portugal,brazil,russia/indicator/gdp,currency

Multiple Parameters

Almost all of the Trading Economics WEB API methods support multiple parameters.
Whenever a method requires a country name or indicator name to be specified, you can provide more than one of each, separated by commas.
Here is a practical example:
historical/country/portugal,brazil,russia/indicator/gdp,currency

Multiple Parameters

Almost all of the Trading Economics WEB API methods support multiple parameters.
Whenever a method requires a country name or indicator name to be specified, you can provide more than one of each, separated by commas.
Here is a practical example:
historical/country/portugal,brazil,russia/indicator/gdp,currency

Data Types

You can request data in several formats:

Authentication

The API provides different methods of authorization. Each request made against API must be supplied with authentication credentials.

Authorization parameters must be provided in the URL query or in the Request Reader.

Using URL auth:
curl -i "https://api.tradingeconomics.com/country/united%20states/?client=guest:guest"
Using Headers auth:
curl -i "https://api.tradingeconomics.com/country/united%20states/" -H "Authorization: Client guest:guest"

Without APIkeys all requests will return the default sample data.

Historical

For example, to get historical data of imports in United Kingdom type:

getHistoricalData(country = 'united kingdom', indicator = 'imports')

To get historical data for several countries and indicators:

getHistoricalData(country = c('united states','china'), indicator = c('gdp','population'),
                  initDate = '2006-01-01', endDate = '2016-12-31',
                  outType = 'df')

In some cases (getCalendarData and getHistoricalData), the start date (initDate) and end date (endDate) of the results can be specified.

In [2]: te.getHistoricalData(country = 'united kingdom', indicator = 'gdp', endDate= '2015-01-01')

Out[2]: 
                  0
2006-12-31  2588.08
2007-12-31  2969.73
2008-12-31  2793.38
2009-12-31  2314.58
2010-12-31  2403.50
2011-12-31  2594.90
2012-12-31  2630.47
2013-12-31  2712.30
2014-12-31  2990.20

Note: Making request for one country and one indicator, without putting country name and indicator name in square brackets, will return pandas.DataFrame type(example above).

Putting country name or indicator name in square brackets will return a dictionary type. For several countries and indicators

te.getHistoricalData(country = ['united states', 'china'], indicator = ['exports','imports', 'gdp'], 
                     initDate= '1990-01-01', endDate= '2015-01-01')

Click Historical button on TE ribbon and then follow the instructions in the dialog box. Or type in any empty cell:

=TEHistorical( "andorra", "gdp per capita", "2010-01-01", "2017-10-29", "Country,Category,DateTime,Value,Frequency,HistoricalDataSymbol,LastUpdate", B2)
var http = require('https');
var headers = {
    'Accept': 'Application/xml',
    'Authorization': 'OAuth2 YOUR_TOKEN_VALUE'
};
var buffer = '';
var options = {
    host: 'api.tradingeconomics.com',
    port: 80,
    path: '/historical/country/{put country name here}/indicator/{put indicator name here}',
    headers: headers
};
callback = function(response) {
    response.on('data', function (chunk) {
    buffer += chunk;
});
response.on('end', function () {
    // your code here if you want to use the results !
});
}

var req = http.get(options, callback).end();         
var url = 'https://api.tradingeconomics.com/historical/country/{put country name here}/indicator/{put indicator name here}?c=guest:guest';
$.ajax({
        url: url,
        type: "GET",
        dataType: 'json'
}).done(function (data) {
    console.log(data);
});
using (var client = new HttpClient())
{
    client.BaseAddress = new Uri("https://api.tradingeconomics.com/");
    client.DefaultRequestHeaders.Clear();
    //ADD Acept Header to tell the server what data type you want
    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
    //ADD Authorization
    AuthenticationHeaderValue auth = new AuthenticationHeaderValue("OAuth2", "YOUR_TOKEN");
    client.DefaultRequestHeaders.Authorization = auth;
    //SET Parameters
    HttpResponseMessage response = await client.GetAsync("/historical/country/{put country name here}/indicator/{put indicator name here}");
    if (response.IsSuccessStatusCode)
    {
        //Your custom response parser code
    }
}
String uri = "https://api.tradingeconomics.com//historical/country/{put country name here}/indicator/{put indicator name here}";
URL url = new URL(uri);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    connection.setRequestMethod("GET");
    connection.setRequestProperty("Accept", "application/xml");
InputStream xml = connection.getInputStream();
<?php
$url = 'https://api.tradingeconomics.com/country';
$headers = array(
    "Accept: application/xml",
    "Authorization: OAuth YOUR_TOKEN_VALUE"
);
$handle = curl_init(); 
    curl_setopt($handle, CURLOPT_URL, $url);
    curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);

    $data = curl_exec($handle);
curl_close($handle);
//parse your data to satisfy your needs....
?>

Here you can get historical information for specific a country and indicator. Click on any method below for a sample. Please note the sample request is limited in scope to a few countries and indicators and responds with a maximum of 10 rows. Trading Economics live acounts have access to more than 20 million indicators for nearly 200 countries.

Methods

Response Fields

Country Country name
Category Indicator Category Name
Date Time Release time and date in UTC
Close Value
Frequency Frequency of the indicator
HistoricalDataSymbol Unique symbol used by TradingEconomics
LastUpdate Time when new data was inserted or changed

Calendar

Shown next is how to get a data frame with information about calendar events for the United Kingdom

getCalendarData(country = 'united kingdom', outType = 'df')

                  Date        Country               Category                                 Event Reference Unit                         Source Actual Previous Forecast TEForecast
1  2016-11-23T11:30:00 United Kingdom          Interest Rate                     BoE Forbes Speech                               Bank of England                                    
2  2016-11-23T11:40:00 United Kingdom          Interest Rate                       BoE Rule Speech                               Bank of England                                    
3  2016-11-23T12:30:00 United Kingdom               Calendar Philip Hammond Makes Autumn Statement                                                                                  
4  2016-11-24T09:30:00 United Kingdom               Calendar                BBA Mortgage Approvals       Oct                                               38.3K    38.8K      40.5K
5  2016-11-25T09:30:00 United Kingdom        GDP Growth Rate           GDP Growth Rate QoQ 2nd Est        Q3      Office for National Statistics            0.7%     0.5%       0.5%
6  2016-11-25T09:30:00 United Kingdom GDP Annual Growth Rate           GDP Growth Rate YoY 2nd Est        Q3      Office for National Statistics            2.1%     2.3%       2.3%
7  2016-11-25T09:30:00 United Kingdom               Calendar          Business Investment YoY Prel       Sep                                               -0.8%    -2.1%      -0.3%
8  2016-11-25T09:30:00 United Kingdom               Calendar          Business Investment QoQ Prel       Sep                                                  1%     0.6%       0.4%
9  2016-11-25T11:00:00 United Kingdom               Calendar               CBI Distributive Trades       Nov                                                  21       12         15
10 2016-11-29T09:30:00 United Kingdom               Calendar                      Mortgage Lending       Oct                                               £3.2B                    
11 2016-11-29T09:30:00 United Kingdom               Calendar        Net Lending to Individuals MoM       Oct                                               £4.7B                    
12 2016-11-29T09:30:00 United Kingdom        Consumer Credit                   BoE Consumer Credit       Oct                     Bank of England          £1405M             £ 1800M
13 2016-11-29T09:30:00 United Kingdom     Mortgage Approvals                    Mortgage Approvals       Oct                     Bank of England          62.93K              61.23K

Shown next is how to get a data frame with information about calendar events for several countries and indicators

getCalendarData(country = c('united states','china'), indicator = c('gdp growth rate','inflation rate'),
                initDate = '2006-01-01', endDate = '2016-12-31',
                outType = 'df')

To get calendar data for a specific country, in data frame format, run:

In [1]: te.getCalendarData(country = 'italy', output_type = 'df')
Out[1]: 
                  Date Country         Category               Event Reference  \
0  2016-11-18T10:00:00   Italy  Current Account     Current Account       Sep   
1  2016-11-24T10:00:00   Italy      Wage Growth  Wage Inflation YoY       Oct   
2  2016-11-24T10:00:00   Italy      Wage Growth  Wage Inflation MoM       Oct   

  Unit                                    Source  Actual Previous Forecast  \
0                                 Banca D'italia  €2810M   €3282M            
1       National Institute of Statistics (ISTAT)             0.6%            
2       National Institute of Statistics (ISTAT)               0%            

  TEForecast  
0    € 2116M  
1       0.7%  
2       0.1%  

For several countries and indicators, in data frame format, run:

te.getCalendarData(country = ['united states', 'china'], category = ['imports','exports'],
                   initDate = '2017-06-07', endDate = '2017-12-31',
                   output_type = 'df')

Click Calendar button on TE ribbon and then follow the instructions in the dialog box. Or type in any empty cell:

=TECalendar( "germany", "services pmi", "2017-03-24", "2017-06-24", "Date,Category,Actual,Previous,Forecast,TEForecast,Importance,LastUpdate", B2)
var http = require('https');
var headers = {
    'Accept': 'Application/xml',
    'Authorization': 'OAuth2 YOUR_TOKEN_VALUE'
};
var buffer = '';
var options = {
    host: 'api.tradingeconomics.com',
    port: 80,
    path: '/calendar',
    headers: headers
};
callback = function(response) {
    response.on('data', function (chunk) {
    buffer += chunk;
});
response.on('end', function () {
    // your code here if you want to use the results !
});
}

var req = http.get(options, callback).end();
var url = 'https://api.tradingeconomics.com/calendar?c=guest:guest';
$.ajax({
        url: url,
        type: "GET",
        dataType: 'json'
}).done(function (data) {
    console.log(data);
});
using (var client = new HttpClient())
{
    client.BaseAddress = new Uri("https://api.tradingeconomics.com/");
    client.DefaultRequestHeaders.Clear();
    //ADD Acept Header to tell the server what data type you want
    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
    //ADD Authorization
    AuthenticationHeaderValue auth = new AuthenticationHeaderValue("OAuth2", "YOUR_TOKEN");
    client.DefaultRequestHeaders.Authorization = auth;
    //SET Parameters
    HttpResponseMessage response = await client.GetAsync("/calendar");
    if (response.IsSuccessStatusCode)
    {
        //Your custom response parser code
    }
}
String uri = "https://api.tradingeconomics.com//calendar";
URL url = new URL(uri);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    connection.setRequestMethod("GET");
    connection.setRequestProperty("Accept", "application/xml");
InputStream xml = connection.getInputStream();
<?php
$url = 'https://api.tradingeconomics.com/country';
$headers = array(
    "Accept: application/xml",
    "Authorization: OAuth YOUR_TOKEN_VALUE"
);
$handle = curl_init(); 
    curl_setopt($handle, CURLOPT_URL, $url);
    curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);

    $data = curl_exec($handle);
curl_close($handle);
//parse your data to satusfy your needs....
?>

Here you can get calendar events. Click on any method below for a sample. Please note the sample request is limited in scope to a few countries and indicators and responds with a maximum of 10 rows. Trading Economics live acounts have access to more than 20 million indicators for nearly 200 countries.

Methods

Response Fields

Date Release time and date in UTC
Country Country name
Category Indicator Category Name
Event Specific event name in the calendar
Reference The period for which released data refers to
Source Source of data
Actual Latest released value
Previous Value for the previous period after the revision (if revision is applicable)
Revised Value reported in the previous period before revision (if there is no revision field remains empty)
Forecast Average forecast among a representative group of economists
TEForecast TE own projections
URL Indicator Hyperlink at Trading Economics
Importance 1 = low, 2 = medium, 3 = high
LastUpdate Time when new data was inserted or changed

Indicators

For example, next code will provide information in data frame format about a number of companies in Italy that got bankrupt

getIndicatorData(country = 'italy', indicator = 'bankruptcies', outType = 'df')

    Country     Category              Title LatestValue     LatestValueDate Source      Unit                 URL CategoryGroup Frequency HistoricalDataSymbol PreviousValue   PreviousValueDate
  1   Italy Bankruptcies Italy Bankruptcies        3600 2016-03-31T00:00:00 Cerved Companies /italy/bankruptcies      Business Quarterly             ITALYBAN          4100 2015-12-31T00:00:00

To get several countries and indicators

getIndicatorData(country = c('united states','china'), indicator = c('gdp','inflation rate'), outType = 'df')

To get List of Indicators by Country:

te.getIndicatorData(country = ['united states', 'china'])

To get Country/Indicator pair:

te.getIndicatorData(country = 'united states', indicators = 'gdp')

To get Several Countries and Indicators:

te.getIndicatorData(country = ['united states', 'china'], indicators = ['gdp', 'population'])

Click Indicators button on TE ribbon and then follow the instructions in the dialog box. Or type in any empty cell:

=TEIndicators( "united states", "bankruptcies", "Title,LatestValue,LatestValueDate,Source,Unit,CategoryGroup,Frequency,PreviousValue,PreviousValueDate", B2)
var http = require('https');
var headers = {
    'Accept': 'Application/xml',
    'Authorization': 'OAuth2 YOUR_TOKEN_VALUE'
};
var buffer = '';
var options = {
    host: 'api.tradingeconomics.com',
    port: 80,
    path: '/indicators',
    headers: headers
};
callback = function(response) {
    response.on('data', function (chunk) {
    buffer += chunk;
});
response.on('end', function () {
    // your code here if you want to use the results !
});
}

var req = http.get(options, callback).end();       
var url = 'https://api.tradingeconomics.com/indicators?c=guest:guest';
$.ajax({
        url: url,
        type: "GET",
        dataType: 'json'
}).done(function (data) {
    console.log(data);
});
using (var client = new HttpClient())
{
    client.BaseAddress = new Uri("https://api.tradingeconomics.com/");
    client.DefaultRequestHeaders.Clear();
    //ADD Acept Header to tell the server what data type you want
    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
    //ADD Authorization
    AuthenticationHeaderValue auth = new AuthenticationHeaderValue("OAuth2", "YOUR_TOKEN");
    client.DefaultRequestHeaders.Authorization = auth;
    //SET Parameters
    HttpResponseMessage response = await client.GetAsync("/indicators");
    if (response.IsSuccessStatusCode)
    {
        //Your custom response parser code
    }
}
String uri = "https://api.tradingeconomics.com//indicators";
URL url = new URL(uri);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    connection.setRequestMethod("GET");
    connection.setRequestProperty("Accept", "application/xml");
InputStream xml = connection.getInputStream();
<?php
$url = 'https://api.tradingeconomics.com/country';
$headers = array(
    "Accept: application/xml",
    "Authorization: OAuth YOUR_TOKEN_VALUE"
);
$handle = curl_init(); 
    curl_setopt($handle, CURLOPT_URL, $url);
    curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);

    $data = curl_exec($handle);
curl_close($handle);
//parse your data to satusfy your needs....
?>

Here you can get a list of all indicators, indicators by country or country-indicator pair. Click on any method below for a sample. Please note the sample request is limited in scope to a few countries and indicators and responds with a maximum of 10 rows. Trading Economics live acounts have access to more than 20 million indicators for nearly 200 countries.

Methods

Response Fields

Country Country name
Category Indicator Category Name
Title Combination of country/category
Source Source of data
Frequency Frequency of the indicator
URL Indicator Hyperlink at Trading Economicse
HistoricalDataSymbol Unique symbol used by TradingEconomics

Forecast

Next code will provide a list with forecasted values of all indicators of United States

getForecastData(country ='united states')

To get data in data frame format type:

getForecastData(country ='united states', outType = 'df')

To get data in data frame format type for several countries and indicators:

getForecastData(country =c('united states','china'), indicator = c('gdp','inflation rate'), outType = 'df')

Forecasted values for specific a country, in this case United States.

te.getForecastData(country = 'united states', output_type = 'df')

Forecasted values for several countries and indicators.

te.getForecastData(country = ['united states', 'china'], indicator = ['gdp', 'population'], output_type = 'df')

Click Forecasts button on TE ribbon and then follow the instructions in the dialog box. Or type in any empty cell:

=TEForecasts( "united states", "gdp", "Country,Category,LatestValue,LatestValueDate,YearEnd,YearEnd2,q1,q1_date,q4,q4_date", B2)
var http = require('https');
var headers = {
    'Accept': 'Application/xml',
    'Authorization': 'OAuth2 YOUR_TOKEN_VALUE'
};
var buffer = '';
var options = {
    host: 'api.tradingeconomics.com',
    port: 80,
    path: '/forecast/country/{put country name here}',
    headers: headers
};
callback = function(response) {
    response.on('data', function (chunk) {
    buffer += chunk;
});
response.on('end', function () {
    // your code here if you want to use the results !
});
}

var req = http.get(options, callback).end();         
var url = 'https://api.tradingeconomics.com/forecast/country/{put country name here}?c=guest:guest';
$.ajax({
        url: url,
        type: "GET",
        dataType: 'json'
}).done(function (data) {
    console.log(data);
});
using (var client = new HttpClient())
{
    client.BaseAddress = new Uri("https://api.tradingeconomics.com/");
    client.DefaultRequestHeaders.Clear();
    //ADD Acept Header to tell the server what data type you want
    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
    //ADD Authorization
    AuthenticationHeaderValue auth = new AuthenticationHeaderValue("OAuth2", "YOUR_TOKEN");
    client.DefaultRequestHeaders.Authorization = auth;
    //SET Parameters
    HttpResponseMessage response = await client.GetAsync("/forecast/country/{put country name here}");
    if (response.IsSuccessStatusCode)
    {
        //Your custom response parser code
    }
}
String uri = "https://api.tradingeconomics.com//forecast/country/{put country name here}";
URL url = new URL(uri);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    connection.setRequestMethod("GET");
    connection.setRequestProperty("Accept", "application/xml");
InputStream xml = connection.getInputStream();
<?php
$url = 'https://api.tradingeconomics.com/country';
$headers = array(
    "Accept: application/xml",
    "Authorization: OAuth YOUR_TOKEN_VALUE"
);
$handle = curl_init(); 
    curl_setopt($handle, CURLOPT_URL, $url);
    curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);

    $data = curl_exec($handle);
curl_close($handle);
//parse your data to satisfy your needs....
?>

Here you can get forecast values by country, by indicator, by country and indicator. Click on any method below for a sample. Please note the sample request is limited in scope to a few countries and indicators and responds with a maximum of 10 rows. Trading Economics live acounts have access to more than 20 million indicators for nearly 200 countries.

Methods

Response Fields

Category Indicator Category Name
Title Combination of country/category
ForecastDate Date when forecasting was done
ForecastValue Forcastvalue for the ForecastDate
ForecastValue1 Forecast value for year end after q4_date
ForecastValue2 Forecast value for year end after ForecastValue1
ForecastValue3 Forecast value for year end after ForecastValue2
ForecastValue1Q Forecast value for the date in d1_date
ForecastValue2Q Forecast value for the date in d2_date
ForecastValue3Q Forecast value for the date in d3_date
ForecastValue4Q Forecast value for the date in d4_date
LatestValue Last released value
LatestValueDate Date of the last released value
q1_date 1 quarter ahead release date
q2_date 2 quarters ahead release date
q3_date 3 quarters ahead release date
q4_date 4 quarters ahead release date
Frequency Frequency of the indicator
HistoricalDataSymbol Unique symbol used by TradingEconomics

Markets

To get information about commodities in data frame format type:

getMarketsData(marketsField = 'commodities', outType = 'df')

To get stock market index data:

te.getMarketsData(marketsField = 'index', output_type = 'df')

Click Markets button on TE ribbon and then follow the instructions in the dialog box. Or type in any empty cell:

=TEMarkets( "currency", "Symbol,Name,Date,Last,Importance,DailyChange,DailyPercentChange,WeeklyChange,WeeklyPercentChange,YTDChange,YTDPercentChange,yesterday,lastWeek,startYear", B2)
var http = require('https');
var headers = {
    'Accept': 'Application/xml',
    'Authorization': 'OAuth2 YOUR_TOKEN_VALUE'
};
var buffer = '';
var options = {
    host: 'api.tradingeconomics.com',
    port: 80,
    path: '/markets/commodities',
    headers: headers
};
callback = function(response) {
    response.on('data', function (chunk) {
    buffer += chunk;
});
response.on('end', function () {
    // your code here if you want to use the results !
});
}

var req = http.get(options, callback).end();         
var url = 'https://api.tradingeconomics.com/markets/commodities?c=guest:guest';
$.ajax({
        url: url,
        type: "GET",
        dataType: 'json'
}).done(function (data) {
    console.log(data);
});
using (var client = new HttpClient())
{
    client.BaseAddress = new Uri("https://api.tradingeconomics.com/");
    client.DefaultRequestHeaders.Clear();
    //ADD Acept Header to tell the server what data type you want
    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
    //ADD Authorization
    AuthenticationHeaderValue auth = new AuthenticationHeaderValue("OAuth2", "YOUR_TOKEN");
    client.DefaultRequestHeaders.Authorization = auth;
    //SET Parameters
    HttpResponseMessage response = await client.GetAsync("/markets/commodities");
    if (response.IsSuccessStatusCode)
    {
        //Your custom response parser code
    }
}
String uri = "https://api.tradingeconomics.com//markets/commodities";
URL url = new URL(uri);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    connection.setRequestMethod("GET");
    connection.setRequestProperty("Accept", "application/xml");
InputStream xml = connection.getInputStream();
<?php
$url = 'https://api.tradingeconomics.com/country';
$headers = array(
    "Accept: application/xml",
    "Authorization: OAuth YOUR_TOKEN_VALUE"
);
$handle = curl_init(); 
    curl_setopt($handle, CURLOPT_URL, $url);
    curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);

    $data = curl_exec($handle);
curl_close($handle);
//parse your data to satusfy your needs....
?>

Here you can get a list of available commodities, currencies, indexes or bonds and their latest values. Click on any method below for a sample. Please note the sample request is limited in scope to a few countries and indicators and responds with a maximum of 10 rows. Trading Economics live acounts have access to more than 20 million indicators for nearly 200 countries.
Please consider that all market-related methods are beta and under heavy development.

Snapshot of latest quotes

Historical

Intraday

Earnings

Market Lists

JSON CSV XML

For all methods listed above, you can get data in next formats:

Response Fields

Name Commodity name
Country Country field of a commodity if always “Commodity”
Date Release time and date in UTC
Last Latest value available
Group Group of commodity
Symbol Unique symbol used by TradingEconomics
LastUpdate Time when new data was inserted or changed

Streaming

In Windows Command Prompt or Linux bash execute next steps:
Step 1 - Clone repository

git clone https://github.com/ieconomics/open-api.git

Step 2

cd open-api/stream/python

Step 3 - Install dependencies

pip install websocket-client

Step 4 - In app.py file, set-up your client key/secret

client_key = "API_CLIENT_KEY"
client_secret = "API_CLIENT_KEY"

Step 5 - Run it

python app.py

Check here for the complete sample code.

In Windows Command Prompt or Linux bash execute next steps:
Step 1 - Clone repository

git clone https://github.com/ieconomics/open-api.git

Step 2

cd open-api/stream/nodejs

Step 3 - Install dependencies

npm install

Step 4 - In app.js file, set-up your client key/secret

Client = new te_client({
  url: 'ws://stream.tradingeconomics.com/',
  key: 'API_CLIENT_KEY', // <--
  secret: 'API_CLIENT_SECRET' // <--
  //reconnect: true
});

Step 5 - Run it

node app.js

Check here for the complete sample code.

The Trading Economics API streaming endpoint can be used to receive live calendar releases and market data utilizing a persistent web socket connection. Streaming data from the API consists of making an Authorization request and leaving the socket open to continually receive data. You can authorize using your API client credentials (key/secret). Then you will be able to subscribe to 1 or more of our streaming channels.

Streaming Endpoint
ws://stream.tradingeconomics.com/

Connecting to Stream
Our data is Streamed using websocket protocol. Meaning you can use programming language of your choice, as long as it supports websockets.

Opening the connection:
Only Authorized users may establish a persistent real time connection with Trading Economics API Stream. In order to do so, you have to start a handshaking process. On the handshake, you have to use client key/secret in order to Authorize. These credentials must be added to the connection query:

Client key/secret
ws://stream.tradingeconomics.com/?client=YOUR_CLIENT_KEY:YOUR_CLIENT_SECRET

Subscribe to a Channel
After establishing the connection, you are able to subscribe to one or more topics. In order to subscribe to a channel, you must send a message to the stream server passing the topic name as the argument.
Our streaming service provides live data on Economic Data, Markets and Commodities.

Subscribe to Calendar Events:
'{"topic": "subscribe", "to": "calendar"}'

Response fields for the calendar subscription:

date Release time and date in UTC
country Country name
category Indicator Category Name
event Specific event name in the calendar
reference The period for which released data refers to
source Source of data
actual Latest released value
previous Value for the previous period after the revision (if revision is applicable)
forecast Average forecast among a representative group of economists
teforecast TE own projections
importance 1 = low, 2 = medium, 3 = high

Subscribe to Markets in Bulk:
'{"topic": "subscribe", "to": "currencies"}' '{"topic": "subscribe", "to": "indexes"}' '{"topic": "subscribe", "to": "commodities"}' '{"topic": "subscribe", "to": "bonds"}'

Subscribe to Individual Markets:
'{"topic": "subscribe", "to": "EURUSD"}' '{"topic": "subscribe", "to": "DXY"}' '{"topic": "subscribe", "to": "INDU"}' '{"topic": "subscribe", "to": "XAUUSD:CUR"}' '{"topic": "subscribe", "to": "AAPL:US"}'
Plus any indicator listed at Trading Economics.

Response fields for the markets subscription:

s symbol
bid latest market bid price
ask latest maket ask price
price latest market price
dt timestamp of last market price (epoch)
state market state (open/close)
type type of market (currency/indexes/commodity)
dhigh daily high
dlow daily low
pch percentage change
nch net change

Check how to use it with Python or NodeJS (JavaScript)

For a detailed list of available live data please contact us

News

Click on any method below for a sample. Please note the sample request is limited in scope to a few countries and indicators and responds with a maximum of 10 rows. Trading Economics live acounts have access to more than 20 million indicators for nearly 200 countries.

Latest news

Latest articles

Response Fields

Id Unique ID
Title Title of the event
Description Description of the event
Date Release time and date in UTC
Country Country name
Category Indicator Category Name
Symbol Unique symbol used by TradingEconomics
Url Indicator Hyperlink at Trading Economics