NAV Navbar
Logo
Python Excel R jQuery

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 and Python 3.6. 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) only for Windows.


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

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.

Error codes

Notes

Indicators

Here you can get a list of all indicators, indicators by country, country-indicator pair and historical information for specific 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.

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'], output_type='df')

Output:
           Country         ...             PreviousValueDate
0    United States         ...           2018-04-30T00:00:00
1    United States         ...           2018-06-15T00:00:00
2    United States         ...           2017-12-31T00:00:00
               ...         ...                           ...
314          China         ...           2016-12-31T00:00:00
315  United States         ...           2016-12-31T00:00:00
316  United States         ...           2018-04-30T00:00:00
317  United States         ...           2018-04-30T00:00:00

To get Country/Indicator pair:

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

Output:
{'United States': 
  {'GDP': 
    [{'LatestValue': 18624.48, 'LatestValueDate': '2016-12-31T00:00:00', 'Source': 'World Bank', 
    'Unit': 'USD Billion', 'CategoryGroup': 'GDP', 'Frequency': 'Yearly', 'PreviousValue': 18120.71, 
    'PreviousValueDate': '2015-12-31T00:00:00'}]
  }
}

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 url = 'https://api.tradingeconomics.com/indicators?c=guest:guest';
$.ajax({
        url: url,
        type: "GET",
        dataType: 'json'
}).done(function (data) {
    console.log(data);
});

Methods

Response Fields

Country Country name
Category Category name
Title Combination of country/category
LatestValueDate Date of the last released value
LatestValue Last released value
Source Source of data
Unit Unit of the value
URL Hyperlink at Trading Economicse
CategoryGroup Category group name
Adjustment —–
Frequency Frequency of the indicator
HistoricalDataSymbol Unique symbol used by TradingEconomics
CreateDate Release time and date in UTC
PreviousValue Previous released value
PreviousValueDate Date of the previous released value

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', initDate='2015-01-01')

Out[2]: 
                  0
2006-12-31  2588.08
2007-12-31  2969.73
              ...
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'], 
                     initDate='1990-01-01', endDate='2015-01-01')

Output:
{'China': 
  {'Exports': 
    [dict_values([
    1990-01-31      28.42
    1990-02-28      32.53
                   ...
    2014-11-30    2116.33
    2014-12-31    2273.72
    Name: 0, Length: 300, dtype: float64])
    ], 
    'Imports': 
    [dict_values([
    1990-01-31      25.70
    1990-02-28      35.30
                   ...
    2014-11-30    1567.79
    2014-12-31    1775.93
    Name: 0, Length: 300, dtype: float64])]
  }, 
  'United States': 
  {'Exports': 
    [dict_values([
    1990-01-31     43315.0
    1990-02-28     43412.0
                    ...
    2014-11-30    197778.0
    2014-12-31    197411.0
    Name: 0, Length: 300, dtype: float64])], 
    'Imports': 
    [dict_values([
    1990-01-31     50769.0
    1990-02-28     48553.0
                    ...
    2014-11-30    237634.0
    2014-12-31    239840.0
    Name: 0, Length: 300, dtype: float64])]
  }
}

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 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);
});

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

Credit Rating

Methods

Response Fields

TE Trading Economics rating
Date Release time and date in UTC
Agency Rating agency
Rating
Outlook
TE_Outlook Trading Economics outlook
SP Standard & Poor’s rating
SP_Outlook Standard & Poor’s outlook
Moodys Moody’s rating
Moodys_Outlook Moody’s outlook
Fitch Fitch rating
Fitch_outlook Fitch outlook

Latest updates

Methods

Response Fields

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:

te.getCalendarData(country='italy', output_type='df')

Output:
  CalendarId                 Date    ...     TEForecast Importance
0     160449  2018-06-28T09:00:00    ...           1.2%          1
1     160450  2018-06-28T09:00:00    ...           0.4%          1
2     160451  2018-06-28T09:00:00    ...           0.3%          2
3     160452  2018-06-28T09:00:00    ...           1.2%          2
4     160693  2018-06-28T09:45:00    ...                         1
5     160694  2018-06-28T09:45:00    ...                         1
6     160832  2018-07-02T07:45:00    ...           53.4          2
7     160837  2018-07-02T08:00:00    ...          10.8%          2
8     160966  2018-07-04T07:45:00    ...           53.6          2

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')

Output:
   CalendarId                 Date    ...     TEForecast Importance
0      133104  2017-06-08T03:00:00    ...                         3
1      133105  2017-06-08T03:00:00    ...                         3
2      134636  2017-07-06T12:30:00    ...        $191.7B          1
3      134637  2017-07-06T12:30:00    ...        $236.7B          1
4      135063  2017-07-13T03:00:00    ...                         3
5      135064  2017-07-13T03:00:00    ...                         3
6      136267  2017-08-04T12:30:00    ...          $193B          1
7      136268  2017-08-04T12:30:00    ...        $238.9B          1
8      136307  2017-08-08T03:00:00    ...                         3
9      136308  2017-08-08T03:00:00    ...                         3
10     137694  2017-09-06T12:30:00    ...          $195B          1
11     137695  2017-09-06T12:30:00    ...        $239.2B          1
12     137989  2017-09-08T02:00:00    ...                         3
13     137990  2017-09-08T02:00:00    ...                         3
14     139629  2017-10-05T12:30:00    ...                         1
15     139630  2017-10-05T12:30:00    ...                         1
16     140073  2017-10-13T02:30:00    ...                         3
17     140075  2017-10-13T02:30:00    ...                         3
18     141343  2017-11-03T12:30:00    ...          $195B          1
19     141344  2017-11-03T12:30:00    ...          $239B          1
20     141492  2017-11-08T03:00:00    ...                         3
21     141493  2017-11-08T03:00:00    ...                         3
22     143120  2017-12-05T13:30:00    ...          $195B          1
23     143121  2017-12-05T13:30:00    ...          $239B          1
24     143323  2017-12-08T03:00:00    ...                         3
25     143324  2017-12-08T03:00:00    ...                         3

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 url = 'https://api.tradingeconomics.com/calendar?c=guest:guest';
$.ajax({
        url: url,
        type: "GET",
        dataType: 'json'
}).done(function (data) {
    console.log(data);
});

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)
Forecast Average forecast among a representative group of economists
TEForecast TE own projections
URL Hyperlink at Trading Economics
DateSpan —–
Importance 1 = low, 2 = medium, 3 = high
LastUpdate Time when new data was inserted or changed
Revised Value reported in the previous period after revision (if there is no revision field remains empty)
Currency —–
Unit Unit of the value
OCountry Country’s original name
OCategory Category’s original name
Ticker Unique ticker used by TradingEconomics
Symbol Unique symbol used by TradingEconomics
CalendarID Unique calendar ID 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')

Output:
           Country         ...                       q4_date
0    United States         ...           2019-03-31T00:00:00
1    United States         ...           2019-03-31T00:00:00
2    United States         ...           2019-03-31T00:00:00
               ...         ...                           ...
200  United States         ...           2019-03-31T00:00:00
201  United States         ...           2019-03-31T00:00:00
202  United States         ...           2019-03-31T00:00:00

Forecasted values for several countries and indicators.

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

Output:
         Country    Category         ...                 q4              q4_date
0          China         GDP         ...           13100.00  2019-03-31T00:00:00
1          China  Population         ...            1407.00  2019-03-31T00:00:00
2  United States         GDP         ...           20220.00  2019-03-31T00:00:00
3  United States  Population         ...             328.49  2019-03-31T00:00:00

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 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);
});

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

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.

Snapshots

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')

Output:
           Symbol            Ticker     ...          lastYear    startYear
1     KWSEIDX:IND   KuwwaitStoarket     ...         6762.8200    6312.5200
2    SECTMIND:IND          SECTMIND     ...          399.3300     400.4300
3         BSX:IND               BSX     ...         2021.9300    2202.1900
              ...               ...     ...               ...          ...
128       SPX:IND               SPX     ...         2419.7000    2695.8100
129      SX5E:IND              SX5E     ...         3471.3300    3490.1900
130       UKX:IND               UKX     ...         7350.3200    7648.1000

To get stock market data filtered by symbol:

te.getMarketsBySymbol(symbols='indu:ind')    

Output:    
     Symbol Ticker         ...           ISIN           LastUpdate
0  INDU:IND   INDU         ...           None  2018-06-28T14:56:00

To get stock market data filtered by symbols:

te.getMarketsBySymbol(symbols=['aapl:us', 'indu:ind'], output_type='raw')   

Output:    
[{'Symbol': 'AAPL:US', 'Ticker': 'AAPL', 'Name': 'Apple', ..., 'LastUpdate': '2018-06-27T20:05:00'}, 
{'Symbol': 'INDU:IND', 'Ticker': 'INDU', 'Name': 'Dow Jones', 'Type': 'index', ... 'LastUpdate': '2018-06-28T11:35:00'}]

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 url = 'https://api.tradingeconomics.com/markets/commodities?c=guest:guest';
$.ajax({
        url: url,
        type: "GET",
        dataType: 'json'
}).done(function (data) {
    console.log(data);
});

Methods

Snapshot of latest quotes

Response Fields

Symbol Unique symbol used by TradingEconomics
Ticker Unique ticker used by TradingEconomics
Name Indicator full name
Country Country name
Date Release time and date in UTC
Group Group name
Type Market type
Decimals Number of decimal places
Last Latest released value
Unit Unit of the value
URL Hyperlink at Trading Economics
Importance Indicator importance from 0(lowest) to 1000(highest)
DailyChange Difference between last close and current price
DailyPercentualChange Difference in percentage between last close and current price
WeeklyChange Difference between last week close and current price
WeeklyPercentualChange Difference in percentage between last week close and current price
MonthlyChange Difference between last month close and current price
MonthlyPercentualChange Difference in percentage between last month close and current price
YearlyChange Difference between last year close and current price
YearlyPercentualChange Difference in percentage between last year close and current price
YTDChange Difference between last year last close and current price
YTDPercentualChange Difference in percentage between last year last close and current price
Yesterday Yesterday close
LastWeek Last week close
LastMonth Last month close
LastYear Last year close
StartYear Start year close
LastUpdate Time when new data was inserted or changed

Historical

To get historical market data for specific symbol and time range:

In [2]: te.fetchMarkets(symbol='indu:ind', initDate='2017-01-01', endDate='2017-06-15')

Out[2]: 
              symbol      open      high       low     close
2017-01-03  INDU:IND  19872.86  19938.53  19775.93  19881.76
2017-01-04  INDU:IND  19890.94  19956.14  19878.83  19942.16
2017-01-05  INDU:IND  19924.56  19948.60  19811.12  19899.29
...              ...       ...       ...       ...       ...
2017-06-13  INDU:IND  21256.83  21332.77  21256.83  21328.47
2017-06-14  INDU:IND  21342.71  21391.97  21294.09  21374.56
2017-06-15  INDU:IND  21291.69  21367.28  21261.87  21359.90

To get historical market data for multiple symbols and specific time range:

In [2]: te.fetchMarkets(symbol=['indu:ind', 'cl1:com'], initDate='2017-01-01', endDate='2017-06-15')

Out[2]: 
              symbol        open        high         low       close
2017-01-02   CL1:COM     53.9600     54.3000     53.9100     54.0200
2017-01-03   CL1:COM     54.2000     55.2400     52.1100     52.3300
2017-01-03  INDU:IND  19872.8600  19938.5300  19775.9300  19881.7600
       ...       ...         ...         ...         ...         ...
2017-06-14  INDU:IND  21342.7100  21391.9700  21294.0900  21374.5600
2017-06-15  INDU:IND  21291.6900  21367.2800  21261.8700  21359.9000
2017-06-15   CL1:COM     44.6900     44.8100     44.2200     44.4600

Methods

Response Fields

Symbol Unique symbol used by TradingEconomics
Date Release time and date in UTC
Open Open value
High High value
Low Low value
Close Close value

Intraday

To get intraday market data for a specific symbol run:

te.getMarketsIntraday(symbols='indu:ind')

Output:
        Symbol                 Date     ...             Low       Close
0     INDU:IND  2018-04-30T08:30:00     ...      24409.2109  24409.2109
1     INDU:IND  2018-04-30T08:31:00     ...      24407.2207  24409.2109
2     INDU:IND  2018-04-30T08:32:00     ...      24410.2109  24411.2109
 ...       ...                  ...     ...             ...         ...
9997  INDU:IND  2018-05-18T15:52:00     ...      24744.1191  24755.1094
9998  INDU:IND  2018-05-18T15:53:00     ...      24749.1094  24749.1094
9999  INDU:IND  2018-05-18T15:54:00     ...      24750.1094  24754.1191

To get intraday market data for a specific symbol starting on certain date and time run:

te.getMarketsIntraday(symbols='indu:ind', initDate='2018-03-13 15:30')

Output:
        Symbol                 Date     ...             Low       Close
0     INDU:IND  2018-03-13T15:30:00     ...      25198.0606  25209.9609
1     INDU:IND  2018-03-13T15:31:00     ...      25201.9395  25206.9395
2     INDU:IND  2018-03-13T15:32:00     ...      25201.8809  25208.8809
 ...       ...                  ...     ...             ...         ...
9997  INDU:IND  2018-04-04T16:06:00     ...      23884.9300  23890.0200
9998  INDU:IND  2018-04-04T16:07:00     ...      23888.4000  23903.0400
9999  INDU:IND  2018-04-04T16:08:00     ...      23903.5000  23942.3900

Methods

Response Fields

Symbol Unique symbol used by TradingEconomics
Datetime Release time and date in UTC
Open Open value
High High value
Low Low value
Close Close value

Market Lists

To get closely related items of a certain symbol:

te.getMarketsPeers(symbols='indu:ind', output_type='df')

Output:
     Symbol Ticker         ...           ISIN           LastUpdate
0  INDU:IND   INDU         ...           None  2018-06-28T13:49:00
1   MID:IND    MID         ...           None  2018-06-28T13:49:00
2   NDX:IND    NDX         ...           None  2018-06-28T13:49:00
3   SPX:IND    SPX         ...           None  2018-06-28T13:49:00

To get closely related items of a certain group of symbols:

te.getMarketsPeers(symbols=['aapl:us', 'indu:ind'])

Output:
      Symbol         ...                    LastUpdate
0    AAPL:US         ...           2018-06-28T13:49:00
1     HPQ:US         ...           2018-06-28T13:49:00
2     IBM:US         ...           2018-06-28T13:49:00
         ...         ...                           ...
8     SNE:US         ...           2018-06-28T13:48:00
9    SPX:IND         ...           2018-06-28T13:49:00
10     VZ:US         ...           2018-06-28T13:49:00

To get components of the certain index:

te.getMarketsComponents(symbols='psi20:ind', output_type='df')

Output:
     Symbol         ...                    LastUpdate
0   ALTR:PL         ...           2018-06-28T13:45:00
1    BCP:PL         ...           2018-06-28T13:45:00
2    COR:PL         ...           2018-06-28T13:48:00
        ...         ...                           ...
15   SEM:PL         ...           2018-06-28T13:47:00
16   SON:PL         ...           2018-06-28T13:46:00
17  SONC:PL         ...           2018-06-28T11:51:00

To get components of the group of indexes:

te.getMarketsComponents(symbols=['indu:ind', 'psi20:ind'])

Output:
     Symbol         ...                    LastUpdate
0   AAPL:US         ...           2018-06-28T13:49:00
1   ALTR:PL         ...           2018-06-28T13:45:00
2    AXP:US         ...           2018-06-28T13:49:00
        ...         ...                           ...
45    VZ:US         ...           2018-06-28T13:49:00
46   WMT:US         ...           2018-06-28T13:49:00
47   XOM:US         ...           2018-06-28T13:49:00

Methods

Response Fields

Symbol Unique symbol used by TradingEconomics
Ticker Unique ticker used by TradingEconomics
Name Indicator full name
Country Country name
Date Release time and date in UTC
Type Market type
Decimals Number of decimal places
Last Latest released value
MarketCap Market capitalization
Unit Unit of the value
URL Hyperlink at Trading Economics
Importance Indicator importance from 0(lowest) to 1000(highest)
DailyChange Difference between last close and current price
DailyPercentualChange Difference in percentage between last close and current price
WeeklyChange Difference between last week close and current price
WeeklyPercentualChange Difference in percentage between last week close and current price
MonthlyChange Difference between last month close and current price
MonthlyPercentualChange Difference in percentage between last month close and current price
YearlyChange Difference between last year close and current price
YearlyPercentualChange Difference in percentage between last year close and current price
YTDChange Difference between last year last close and current price
YTDPercentualChange Difference in percentage between last year last close and current price
Yesterday Yesterday close
LastWeek Last week close
LastMonth Last month close
LastYear Last year close
StartYear Start year close
LastUpdate Time when new data was inserted or changed

Methods

Response Fields

Symbol Unique symbol used by TradingEconomics
Ticker Unique ticker used by TradingEconomics
Name Indicator full name
Country Country name
Date Release time and date in UTC
Type Market Type
Decimals Number of decimal places
Last Latest released value
Unit Unit of the value
URL Hyperlink at Trading Economics
Importance Indicator importance from 0(lowest) to 1000(highest)
DailyChange Difference between last close and current price
DailyPercentualChange Difference in percentage between last close and current price
WeeklyChange Difference between last week close and current price
WeeklyPercentualChange Difference in percentage between last week close and current price
MonthlyChange Difference between last month close and current price
MonthlyPercentualChange Difference in percentage between last month close and current price
YearlyChange Difference between last year close and current price
YearlyPercentualChange Difference in percentage between last year close and current price
YTDChange Difference between last year last close and current price
YTDPercentualChange Difference in percentage between last year last close and current price
Yesterday Yesterday close
LastWeek Last week close
LastMonth Last month close
LastYear Last year close
StartYear Start year close
LastUpdate Time when new data was inserted or changed

JSON CSV XML

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

Earnings

Earnings, IPO, Dividends

To get default earnings calendar:

te.getEarnings()

Output:
        Symbol                            Name     Actual  ...
0         A:US                         Agilent      0.149  ...
1     ASLAN:TI                   Aslan Cimento       0.55  ...
2      2459:TT                           Audix          3  ...
3       AXW:FP                  AXWAY SOFTWARE        0.2  ...

To get earnings calendar filtered by symbol and date:

te.getEarnings(symbols = 'msft:us', initDate='2016-01-01', endDate='2017-12-31')

Output:
    Symbol       Name Actual  ...
0  MSFT:US  Microsoft   0.78  ...
1  MSFT:US  Microsoft   0.62  ...
2  MSFT:US  Microsoft   0.69  ...
3  MSFT:US  Microsoft   0.76  ...

To get earnings calendar by country:

te.getEarnings(country = 'united states')

Output:
       Symbol                                  Name  Actual  ...
0        A:US                               Agilent   0.149  ...
1    CMCSA:US                               Comcast    0.19  ...
2      DDR:US                                   DDR    0.38  ...
3      CUZ:US                    Cousins Properties   0.065  ...

Methods

Response Fields

Date Release time and date in UTC
Symbol Unique symbol used by TradingEconomics
Type Earnings type: earnings, ipo, dividends
Name Company name
Actual Earnings per share
Forecast Average forecast among a representative group of analysts
FiscalTag Fiscal year and quarter
FiscalReference Fiscal year and quarter in different format
CalendarReference Calendar quarter for the release
Country Country name
Currency —-
LastUpdate Time when new data was inserted or changed

Streaming

Copy this code and execute

import tradingeconomics as te
import json

te.login('guest:guest')

def on_message(ws, message):
  print json.loads(message)

te.subscribe('EURUSD:CUR')
te.run(on_message)

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.

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

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

Methods

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 Category name
Symbol Unique symbol used by TradingEconomics
Url Hyperlink at Trading Economics

Latest articles

Methods

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 Category name
Symbol Unique symbol used by TradingEconomics
URL Hyperlink at Trading Economics

World Bank

Category

Methods

All of this can be formatted to json by appending “&format=json”

Response Fields

Category Category name
series_code
series_name
sub_category —-
sub_category2 —-
sub_category3 —-
Title —-
long_definition —–
short_definition —-
Source Data source
general_comments —-
aggregation_method —–
URL Hyperlink at Trading Economics
Organization —-
Unit —-
verbose_unit —-
last_update Time when new data was inserted or changed

Indicators and Countries

Methods

All of this can be formatted to json by appending “&format=json”

Response Fields

Symbol Unique symbol used by TradingEconomics
Last Latest released value
Date Release time and date in UTC
Previous Value for the previous period after the revision (if revision is applicable)
PreviousDate Release time and date in UTC of the previous value
Country Country name
Category Category name
Description —-
Frequency Frequency of the indicator
Unit Unit of the value
Title — —
URL Hyperlink at Trading Economics
LastUpdate Time when new data was inserted or changed

Historical

Methods

All of this can be formatted to json by appending “&format=json”

Response Fields

Symbol Unique symbol used by TradingEconomics
Date Release time and date in UTC
Value Released value

Comtrade

Methods

Response Fields

Id
Name
ParentId
Pretty_Name

Country

Methods

Response Fields

Id
Name
Region
Subregion
ISO Three letter country code
Year
Symbol Unique symbol used by TradingEconomics
Country1 First country ame
Country2 Second country name
Type —–
Category Category name
URL Hyperlink at Trading Economics
Title —–

Historical

Methods

Response Fields

Symbol Unique symbol used by TradingEconomics
Date Release time and date in UTC
Value Released value

Federal Reserve

Methods

Response Fields

Name State
County County

Snapshots

Snapshots can be accessed through symbol, url, country, state or county. All have pagination.

Methods

Response Fields

Symbol Unique symbol used by TradingEconomics
Country Country name
Category Indicator category name
Last Latest released value
Date Release time and date in UTC
Previous Value for the previous period after the revision (if revision is applicable)
PreviousDate Release time and date in UTC of the previous value
Frequency Frequency of the indicator
Popularity
Start
Unit Unit of the value
Adjustment
URL Hyperlink at Trading Economics
LastUpdate Time when new data was inserted or changed

Historical

Methods

Response Fields

Symbol Unique symbol used by TradingEconomics
Date Release time and date in UTC
Value Released value

Excel

Download the Trading Economics Excel Add In installer, launch it and follow the instructions. We support Excel 2010, 2013, 2016 (32 and 64bit) only for Windows. After installing the Trading Economics Excel Add In click on TE tab and then click on login button, insert the access key and hit Submit button.
Click here to download detailed user guide.