NAV Navbar
Python R Javascript 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.

Authentication

You can get Python from: https://www.python.org/downloads/

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:

pip3 install tradingeconomics

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

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 and stringr packages.

library(devtools)
library(stringr)

Install the tradingeconomics package.

install_github("tradingeconomics/tradingeconomics/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()

Trading Economics Node package

You can get Node.js from: https://nodejs.org/en/download/

First install tradingeconomics package. In Windows Command Prompt or Linux bash type:


    npm install tradingeconomics
    

To start using the Trading Economics Node package:


    const te = require('tradingeconomics');

If you have a client key type it, if not just leave it blank and a sample of data will be provided.

You can get your test key at https://developer.tradingeconomics.com


    te.login('client_key');

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/united%20states,china/indicator/gdp,population


To run our c# examples (except streaming), you can go to an online editor

Open the online editor:


 https://repl.it/languages/csharp

Paste the code on the editor window


Hit run button

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/united%20states,china/indicator/gdp,population

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/united%20states,china/indicator/gdp,population

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/mexico/?client=guest:guest"
Using Headers auth:
curl -i "https://api.tradingeconomics.com/country/mexico/" -H "Authorization: Client guest:guest"

Without an API key all requests will return the default sample data.

GitHub

You can look for other examples on how to use our API in different programming languages, in our GitHub repository.

Data Types

You can request data in several formats:

Status codes

Notes

Indicators

Trading Economics National Statistical database includes more than 15,000 dataseries that come directly from official sources like central banks, national statistical agencies. It is a comprehensive database covering the most important macroeconomic data for each country from GDP growth rates to tax rates and population.

Snapshot

To get a list of indicators available.

getIndicatorData(outType = 'df')

To get a list of all countries.

getAllCountries(outType = 'df')

To get a list of all indicators per country.

getIndicatorData('mexico',outType = 'df')

Output:
        country                      Category     Title                         LatestValue              
2          Mexico         Auto Exports            Mexico Auto Exports          275.00  ...
21         Mexico         Balance of Trade        Mexico Balance of Trade      2.40    ...
3          Mexico         Banks Balance Sheet     Mexico Banks Balance Sheet   7267.00 ...

To get a list of all indicators per country and group.

getIndicatorData(country = 'mexico', group = 'money', outType = 'df')

To get several countries and indicators

getIndicatorData(country = c('mexico','sweden'), indicator = 'gdp', outType = 'df')

        Output:
              country              Category    ...    LatestValue   
2               Mexico                   GDP   ...    275.00
21              Sweden        Inflation Rate   ...       2.5

To get indicator data by ticker or tickers.

getIndicatorData(ticker = 'usurtot', outType = 'df')
 

To get indicator peers data by ticker.

getPeers(ticker = 'CPI YOY', outType = 'df')
 

To get indicator peers data by country.

getPeers(country = 'mexico', outType = 'df')
 

To get indicator peers data by country and category.

getPeers(country = 'mexico', category = 'money', outType = 'df')
 

To get a list of all indicators available.

te.getIndicatorData(output_type='df')

To get a list of all countries.

te.getAllCountries(output_type='df')

To get a list of Indicators by country.

te.getIndicatorData(country=['mexico', 'sweden'], 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

To get a specific indicator for all countries.

te.getIndicatorData(indicators='gdp' , output_type='df')

Output:
           Country         ...             PreviousValueDate
0    Algeria          ...           2020-12-31T00:00:00
1    Albania          ...           2012-10-08T00:00:00
2    Afghanistan          ...           2012-11-07T00:00:00

List of indicators by country and category group.

te.getIndicatorByCategoryGroup(country='mexico', category_group='gdp', output_type='df')

To get country and indicators

te.getIndicatorData(country='mexico', indicators='gdp')

Output:
{'Mexico': 
  {'GDP': 
    [{'LatestValue': 1293.04, 'LatestValueDate': '2021-12-31T00:00:00', 'Source': 'World Bank', 
    'Unit': 'USD Billion', 'CategoryGroup': 'GDP', 'Frequency': 'Yearly', 'PreviousValue': 1087.12, 
    'PreviousValueDate': '2020-12-31T00:00:00'}]
  }
}

To get data by specific ticker or tickers.

te.getIndicatorByTicker(ticker='usurtot', output_type='df')

To get data of indicator peers by specific ticker.

te.getPeers(ticker='CPI YOY', output_type='df')

To get data of indicator peers by specific country.

te.getPeers(country='mexico', output_type='df')

To get data of indicator peers by specific country and category.

te.getPeers(country='mexico', category='money', output_type='df')

To get a list of all indicators, no parameters are required.


    data = te.getIndicatorData().then(function(data){
        console.log(data)       
    });

To get a list of all countries.


  data = te.getAllCountries().then(function(data){
      console.log(data)       
  });

To get a list of indicators by country or countries.


    data = te.getIndicatorData(country = ['mexico']).then(function(data){
        console.log(data)       
    });

To get a list of indicators by country and group.


    data = te.getIndicatorData(country = 'mexico', group = 'gdp' ).then(function(data){
        console.log(data)       
    });

To get a list of all countries with a specific indicator.


    data = te.getIndicatorData(indicator = 'gdp').then(function(data){
        console.log(data)       
    });

To get a list of indicators by ticker.


  data = te.getIndicatorData(ticker = 'usurtot').then(function(data){
      console.log(data)       
  });

To get a list of indicator peers by ticker.


  data = te.getPeers(ticker = 'CPI YOY').then(function(data){
      console.log(data)       
  });

To get a list of indicator peers by country.


  data = te.getPeers(country = 'mexico').then(function(data){
      console.log(data)       
  });

To get a list of indicator peers by country and category.


    data = te.getPeers(country = 'mexico', category = 'money').then(function(data){
        console.log(data)       
    });
  

Without an API key only a small sample of data will be given.
You can get your test key at https://developer.tradingeconomics.com


To get a list of all indicators.


using System;
using System.IO;
using System.Net;

namespace Examples.System.Net
{
    public class Indicators
    {
        public static void Main()
        {
            // replace guest:guest with your key
            WebRequest request = WebRequest.Create(
                "https://api.tradingeconomics.com/indicators?c=guest:guest");
            WebResponse response = request.GetResponse(); 
            Console.WriteLine(((HttpWebResponse)response).StatusDescription);    

            using (Stream dataStream = response.GetResponseStream())
            { 
                StreamReader reader = new StreamReader(dataStream);
                String responseFromServer = reader.ReadToEnd();
                Console.WriteLine(responseFromServer);
            }     
            response.Close();
        }
    }        
}

Get a list of indicators from a country.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/country/{put country name here}?c=guest:guest");

Get specific indicator for all countries.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/country/all/{put indicator name here}?c=guest:guest");

This is only a small sample of the code. Check here for the complete sample code.


To get a list of all indicators.


public static void getIndicators() throws IOException
{
    //set the path
    String path = "/indicators";   
    System.out.println("Get a list of all indicators");
    constructUrl (path);
}

To get a list indicators by country.


public static void getIndicatorsByCountry() throws IOException
{
    //put country name here
    String params = "united states"; 
    params = params.replaceAll("\\s","%20""); 
    //set the path
    String path = "/country" + "/" + params;   
    System.out.println("Get a list of indicators by country");
    constructUrl (path);
}

To get a list of all countries with a specific indicator.


public static void getIndicatorsByIndicator() throws IOException
{
    //put indicator name here
    String params = "gdp"; 
    params = params.replaceAll("\\s","%20""); 
    //set the path
    String path = "/country/all" + "/" + params;   
    System.out.println("Get a list of all countries with a specific indicator");
    constructUrl (path);
}

To get a list of all indicators.
Remember, without a client key only a sample of data will be provided.

<?php
$url = 'https://api.tradingeconomics.com/indicators';
$headers = array(
    "Accept: application/xml",
    "Authorization: Client guest:guest"
);
$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....
//showing result
echo($data);
?>

To get a list of indicators by country.


    $url = 'https://api.tradingeconomics.com/country/{put country name here}';

To get a list of a specific indicator for all countries.


    $url = 'https://api.tradingeconomics.com/country/all/{put indicator name here}';


Peers


Response Fields

Country Country name
Category Category name
CategoryGroup Category group 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 Economics
Adjustment Data description, for example: base period, price adjustement, seasonality
Frequency Frequency of the indicator
HistoricalDataSymbol Unique symbol used by Trading Economics
CreateDate Time when an indicator was inserted
FirstValueDate Date of the first value in the historical series
PreviousValue Previously released value
PreviousValueDate Date of the previously released value
Peer Related ticker
Relationship -1 itself, 0 related, 1 component, 2 parent, 3 derivative

Historical

To get historical data of GDP in Mexico.

getHistoricalData(country = 'mexico', indicator = 'gdp')

        Output:
        country        Category     Frequency     Value         ...
2          Mexico         GDP       Monthly       1269.40       ...
21         Mexico         GDP       Monthly       1087.12       ...
3          Mexico         GDP       Monthly       1293.04       ...

To get historical data for several countries and indicators.

getHistoricalData(country = c('mexico','sweden'), indicator = c('gdp','population'),
                  initDate = '2006-01-01',
                  outType = 'df')

To get historical data by ticker.

getHistoricalData(ticker = 'USURTOT', initDate = '2015-03-01')

To get historical data by symbol.

getHistorical('USURTOT')

To get historical updates.

getHistoricalUpdates(outType ='df')

        Output:
Country            Category                             HistoricalDataSymbol        LastUpdate  
Costa Rica         Wages                                COSTARICAWAG                2022-05-23T16:32:00
Costa Rica         Leading Economic Index               COSTARICALEAECOIND          2022-05-23T16:32:00
Costa Rica         Labor Force Participation Rate       COSTARICALFPR               2022-05-23T16:32:00

To get discontinued series.

getDiscontinuedIndicators(outType ='df')

To get discontinued series by country.

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

To get discontinued series for multiple countries.

getDiscontinuedIndicators(country = c('united states', 'china'), outType ='df')

Historical data by country, indicator and dates.

te.getHistoricalData(country='mexico', indicator='gdp')
te.getHistoricalData(country='mexico', indicator='gdp', initDate='2013-01-01')
te.getHistoricalData(country='mexico',  indicator='gdp',  initDate='2015-01-01', endDate='2015-12-31')

Historical data by multiple countries and specific indicator and dates.

te.getHistoricalData(country=['mexico', 'sweden'], indicator='gdp', initDate='1990-01-01', endDate='2015-01-01')

Historical data by multiple indicators and specific country and dates.

te.getHistoricalData(country='mexico',  indicator=['gdp','population'], initDate='1990-01-01', endDate='2015-01-01')

Historical data by multiple countries, indicators and dates.

te.getHistoricalData(country=['mexico', 'sweden'], indicator=['gdp','population'], initDate='1990-01-01', endDate='2015-01-01')

Get historical data by ticker and start date.

te.getHistoricalByTicker(ticker = 'USURTOT', start_date = '2015-03-01')                       
    

Getting historical data by ticker or TE symbol.

te.getHistorical('USURTOT')                

Get historical latest updates.

te.getHistoricalUpdates()                


Output:
{
'Country': 'Costa Rica',
'Category': 'Wages',
'HistoricalDataSymbol': 'COSTARICAWAG',
'LastUpdate': '2022-05-23T16:32:00'
}

»»»»»»»»»»»»»»»»»»»»»»»»»» BULK DOWNLOAD EXAMPLE «««««««««««««««««««««««««

Get discontinued indicators.

te.getDiscontinuedIndicator()                
te.getDiscontinuedIndicator(country = 'united states',output_type = 'df'  )                
te.getDiscontinuedIndicator(country = ['united states', 'china'], output_type = 'df'  )                

To get a list of Historical data for specific country or countries and indicator.


    data = te.getHistoricalData(country = 'mexico', indicator = 'gdp').then(function(data){
        console.log(data)       
    });
  

    data = te.getHistoricalData(country = ['mexico','sweden'], indicator = ['gdp','population']).then(function(data){
        console.log(data)       
    });
  

You can specify a start date, or even start and end date (date format is yyyy-mm-dd).


    data = te.getHistoricalData(country = 'mexico', indicator = 'gdp', start_date = '2015-01-01', 
    end_date = '2015-12-31').then(function(data){ 
        console.log(data)       
    });
  

You can specify a ticker, and a start date (date format is yyy-mm-dd).


    data = te.getHistoricalData(ticker = 'usurtot', start_date = '2015-03-01' ).then(function(data){
        console.log(data)       
    });

Get historical latest updates


    data = te.getHistoricalUpdates().then(function(data){
        console.log(data)       
    });



Get discontinued series.


    data = te.getDiscontinuedIndicators().then(function(data){
        console.log(data)       
    });

    data = te.getDiscontinuedIndicators(country = 'united states').then(function(data){
        console.log(data)       
    });

    data = te.getDiscontinuedIndicators(country = ['united states', 'china'] ).then(function(data){
        console.log(data)       
    });

To get historical data for given countries and indicators.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/historical/country/{put country name here}/indicator/{put indicator name here}?c=guest:guest");

Get historical data for given countries and indicators in a date range (date format: YYYY-MM-DD).


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/historical/country/{put country name here}/indicator/{put indicator name here}/{put start date here}/{put end date here}?c=guest:guest");  

Get historical by ticker and start date.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/historical/ticker/{put ticker symbol here}/{put start date here}?c=guest:guest");
    

This is only a small sample of the code. Check here for the complete sample code.


To get historical data by country and indicator.


public static void getHistoricalCountryIndicator() throws IOException
{
    //put country name here
    String params = "united states" + "/"; 
    params = params.replaceAll("\\s","%20"");
    //put indicator name here
    String params1 = "gdp"; 
    params1 = params1.replaceAll("\\s","%20"");
    //set the path
    String path = "/historical/country" + "/" + params + "indicator/" + params1;   
    System.out.println("Get historical data by country and indicator");
    constructUrl (path);
}

To get historical data by country, indicator and start date.


public static void getHistoricalCountryIndicatorDate() throws IOException
{
    //put country name here
    String params = "united states" + "/"; 
    params = params.replaceAll("\\s","%20"");
    //put indicator name here
    String params1 = "gdp"; 
    params1 = params1.replaceAll("\\s","%20"");
    //put start date here (date format: yyyy-mm-dd)
    String date = "2013-01-01";
    //set the path
    String path = "/historical/country" + "/" + params + "indicator/" + params1 + "/" + date;   
    System.out.println("Get historical data by country, indicator and start date");
    constructUrl (path);
}

To get a list of historical data for specific country and indicator.
Remember, without a client key only a sample of data will be provided.

<?php
$url = 'https://api.tradingeconomics.com/historical/country/{put country or countries name here}/indicator/{put indicators name here}';
$headers = array(
    "Accept: application/xml",
    "Authorization: Client guest:guest"
);
$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....
//showing result
echo($data);
?>

To get a historical data by start date. Date format is - yyyy-mm-dd


$url = 'https://api.tradingeconomics.com/historical/country/{put country or countries name here}/indicator/{put indicators name here}/{put date here}';

To get a historical data by symbol and date.


$url = 'https://api.tradingeconomics.com/historical/ticker/{put symbol name here}/{put date here}';


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

*Python package response field returns Value instead of Close.



Discontinued Series

Credit Rating



To get Credit Ratings.

te.getRatings( output_type='df')
    


To get Credit Rating data for one country.

te.getRatings(country= 'mexico', output_type='df')


To get Credit Rating data for several countries.

te.getRatings(country=['mexico','sweden'], output_type='df')

              Country     TE   TE_Outlook      SP    SP_Outlook    Moodys    Moodys_Outlook    Fitch    Fitch_Outlook    Outlook
  0            Mexico     60     Stable      BBB      Stable        Baa2        Stable         BBB-          Stable        NaN
  1            Sweden     99     Stable      AAA      Stable       Aaa          Stable         AAA           Stable        NaN


To get Credit Rating historical data for one country.

te.getHistoricalRatings(country= 'mexico', output_type='df')


To get Credit Rating historical data for several countries.

te.getHistoricalRatings(country=['mexico','sweden'])
 
     Country        Date       Agency    Rating         Outlook    
  0    Mexico     7/8/2022     Moody's   Baa2           Stable               
  1    Sweden     4/17/2012    DBRS      AAA            Stable 



To get Credit Rating historical data for one country by start and end date.

te.getHistoricalRatings(country= 'mexico',initDate= '2011-01-01',  endDate= '2012-01-01',output_type='df')


To get Credit Rating historical data for one country using only start date.

te.getHistoricalRatings(country= 'mexico',initDate= '2011-01-01', output_type='df')

To get the last ratings for all countries.

getCreditRating()  

Output:
           country         TE     SP_Outlook   
2          Albania         35         Stable
21         Andorra         60         Stable
3           Angola         26       Negative

To get Credit Rating by country.

getCreditRating('mexico')            

To get Credit Rating by several countries.

getCreditRating(country = c('mexico','sweden'),outType = 'df')            

To get Historical Credit Rating by country.

getCreditRatingHistorical('mexico' )          

To get Historical Credit Rating by country and a start date.

getCreditRatingHistorical(country = 'mexico' , initDate = '2011-01-01')          

To get Historical Credit Rating by country and dates.

getCreditRatingHistorical(country = 'mexico' , initDate = '2011-01-01', endDate = '2012-01-01')          

To get credit ratings for all countries, no parameters are required.


    data = te.getRatings().then(function(data){
        console.log(data)       
    });

To get credit rating for specific country.


    data = te.getRatings(country = 'mexico').then(function(data){
        console.log(data)       
    });

To get credit ratings for multiple countries.


    data = te.getRatings(country = ['mexico', 'sweden']).then(function(data){
        console.log(data)       
    });

To get historical ratings.


    data = te.getRatings(historical = 'mexico').then(function(data){
        console.log(data)       
    });

To get historical ratings giving a start date.


    data = te.getRatings(historical = 'mexico', start_date = '2011-01-01').then(function(data){
        console.log(data)       
    });

To get historical ratings by specifying a start and an end dates.


    data = te.getRatings(historical = 'mexico', start_date = '2011-01-01', end_date = '2015-01-01').then(function(data){
        console.log(data)       
    });

To get a list of all credit ratings.
Remember, without a client key only a sample of data will be provided.

<?php
$url = 'https://api.tradingeconomics.com/ratings';
$headers = array(
    "Accept: application/xml",
    "Authorization: Client guest:guest"
);
$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....
//showing result
echo($data);
?>

To get ratings by country or countries.


$url = 'https://api.tradingeconomics.com/ratings/{put country or countries name here}';

To get a historical ratings by country or countries.


$url = 'https://api.tradingeconomics.com/ratings/historical/{put country or countries name here}';

Without an API key only a small sample of data will be given.
You can get your test key at https://developer.tradingeconomics.com


To get all credit ratings.


using System;
using System.IO;
using System.Net;

namespace Examples.System.Net
{
    public class Indicators
    {
        public static void Main()
        {
            // replace guest:guest with your key
            WebRequest request = WebRequest.Create(
                "https://api.tradingeconomics.com/ratings?c=guest:guest");
            WebResponse response = request.GetResponse(); 
            Console.WriteLine(((HttpWebResponse)response).StatusDescription);    

            using (Stream dataStream = response.GetResponseStream())
            { 
                StreamReader reader = new StreamReader(dataStream);
                String responseFromServer = reader.ReadToEnd();
                Console.WriteLine(responseFromServer);
            }     
            response.Close();
        }
    }        
}

Get a list of ratings from a country or countries.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/ratings/{put country name here}?c=guest:guest");   

Get historical ratings by country and dates (date format is: YYYY-MM-DD).


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/ratings/historical{put country name here}/{put start date here}/{put end date here}?c=guest:guest");

Get historical ratings for one or multiple countries .


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/ratings/historical{put country name here}?c=guest:guest");

This is only a small sample of the code. Check here for the complete sample code.


To get a list of all credit ratings.


public static void getRatings() throws IOException
{
    //set the path
    String path = "/ratings";   
    System.out.println("Get a list of all credit ratings");
    constructUrl (path);
}

To get a list of credit ratings by country or countries.


public static void getRatingsCountry() throws IOException
{
    //put country or countries name here
    String params = "united states"; 
    params = params.replaceAll("\\s","%20"");
    //set the path
    String path = "/ratings" + "/" + params;   
    System.out.println("Get a list of credit ratings by country or countries");
    constructUrl (path);
}

To get a list of historical credit ratings for one country or multiple countries.


public static void getRatingsHistoricalCountry() throws IOException
{
    //put country or countries name here
    String params = "united states,portugal"; 
    params = params.replaceAll("\\s","%20"");
    //set the path
    String path = "/ratings/historical" + "/" + params;   
    System.out.println("Get a list of historical credit ratings for multiple countries");
    constructUrl (path);
}


Response Fields

Country Country name
TE Trading Economics rating
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
DBRS DBRS rating
DBRS_Outlook DBRS outlook
Date Release time and date in UTC
Agency Rating agency
Rating Rating score
Outlook Rating outlook

Latest updates

Without specifying the date a sample of the latest updates will be provided.

te.getLatestUpdates(output_type='df')

To get latest updates using a starting date.

te.getLatestUpdates(init_date='2018-08-15')

        HistoricalDataSymbol              LastUpDate        
  0                   USASSR     20-02-2019T13:47:00                       
  1                  USASSRC     22-09-2017T13:49:00       
  2                  USASSRE     28-06-2016T13:49:00         
  3     MOZAMBIQUEGROFIXCAPF     22-04-2014T15:15:00           
  4         MOZAMBIQUECONSPE     21-03-2014T15:16:00          
  5         MOZAMBIQUEGOVSPE     15-10-2013T15:17:00              

To get latest updates by country.

te.getLatestUpdates(country='portugal')

To get latest updates by country using a starting date.

te.getLatestUpdates(country='portugal', init_date='2018-08-15')
  

To get latest updates by date (yyyy-mm-dd) and time (hh:mm).

te.getLatestUpdates(init_date='2021-10-18', time='15:20')
  

To get the latest updates by date.
with no specific date, a list of the latest updates will be provided.


getLatestUpdates( '2018-02-22')           

To get the latest updates by country.


getLatestUpdates(country = 'united states')           

To get the latest updates by country and date.


getLatestUpdates(country = 'united states', initDate = '2018-02-22')           

To get the latest updates by date and time.


getLatestUpdates(initDate = '2021-10-18', time = '21:20')           

To get the latest updates, no parameters are required.


    data = te.getLatestUpdates().then(function(data){
        console.log(data)       
    });

To get updates from a starting date (date format is yyyy-mm-dd).


    data = te.getLatestUpdates(start_date = '2018-02-02').then(function(data){
        console.log(data)       
    });

To get latest updates by country.


  data = te.getLatestUpdates(country = 'sweden').then(function(data){
      console.log(data)       
  });

To get updates from a starting date (date format is yyyy-mm-dd) and country.


  data = te.getLatestUpdates(start_date = '2018-02-02', country = 'sweden').then(function(data){
      console.log(data)       
  });

To get updates from a starting date (date format is yyyy-mm-dd) and time (hh:mm).


  data = te.getLatestUpdates(start_date = '2021-10-18', time = '15:20').then(function(data){
      console.log(data)       
  });

To get latest updates.


$url = 'https://api.tradingeconomics.com/updates';

To get updates by date. Date format is - yyyy-mm-dd.


$url = 'https://api.tradingeconomics.com/updates/{put date here}';

Get the latest updates.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/updates?c=guest:guest");

Get latest updates by a specific date (date format: YYY-MM-DD).


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/updates/{put date here}?c=guest:guest");

This is only a small sample of the code. Check here for the complete sample code.


To get a list of the latest updates by start date.


public static void getLatestUpdatesByDate() throws IOException
{
    //put start date here (date format: yyyy-mm-dd)
    String date = "2018-01-01";
    //set the path
    String path = "/updates" + "/" + date;   
    System.out.println("Get latest updates by a start date");
    constructUrl (path);
}


Response Fields

Country Country name
Category Category name
HistoricalDataSymbol Unique symbol used by Trading Economics
LastUpdate Time when new data was inserted or changed

Economic Calendar

The economic calendar covers around 1600 events for more than 150 countries a month.

Events

To get all calendar events.

getCalendarData()           

To get all calendar events by importance.

getCalendarData(importance = '2')           

Filter calendar events by dates and importance.

getCalendarData(initDate = '2021-01-01', endDate = '2021-02-02')           
getCalendarData(initDate = '2021-01-01', endDate = '2021-02-02', importance = '2')           

To get information about calendar events by country, dates and importance

getCalendarData(country = 'united states', outType = 'df')
getCalendarData(country = 'united states', importance = '2',  outType = 'df')
getCalendarData(country = 'united states', initDate = '2021-02-02', endDate  = '2021-03-03',  outType = 'df')

To get information about calendar events for several countries and indicators

getCalendarData(country = 'united states', indicator = 'initial jobless claims',
                initDate = '2006-01-01', endDate = '2016-12-31',
                outType = 'df')

To get information about calendar events for specific indicator.

getCalendarData(indicator = 'inflation rate')

To get information about calendar events for specific indicator within a date interval.

getCalendarData(indicator = 'inflation rate', initDate = '2006-01-01', endDate = '2016-12-31',outType = 'df')

To get calendar events by specific id.

getCalendarData(id = c('174108', '160025', '160030' ), outType = 'df')

CalendarId               date      Country                     Event
1  174108  2018-06-19 00:00:00  Azerbaijan   Holidays End of Ramadan                           
2  160025  2018-06-21 07:00:00       Spain            Factory Orders                                   
3  160030  2018-06-23 06:15:00     Bahrain            Inflation Rate

To get calendar events for specific ticker.

getCalendarData(ticker = 'IJCUSA')

To get calendar events for specific ticker within a date interval.

getCalendarData(ticker = 'IJCUSA', initDate = '2006-01-01', endDate = '2016-12-31',outType = 'df')

To get calendar updates.

getCalendarUpdates(outType = 'df')

With no parameters passed you'll get a list of all calendar events available.

te.getCalendarData(output_type='df')

To get calendar data by importance. With no parameters passed you'll get a list of all calendar events available.

te.getCalendarData(importance='1', output_type='df')

To get calendar events for all countries by date.

te.getCalendarData(initDate='2016-02-01', endDate='2016-02-02', output_type='df')

To get calendar events for all countries by dates and importance.

te.getCalendarData(initDate='2016-02-01', endDate='2016-02-02', importance='3', output_type='df')

To get calendar data for a specific country.

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

To get calendar data for a specific country by importance.

te.getCalendarData(country='united states', importance='2',  output_type='df')

To get calendar data for a specific country by dates.

te.getCalendarData(country='united states', initDate='2018-02-01', endDate='2018-02-02', output_type='df')

To get calendar data for a specific indicator.

te.getCalendarData(category='inflation rate', output_type='df')

To get calendar data for a specific indicator by importance.

te.getCalendarData(category='inflation rate', importance='2',  output_type='df')

To get calendar data for a specific indicator by dates.

te.getCalendarData(category='inflation rate', initDate='2018-02-01', endDate='2018-02-02', output_type='df')

For multiple countries.

te.getCalendarData(country=['united states', 'united kingdom'],output_type='df')

For multiple countries and importance.

te.getCalendarData(country=['united states', 'united kingdom'], importance='1', output_type='df')

For multiple countries and by dates.

te.getCalendarData(country=['united states', 'united kingdom'], initDate='2022-02-10', endDate='2022-03-15', output_type='df')

For multiple countries by dates and importance.

te.getCalendarData(country=['united states', 'united kingdom'], initDate='2022-02-10', endDate='2022-03-15', importance='1', output_type='df')

Calendar events for a specific country and specific indicator.

te.getCalendarData(country='united states', category='initial jobless claims', output_type='df')

Calendar events for a specific country and specific indicator and by dates.

te.getCalendarData(country='united states', category='initial jobless claims', initDate='2017-06-07', endDate='2017-12-31', output_type='df')

Calendar events for a specific group.*

te.getCalendarEventsByGroup(group='bonds', output_type='df')

te.getCalendarEventsByGroup(group='inflation',  initDate='2023-01-01', endDate='2023-02-01', output_type='df')

Calendar events for country and a specific group.*

te.getCalendarEventsByGroup(country='united states', group='inflation', output_type='df')

te.getCalendarEventsByGroup(country='united states', group='inflation',  initDate='2023-01-01', endDate='2023-02-01', output_type='df')

Available groups are: interest rate, inflation, bonds, consumer, gdp, government, housing, labour, markets, money, prices, trade, business.

Get Calendar events by a specific Id.


te.getCalendarId(id = '174108')

Get Calendar events by multiple Ids.


te.getCalendarId(id = ['160025',  '174108',  '160030'], output_type=  'df')

Get Calendar events by a specific ticker.


te.getCalendarData(ticker =  'IJCUSA', output_type =  'df')

Get Calendar events by multiple tickers.


te.getCalendarData(ticker = ['IJCUSA',  'SPAINFACORD',  'BAHRAININFNRATE'], output_type =  'df')

Get Calendar events by a multiple tickers and by dates.


te.getCalendarData(ticker = ['IJCUSA',  'SPAINFACORD',  'BAHRAININFNRATE'],  initDate='2017-06-07', endDate='2017-12-31', output_type =  'df')

To get calendar updates.


te.getCalendarUpdates(output_type =  'df')

To get all calendar events, no parameters are required.


data = te.getCalendar().then(function(data){
    console.log(data)       
});

To get all calendar events sorted by importance.


data = te.getCalendar(importance = '1').then(function(data){
    console.log(data)       
});

To filter calendar events by a date (date format is yyyy-mm-dd).


data = te.getCalendar(start_date = '2016-02-01', end_date = '2016-02-10'  ).then(function(data){
    console.log(data)     
});

To get calendar events by country.


data = te.getCalendar(country = 'united states').then(function(data){
    console.log(data)     
});

To get calendar events by country and date (date format is yyyy-mm-dd).


data = te.getCalendar(country = 'united states', start_date = '2016-02-01', end_date = '2016-02-10'  ).then(function(data){
    console.log(data)     
});

To get calendar events by indicator.


data = te.getCalendar(indicator = 'inflation rate').then(function(data){
    console.log(data)     
});

To get calendar events by indicator and date (date format is yyyy-mm-dd).


data = te.getCalendar(indicator = 'inflation rate', start_date = '2016-02-01',end_date = '2016-02-10')
.then(function(data){
        console.log(data)     
});

To get calendar events by specific group.*


data = te.getCalendarEventsByGroup(group = 'bonds')
.then(function(data){
        console.log(data)     
});

data = te.getCalendarEventsByGroup(group = 'bonds', start_date = '2018-01-01',end_date = '2023-12-01')
.then(function(data){
        console.log(data)     
});

To get calendar events by specific country and group.*


data = te.getCalendarEventsByGroup(group = 'inflation', country = 'china')
.then(function(data){
        console.log(data)     
});

data = te.getCalendarEventsByGroup(group = 'inflation', country = 'china', start_date = '2018-01-01',end_date = '2023-12-01')
.then(function(data){
        console.log(data)     
});

*Available groups are: interest rate, inflation, bonds, consumer, gdp, government, housing, labour, markets, money, prices, trade, business.

Filter calendar events by calendar ID or multiple ids.


data = te.getCalendar(id = ['174108','160025','160030']).then(function(data){
    console.log(data)     
});

Filter calendar events by ticker.


data = te.getCalendar(ticker = ['IJCUSA','SPAINFACORD','BAHRAININFNRATE']).then(function(data){
     console.log(data)     
});

To get calendar updates.


data = te.getCalendarUpdates().then(function(data){
    console.log(data)     
});

Without an API key only a small sample of data will be given.
You can get your test key at https://developer.tradingeconomics.com


To get all Calendar events.


using System;
using System.IO;
using System.Net;

namespace Examples.System.Net
{
    public class Calendar
    {
        public static void Main()
        {
            // replace guest:guest with your key
            WebRequest request = WebRequest.Create(
                "https://api.tradingeconomics.com/calendar?c=guest:guest");
            WebResponse response = request.GetResponse(); 
            Console.WriteLine(((HttpWebResponse)response).StatusDescription);    

            using (Stream dataStream = response.GetResponseStream())
            { 
                StreamReader reader = new StreamReader(dataStream);
                String responseFromServer = reader.ReadToEnd();
                Console.WriteLine(responseFromServer);
            }     
            response.Close();
        }
    }        
}

Get Calendar events between two dates.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/calendar/country/All/{put start date here}/{put start date here}?c=guest:guest");

Get Calendar events by country or countries and dates (date format: YYYY-MM-DD).


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/calendar/country/{put country name here}/{put start date here}/{put start date here}?c=guest:guest");

Get Calendar events by indicator or indicators.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/calendar/indicator/{put indicator name here}?c=guest:guest");

Get Calendar events by id.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/calendar/calendarid/{put id here}?c=guest:guest");

This is only a small sample of the code. Check here for the complete sample code.


To get all calendar events.


public static void getCalendar() throws IOException
{ 
    //set the path
    String path = "/calendar" ;    
    System.out.println("Get all calendar events");
    constructUrl (path);
}

To get calendar events between dates.


public static void getCalendarBetweenDates() throws IOException
{
    //put your dates here (date format: YYYY-MM-DD)
    String params = "2016-12-02/2016-12-03"; 
    //set the path
    String path = "/calendar/country/all" + "/" + params;    
    System.out.println("Get calendar events between dates");
    constructUrl (path);
}

To get calendar events by country or countries.


public static void getCalendarByCountry() throws IOException
{
    //put country or countries name here
    String params = "united states,china"; 
    params = params.replaceAll("\\s","%20""); 
    //set the path
    String path = "/calendar/country" + "/" + params;   
    System.out.println("Get calendar by country or countries");
    constructUrl (path);
}

To get calendar events by country and indicator.


public static void getCalendarByCountryIndicator() throws IOException
{
    //put country name here
    String params = "united states" + "/"; 
    params = params.replaceAll("\\s","%20""); 
    //put indicator name here
    String params1 = "initial jobless claims"; 
    params1 = params1.replaceAll("\\s","%20""); 
    //set the path
    String path = "/calendar/country" + "/" + params + "indicator" + "/" + params1;   
    System.out.println("Get calendar by country and indicator");
    constructUrl (path);
}

To get calendar by Id.


public static void getCalendarById() throws IOException
{
    //put id's here
    String params = "174108,160025, 160030" + "/"; 
    params = params.replaceAll("\\s","%20""); 
    //set the path
    String path = "/calendar/calendarid" + "/" + params;   
    System.out.println("Get calendar by specific id");
    constructUrl (path);
}

To get a list of all calendar events.
Remember, without a client key only a sample of data will be provided.

<?php
$url = 'https://api.tradingeconomics.com/calendar';
$headers = array(
    "Accept: application/xml",
    "Authorization: Client guest:guest"
);
$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....
//showing result
echo($data);
?>

To get calendar events by start and end date.


$url = 'https://api.tradingeconomics.com/calendar/country/All/{put start date here}/{put end date here}';

To get calendar events by country or countries.


$url = 'https://api.tradingeconomics.com/calendar/country/{put country or countries name here}';

To get calendar events by country or countries and dates.


$url = 'https://api.tradingeconomics.com/calendar/country/{put country or countries name here}/{put start date here}/{put end date here}';

To get calendar events by indicator or indicators.


$url = 'https://api.tradingeconomics.com/calendar/indicator/{put indicator or indicators name here}';

To get calendar events by country or countries and indicator or indicators.


$url = 'https://api.tradingeconomics.com/calendar/country/{put country or countries name here}/indicator/{put indicator or indicators name here}';

To get calendar events by it's specific id.


$url = 'https://api.tradingeconomics.com/calendar/calendarid/{put id or ids here}';

To get calendar events by ticker. You can also filter by dates.


$url = 'https://api.tradingeconomics.com/calendar/ticker/{put symbol here}';


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 0 Indicates that the time of the event is known, 1 indicates that we only know the date of event, the exact time of event is unknown
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)
Ticker Unique ticker used by Trading Economics
Symbol Unique symbol used by Trading Economics
CalendarID Unique calendar ID used by Trading Economics
OCountry* Country’s original name
OCategory* Category’s original name
OEvent* Event’s original name

*Response fields only used on translated calendar queries.

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 consider that all market-related methods are beta and under heavy development.

Snapshot

To get markets data:

marketsField can be: commodities, currency, crypto, index and bond

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

Output:
        Symbol   ...           Name     ...    DailyChange    ...
2     BDIY:IND   ...     Baltic Dry     ...        -11.000    ...
21    BEEF:IND   ...           Beef     ...        -0.0700    ... 
3      CHE:IND   ...         Cheese     ...        -0.0010    ...
getMarketsData(marketsField = 'currency', outType = 'df')

        Output:
            Symbol    Ticker           Country       Last       
1       USDCVE:CUR    USDCVE        cape verde      98.85        
2       USDKYD:CUR    USDKYD    cayman islands      0.825                
3       USDCLF:CUR    USDCLF             Chile    27754.5    
4       USDCNY:CUR       CNY             china    6.93466             

Get currency crosses

getMarketsData(marketsField = 'currency', cross = 'eur',  outType = 'df')

stock market by symbol or symbols.

getMarketsData(symbol = 'aapl:us', outType = 'df')
getMarketsData(symbol = c( 'aapl:us', 'gac:com'), outType = 'df')

stock market by country.

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

To get markets list:

marketsField can be: commodities, currency, crypto, index and bond

te.getMarketsData(marketsField = 'commodities', output_type = 'df')
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 currency crosses.

te.getCurrencyCross(cross = 'EUR', output_type = 'df')

To get stock market data filtered by instrument or multiple instruments.

te.getMarketsBySymbol(symbols='aapl:us')    

    Output:    
     Symbol Ticker         ...           ISIN           LastUpdate
0  INDU:IND   INDU         ...           None  2018-06-28T14:56:00
te.getMarketsBySymbol(symbols=['aapl:us', 'gac:com'], output_type='raw')   

    Output:    
[{'Symbol': 'AAPL:US', 'Ticker': 'AAPL', 'Name': 'Apple', ..., 'LastUpdate': '2018-06-27T20:05:00'}, 
{'Symbol': 'GAC:COM', 'Ticker': 'GAC', 'Name': 'Gallium', 'Type': 'commodity', ... 'LastUpdate': '2022-04-08T07:02:00'}]

Get markets commodities.


    data = te.getMarketSnap(marketsField = 'commodities').then(function(data){
        console.log(data)     
    });

Get major currencies.


    data = te.getMarketSnap(marketsField = 'currency').then(function(data){
        console.log(data)     
    });

Get currency crosses.


    data = te.getMarketSnap(cross = 'eur').then(function(data){
        console.log(data)     
    });

Get crypto markets.


    data = te.getMarketSnap(marketsField = 'crypto').then(function(data){
        console.log(data)     
    });

Get stock market indexes.


    data = te.getMarketSnap(marketsField = 'index').then(function(data){
        console.log(data)     
    });

Get government bonds.


    data = te.getMarketSnap(marketsField = 'bond').then(function(data){
        console.log(data)     
    });

Get markets by symbol.


    data = te.getMarketSnap(symbol = 'aapl:us').then(function(data){
        console.log(data)     
    });

Get markets for multiple symbols.


    data = te.getMarketSnap(symbol = ['aapl:us', 'gac:com']).then(function(data){
        console.log(data)     
    });

Get stock market by country.


    data = te.getMarketSnap(country = 'japan').then(function(data){
        console.log(data)     
    });

Get a snapshot of the latest peers prices by market.


    data = te.getMarketSnap(peers_symbol = 'aapl:us').then(function(data){
        console.log(data)     
    });

Get stock index markets components.


    data = te.getMarketSnap(components_symbol = 'psi20:ind').then(function(data){
        console.log(data)     
    });

Get stock descriptions by company symbol.


    data = te.getMarketStockDescriptions(symbol = 'aapl:us').then(function(data){
        console.log(data)     
    });

Get stock descriptions by country.


    data = te.getMarketStockDescriptions(country = 'china').then(function(data){
        console.log(data)     
    });

Get stock market searching for country.


    data = te.getMarketSnap(search_term = 'united states').then(function(data){
        console.log(data)     
    });

Get stock market searching for country and category.


    data = te.getMarketSnap(search_term = 'united states', category = 'index').then(function(data){
        console.log(data)     
    });

Get stocks symbology by symbol, ticker or ISIN.


    data = te.getSymbology(symbol = 'aapl:us').then(function(data){
        console.log(data)     
    });

    data = te.getSymbology(ticker = 'aapl').then(function(data){
        console.log(data)     
    });

    data = te.getSymbology(isin = 'US0378331005').then(function(data){
        console.log(data)     
    });

Without an API key only a small sample of data will be given.
You can get your test key at https://developer.tradingeconomics.com


To get markets commodities.


using System;
using System.IO;
using System.Net;

namespace Examples.System.Net
{
    public class Markets
    {
        public static void Main()
        {
            // replace guest:guest with your key
            WebRequest request = WebRequest.Create(
                "https://api.tradingeconomics.com/markets/commodities?c=guest:guest");
            WebResponse response = request.GetResponse(); 
            Console.WriteLine(((HttpWebResponse)response).StatusDescription);    

            using (Stream dataStream = response.GetResponseStream())
            { 
                StreamReader reader = new StreamReader(dataStream);
                String responseFromServer = reader.ReadToEnd();
                Console.WriteLine(responseFromServer);
            }     
            response.Close();
        }
    }        
}

Get markets currency.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/markets/currency?c=guest:guest");

Get currency crosses.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/markets/currency?cross={currency to cross example: eur}&c=guest:guest");

Get markets indexes.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/markets/index?c=guest:guest");

Get markets bonds.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/markets/bond?c=guest:guest");

Get markets for multiple symbols.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/markets/symbol/{put symbols here}?c=guest:guest");

Get markets for a specific symbol (you can choose from stock, index, currency, commodity or bond).


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/markets/symbol/{put symbol here}?c=guest:guest");

Get markets peers.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/markets/peers/{put symbol here}?c=guest:guest");

Get stock market index components.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/markets/components/{put symbol here}?c=guest:guest");

Get stock market by country.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/markets/country/{put country name here}?c=guest:guest");

This is only a small sample of the code. Check here for the complete sample code.


To get a list of commodities.


public static void getMarketCommodities() throws IOException
{
    //set the path
    String path = "/markets/commodities";   
    System.out.println("Get a list of commodities");
    constructUrl (path);
}

To get a list of the major currencies.


public static void getMarketCurrency() throws IOException
{
    //set the path
    String path = "/markets/currency";   
    System.out.println("Get a list of the major currencies");
    constructUrl (path);
}

To get markets by symbol or symbols.


public static void getMarketSymbol() throws IOException
{
    //put symbol or symbols name here
    String params = "aapl:us";
    params = params.replaceAll("\\s","%20"");
    //set the path
    String path = "/markets/symbol" + "/" + params;   
    System.out.println("Get markets by symbol or symbols");
    constructUrl (path);
}

To get stock Market Index Components.


public static void getMarketComponents() throws IOException
{
    //put index component here
    String params = "psi20:ind";
    params = params.replaceAll("\\s","%20"");
    //set the path
    String path = "/markets/components" + "/" + params;   
    System.out.println("Get stock Market Index Components");
    constructUrl (path);
}

The search will look into the categories: Indexes, markets(stocks), bonds, and commodities.


public static void getMarketSearch() throws IOException
{
    //put search term here
    String params = "united states";
    params = params.replaceAll("\\s","%20"");
    //set the path
    String path = "/markets/search" + "/" + params;   
    System.out.println("Search for country");
    constructUrl (path);
}

Search for country and category.


public static void getMarketCategory() throws IOException
{
    //put search term here
    String params = "united states";
    params = params.replaceAll("\\s","%20"");
    //put category name here
    //Categories available: index, markets, forex, bond and commodity
    String params1 = "index,markets";
    params1 = params1.replaceAll("\\s","%20"");
    //set the path
    String path = "/markets/search" + "/" + params + "?category=" + params1;   
    System.out.println("Search for country and category");
    constructUrl (path);
}

To get markets commodities.
Remember, without a client key only a sample of data will be provided.

<?php
$url = 'https://api.tradingeconomics.com/markets/commodities';
$headers = array(
    "Accept: application/xml",
    "Authorization: Client guest:guest"
);
$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....
//showing result
echo($data);
?>



To get markets currency.


$url = 'https://api.tradingeconomics.com/markets/currency';



To get currency crosses.


$url = 'https://api.tradingeconomics.com/markets/currency?cross=eur';



To get stock market indexes.


$url = 'https://api.tradingeconomics.com/markets/index';



To get goverment bonds.


$url = 'https://api.tradingeconomics.com/markets/bond';



To get one or more markets (stock, index, currency, commodity or bond).


$url = 'https://api.tradingeconomics.com/markets/symbol/{put symbol or symbols name here}';



To get markets by peers.


$url = 'https://api.tradingeconomics.com/markets/peers/{put symbol name here}';



To get markets by components.


$url = 'https://api.tradingeconomics.com/markets/components/{put symbol name here}';



To get stock market index components.


$url = 'https://api.tradingeconomics.com/markets/components/{put symbol name here}';



To get stock market by country.


$url = 'https://api.tradingeconomics.com/markets/country/{put country name here};

Market Lists

To get the peer group of a stock or a group of stocks

te.getMarketsPeers(symbols='aapl:us', output_type='df')

To get a list of stocks by country

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

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

To get Stock descriptions by company symbol:

te.getMarketsStockDescriptions(symbol='aapl:us', output_type='df')

To get Stock descriptions by country:

te.getMarketsStockDescriptions(country='japan', output_type='df')

To get markets lists by components.

getMarketsList(marketsField='components','psi20:ind', outType = 'df')

        Output:
      Symbol    Ticker     Country       Last       
1    ALTR:PL      ALTR    Portugal     5.8350        
2     BCP:PL    BCP:PL    Portugal     0.2535                
3     COR:PL    COR:PL    Portugal    10.3400    
4     CTT:PL    CTT:PL    Portugal     2.2560          

To get markets lists by peers.

getMarketsList(marketsField='peers','aapl:us', outType = 'df')

To get stock markets descriptions by company symbol.

getMarketsStockDescriptions(symbol='aapl:us', outType = 'df')

To get stock markets descriptions by country.

getMarketsStockDescriptions(country='china', outType = 'df')

To search markets by country.

te.getMarketsSearch(country='japan')

To search markets by country and category.

te.getMarketsSearch(term='japan', category = 'index')

To search markets by country and categories.

te.getMarketsSearch(term='japan', category = ['index', 'markets'])

To get stocks symbology.

te.getMarketsSymbology(symbol = 'aapl:us', output_type = 'df')
te.getMarketsSymbology(ticker = 'aapl', output_type = 'df')
    
te.getMarketsSymbology(isin = 'US0378331005', output_type = 'df')
   
Output:
    Symbol            Ticker     ISIN          Name    Country
    AAPL:US           AAPL       US0378331005  Apple   United States    

To get markets search by country, category.

getMarketsSearch('Japan', 'index' )

        Output:
      Symbol   Ticker    Country         Last       
1    NKY:IND      NKY      Japan     21003.37        
2    VXJ:IND      VXJ      Japan        17.68                

To get markets search by country.

getMarketsSearch('united states')

To get markets search by country and categories.

getMarketsSearch('united states', category = c('index', 'markets'))

    Output:
      Symbol        Type            Country         Last       
1    ACWX:US      stocks      United States       47.680        
2    ADR:IND       Index      United States     5262.980                
3    BRKS:US      stocks      United States       36.050                
4     BZH:US      stocks      United States        9.270                
5   CCMP:IND       Index      United States     7607.351                
6     COT:US      stocks      United States       13.090                

To get stocks symbology by symbol, ticker or ISIN.

getSymbology(symbol='aapl:us', outType = 'df')
getSymbology(ticker='aapl', outType = 'df')
getSymbology(isin='US0378331005', outType = 'df')

   Output:
      Symbol        Ticker            ISIN         Name         Country       
1     AAPL:US       AAPL          US0378331005     Apple        United States        

By Default, the search will look into the categories: Indexes, markets(stocks), bonds, and commodities.

Categories available: index, markets, forex, bond and commodity.


Response Fields

Symbol Unique symbol used by Trading Economics
Ticker Unique ticker used by Trading Economics
Name Indicator full name
Country Country name
Date Release time and date in UTC
Group* Group name
Type* Market type
MarketCap* Market Capitalization
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
Frequency Market frequency
Relationship* 0 - component, 1 - peer



Group* - only in :

/markets/commodities, /markets/index, /markets/currency, /markets/bond and /markets/currency?cross=eur.

Type* and MarketCap* not in :

/markets/commodities, /markets/index, /markets/currency, /markets/bond and /markets/currency?cross=eur.

Relationship* only in :

/markets/peers/{symbol}, /markets/components/{symbol}.


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

Historical

To get historical to symbol

te.getHistorical(symbol='aapl:us',output_type='df')

To get historical to multiple symbols

te.getHistorical(symbol=['aapl:us','gac:com'],output_type='df')

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

te.fetchMarkets(symbol='aapl:us', initDate='2017-01-01', endDate='2017-06-15')

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

 te.fetchMarkets(symbol=['aapl:us', 'gac:com'], initDate='2017-01-01', endDate='2017-06-15')


              symbol        open        high         low       close
2022-04-08   AAPL:US     171.78     171.78     169.32001     169.72
2022-04-07   GAC:COM     2605     2605     2605     2605
2022-04-07  AAPL:US  171.16  173.36  169.85  172.14

Get markets historical data by market symbol or symbols.


    data = te.getHistoricalMarkets(symbol = 'aapl:us').then(function(data){
        console.log(data)     
    });

Get markets historical data by market symbol or symbols and dates.


    data = te.getHistoricalMarkets(symbol = 'aapl:us', start_date = '2018-02-02').then(function(data){
        console.log(data)     
    });

    data = te.getHistoricalMarkets(symbol = 'aapl:us', start_date = '2018-02-02',
    end_date = '2019-02-02').then(function(data){
        console.log(data)     
    });

To get from historical markets by symbol.

getHistoricalMarkets('AAPL:US', initDate = '2011-01-01')

    Output: 
       Symbol         Open            High              Low         Close   
1     AAPL:US      65.5871         65.6399          64.0499       64.8028        
2     AAPL:US      65.4871         65.5699          65.0785       65.1699                
                

To get from historical markets by symbols and date.

getHistoricalMarkets(c('AAPL:US','GAC:COM'), initDate = '2011-01-01',endDate='2016-01-01', outType = 'df')               

To get historical data for markets by one or more symbols.
Remember, without a client key only a sample of data will be provided.

<?php
$url = 'https://api.tradingeconomics.com/markets/historical/{put symbol or symbols name here}';
$headers = array(
    "Accept: application/xml",
    "Authorization: Client guest:guest"
);
$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....
//showing result
echo($data);
?>

To get historical markets by symbol and dates. Date format - yyyy-mm-dd.


$url = 'https://api.tradingeconomics.com/markets/historical/{put symbol name here}?d1={put date here}&d2={put date here}';

Get historical markets data by market.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/markets/historical/{put symbol name here}?c=guest:guest");

Get historical markets data by multiple markets.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/markets/historical/{put symbols name here}?c=guest:guest");

Get historical markets data by date.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/markets/historical/{put symbol name here}?d1={put date here}&c=guest:guest");

Get historical markets data within a date interval.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/markets/historical/{put symbol name here}?d1={put date here}&d2={put date here}&c=guest:guest");

This is only a small sample of the code. Check here for the complete sample code.


To get historical data by symbol or symbols.


public static void getHistoricalSymbol() throws IOException
{
    //put symbol name here
    String params = "aapl:us";
    params = params.replaceAll("\\s","%20"");
    //set the path
    String path = "/markets/historical" +  "/" + params;   
    System.out.println("Historical markets by symbo");
    constructUrl (path);
}

To get markets historical data between dates.


public static void getHistoricalBetweenDates() throws IOException
{
    //put symbol name here
    String params = "aapl:us";
    params = params.replaceAll("\\s","%20"");
    //put start date here
    String start_date = "2017-08-01";
    //put end date here
    String end_date = "2017-08-08";
    //set the path
    String path = "/markets/historical" + "/" + params + "?d1=" + start_date + "&d2=" + end_date;   
    System.out.println("Historical markets between dates");
    constructUrl (path);
}


Response Fields

Symbol Unique symbol used by Trading Economics
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='aapl:us',output_type='df')

Output:
        Symbol                 Date     ...             Low       Close
0     AAPL:US  2022-04-08T14:54:00     ...      170.4399  170.575
1     AAPL:US  2022-04-08T14:53:00     ...      170.48  170.48
2     AAPL:US  2022-04-08T14:52:00     ...      170.49001  170.62
 ...       ...                  ...     ...             ...         ...

To get intraday market data for a group of symbols:

te.getMarketsIntraday(symbols=['aapl:us','stx:us'], initDate='2018-03-13 15:30',output_type='df')

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

te.getMarketsIntraday(symbols='aapl:us', initDate='2018-03-13 15:30',output_type='df')

To get intraday market data for a specific symbol and by init date and end date

te.getMarketsIntraday(symbols='aapl:us',initDate='2021-03-13', endDate='2021-03-17',output_type='df')

Aggregate intraday prices by interval.

te.getMarketsIntradayByInterval(symbol='aapl:us', interval='1m', initDate='2021-03-13', endDate='2021-03-17',output_type='df')

Get markets intraday data by market symbol.


    data = te.getMarketsIntraday(symbol = 'aapl:us').then(function(data){
        console.log(data)     
    });

Get markets intraday data by market symbol and dates.


    data = te.getMarketsIntraday(symbol = 'aapl:us', start_date = '2018-03-03', 
    end_date = '2019-04-04').then(function(data){
        console.log(data)     
    });

Get markets intraday data by market symbol, dates and interval.


    data = te.getMarketsIntraday(symbol = 'aapl:us', start_date = '2018-03-03', 
    end_date = '2019-04-04', agr = '5m').then(function(data){
        console.log(data)     
    });

To get markets intraday by symbol and date.

getMarketsIntraday(symbol='AAPL:US',initDate = '2019-02-01',endDate ='2019-02-02', outType = 'df')

     Output: 
        Symbol                   Date         Open         High          Low        Close   
 1     AAPL:US    2019-05-29T15:00:00       177.67       177.67       177.56       177.57        
 2     AAPL:US    2019-05-29T14:59:00       177.73       177.80       177.73       177.76                
 3     AAPL:US    2019-05-29T14:58:00       177.82       177.93       177.82       177.83                
 4     AAPL:US    2019-05-29T14:57:00       177.92       177.92       177.85       177.87                
 5     AAPL:US    2019-05-29T14:56:00       178.07       178.07       177.99       177.99                
 6     AAPL:US    2019-05-29T14:55:00       178.01       178.10       178.00       178.10                
 7     AAPL:US    2019-05-29T14:54:00       178.03       178.10       178.00       178.00                
 8     AAPL:US    2019-05-29T14:53:00       178.13       178.13       177.96       177.97                
                 
 

To get markets intraday by symbol and date and interval.

getMarketsIntraday(symbol='AAPL:US',initDate = '2019-02-01',endDate ='2019-02-02', interval = '5m', outType = 'df')
   

To getintraday prices by symbol.


$url = 'https://api.tradingeconomics.com/markets/intraday/{put symbol name here}';

To getintraday prices by date and hour. Date/hour format - yyyy-mm-dd hh-mm.


$url = 'https://api.tradingeconomics.com/markets/intraday/{put symbol name here}?d1={put date and hour here}';

To getintraday prices within a date interval. Date format - yyyy-mm-dd.


$url = 'https://api.tradingeconomics.com/markets/intraday/{put symbol name here}?d1={put date here}&d2={put date here}';

Get Intraday prices for a single market.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/markets/intraday/{put symbol name here}?c=guest:guest");

Get intraday prices by date and hour (date format: YYYY-MM-DD HH:MM).


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/markets/intraday/{put symbol name here}?d1={put date here}&c=guest:guest");

Get intraday prices by date.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/markets/intraday/{put symbol name here}?d1={put date here}&d2={put date here}&c=guest:guest");

Get intraday prices by interval.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/markets/intraday/{put symbol name here}?agr={put interval here}&d1={put date here}&d2={put date here}&c=guest:guest");

This is only a small sample of the code. Check here for the complete sample code.


To get intraday for a single market.


public static void getIntradayBySymbol() throws IOException
{
    //put symbol name here
    String params = "aapl:us";
    params = params.replaceAll("\\s","%20"");
    //set the path
    String path = "/markets/intraday" +  "/" + params;   
    System.out.println("Intraday for a single market");
    constructUrl (path);
}

To get intraday by symbol date and time.


public static void getIntradayByDateTime() throws IOException
{
    //put symbol name here
    String params = "aapl:us";
    params = params.replaceAll("\\s","%20"");
    //put date and time here (date format yyyy-mm-dd, time format: hh:mm)
    String date = "2017-08-10 15:30";
    date = date.replaceAll("\\s","%20"");
    //set the path
    String path = "/markets/intraday" + "/" + params + "?d1=" + date;   
    System.out.println("Intraday by symbol date and time");
    constructUrl (path);
}


Response Fields

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

Financials

Here you can get stocks earnings and fundamental information.

Snapshot


If no argument is provided, returns a list of all companies available.

te.getFinancialsData()

To get financials data by country.

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

To get financials data by a Maximum of 5 countries.

te.getFinancialsData(country = ['united states', 'china'], output_type = 'df')

List all categories available.

te.getFinancialsCategoryList(output_type = 'df')

To get financials data by category.

te.getFinancialsDataByCategory(category = 'assets', output_type = 'df')

To get financials data by instrument symbol.

te.getFinancialsData(symbol = 'aapl:us', output_type = 'df')

Get financials data.

getFinancialsData(outType = 'df')
   

Financials data by country.

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

Financials data by more than one country.

getFinancialsData(country= c('united states', 'china'), outType = 'df')
   

Financials data by symbol.

getFinancialsData(symbol='aapl:us', outType = 'df')
   

If no argument is provided, returns a list of all companies available.


    data = te.getFinancialsData().then(function(data){
        console.log(data)     
    });

Get financials data for one country.


    data = te.getFinancialsData(country = 'china').then(function(data){
        console.log(data)     
    });

Get financials data for multiple countries.


    data = te.getFinancialsData(country = ['china', 'united states'] ).then(function(data){
        console.log(data)     
    });

List all categories available.


    data = te.getFinancialsCategoryList().then(function(data){
        console.log(data)     
    });

Get financials data by category.


    data = te.getFinancialsDataByCategory(category = 'assets').then(function(data){
        console.log(data)     
    });

Get financials data by instrument symbol.


    data = te.getFinancialsData(symbol = 'aapl:us').then(function(data){
        console.log(data)     
    });


Response Fields

Symbol Unique symbol used by Trading Economics
Name Name of the company
Country Company Country
Date Trading Economics date time in UTC
Last Lastest value
Value1 Value for the current quarter
Date1 Date for the current quarter
Value2 Value for the quarter prior to Value1
Date2 Date for the quarter prior to Date1
Value3 Value for the quarter prior to Value2
Date3 Date for the quarter prior to Date2
Value4 Value for the quarter prior to Value3
Date4 Date for the quarter prior to Date3
Unit Unit
Currency Currency
Frequency Frequency of the financial
Stock Stock unique symbol used by Trading Economics
FinancialSymbol Financials category
Category Financials category
Value Close price value
Report Date Reporting date
Reference Fiscal reference date

Historical

To get historical financials data by instrument symbol.

te.getFinancialsHistorical(symbol = 'aapl:us', category = 'assets', output_type = 'df')

To get historical financials data by multiple instrument symbol.

te.getFinancialsHistorical(['aapl:us' , 'tsla:us'], category =['assets', 'debt'], output_type = 'df')

To get historical financials data by instrument symbol and date interval.

te.getFinancialsHistorical(['aapl:us', 'tsla:us'], category =['assets', 'debt'], initDate = '2021-01-01', endDate ='2023-12-01', output_type = 'df')

Get historical financials data by instrument symbol.

getHistoricalFinancialsData(symbol='aapl:us', category = 'assets', outType = 'df')

Get financials historical data by instrument symbol.


    data = te.getFinancialsHistorical(symbol = 'aapl:us', category = 'assets' ).then(function(data){
        console.log(data)     
    });

Get financials historical data by multiple instrument symbol.


    data = te.getFinancialsHistorical(symbol = ['aapl:us', 'msft:us'], category = 'assets' ).then(function(data){
        console.log(data)     
    });

Get financials historical data by instrument symbol and date interval.


    data = te.getFinancialsHistorical(symbol = ['aapl:us', 'msft:us'], start_date = '2015-01-01', end_date = '2023-01-01', category = 'assets' ).then(function(data){
        console.log(data)     
    });

Response Fields

Symbol Unique symbol used by Trading Economics
Category Financials historical category
Date Trading Economics date time in UTC
Value Value of the historical date
Report Date Reporting date
Reference Fiscal reference date

Earnings Revenues

To get earnings revenues by country.

getEarnings('united states', outType = 'df')

To get earnings revenues by date.

getEarnings(initDate='2017-01-01', outType = 'df')

To get earnings revenues by category.

getEarnings(indicator='aapl:us', category = 'symbol',initDate='2017-01-01')

To get default earnings revenues 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 revenues calendar filtered by date. You can set only a start date:

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

To get earnings revenues calendar filtered by symbol and date. You can set only a start date:

te.getEarnings(symbols = 'aapl: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 revenues 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  ...

To get earnings revenues calendar by country and date:

te.getEarnings(country = 'mexico', initDate = '2016-01-01', endDate ='2023-12-01', output_type = 'df')

Get earnings revenues default calendar, no parameters are required.


    data = te.getEarnings().then(function(data){
        console.log(data)     
    });

Get earnings revenues calendar by date.


    data = te.getEarnings(start_date = '2018-02-02').then(function(data){
        console.log(data)     
    });

Get earnings revenues calendar by symbol and date. You can set only a start date.


    data = te.getEarnings(symbol = 'AAPL:US', start_date = '2018-02-02', end_date = '2019-02-02').then(function(data){
        console.log(data)     
    });

Get earnings revenues calendar by country.


    data = te.getEarnings(country = 'united states').then(function(data){
        console.log(data)     
    });

Get earnings revenues calendar by country and date.


    data = te.getEarnings(country = 'mexico', start_date = '2016-01-01', end_date = '2023-12-31').then(function(data){
        console.log(data)     
    });

To get earnings revenues.
Remember, without a client key only a sample of data will be provided.

<?php
$url = 'https://api.tradingeconomics.com/earnings-revenues';
$headers = array(
    "Accept: application/xml",
    "Authorization: Client guest:guest"
);
$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....
//showing result
echo($data);
?>

To filter earnings revenues revenues calendar by date. Date format - yyyy-mm-dd.


$url = 'https://api.tradingeconomics.com/earnings-revenues?d1={put date here}';

To filter earnings revenues calendar by market and date.


$url = 'https://api.tradingeconomics.com/earnings-revenues/symbol/{put symbol name here}?d1={put date here}&d2={put date here}';

To filter earnings revenues calendar by country.


$url = 'https://api.tradingeconomics.com/earnings-revenues/country/{put country name here}';

To get default earnings revenues calendar.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/earnings-revenues?c=guest:guest");

Get earnings revenues calendar by market and date.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/earnings-revenues/symbol/{put symbol name here}?d1={put date here}&c=guest:guest");

Get earnings revenues calendar by market in a date range (date format: YYYY-MM-DD).


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/earnings-revenues/symbol/{put symbol name here}?d1={put date here}&d2={put date here}&c=guest:guest");

Filter earnings revenues by country.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/earnings-revenues/country/{put country name here}?c=guest:guest");

Filter earnings revenues by type (type can be: earnings revenues, ipo, dividends).


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/earnings-revenues?c=guest:guest&type={put type here}");

This is only a small sample of the code. Check here for the complete sample code.


To get default earnings revenues calendar.


public static void getEarnings() throws IOException
{
    //set the path
    String path = "/earnings-revenues";   
    System.out.println("Default earnings revenues calendar");
    constructUrl (path);
}

Get earnings revenues by symbol within a date interval.


public static void getEarningsBetweenDates() throws IOException
{
    //put symbol name here
    String params = "msft:us";
    params = params.replaceAll("\\s","%20"");
    //put date here (date format yyyy-mm-dd)
    String date = "2016-01-01" + "&d2=" + "2017-12-31";
    date = date.replaceAll("\\s","%20"");
    //set the path
    String path = "/earnings-revenues/symbol" + "/" + params + "?d1=" + date;   
    System.out.println("Get earnings revenues by symbol within a date interval");
    constructUrl (path);
}


Response Fields

Date Release date in UTC
Symbol Unique symbol used by Trading Economics
Name Company name
Actual Earnings per share
Forecast Average forecast among a representative group of analysts
Previous Previously released value
FiscalTag Fiscal year and quarter. E.g. "FY2022Q4"
FiscalReference Fiscal year and quarter in different format. E.g. "Q3"
CalendarReference Calendar quarter for the release
Country Country name
Currency Currency
Session Expected earnings release hour
Importance Importance being 3 the highest.
LastUpdate Time when new data was inserted or changed
marketRelease Release type: after_close, before_open, by_day_end
MarketCapUSD Market cap in US dollar

Forecasts

Trading Economics forecasts are built using a proprietary global macro model that takes into account our analysts’ expectations, correlations between countries, and a set of logical relationships between different indicators.

Indicators

Forecasted values of all indicators of Mexico.

getForecastData(country ='mexico')
        Output:
         country     Category             ...   Q1        Q2         Q3        Q4
2          Mexico    Auto Exports         ...   240       242       243        245   
21         Mexico    Balance of Trade     ...   198       197       196        194 
3          Mexico    Banks Balance Sheet  ...   9622670   9728631   9834592    9940553 

Forecasted values of all indicators by more than one country.

getForecastData(country = c('mexico', 'sweden') )

Forecasted values for a specific indicator.

getForecastData(indicator ='gdp')

Forecasted values for more than one indicator.

getForecastData(indicator = c('gdp', 'population') )

To get forecast data by ticker.

getForecastData(ticker ='usurtot', outType = 'df')

To get forecast data by multiple tickers.

getForecastData(ticker =c('usurtot','wgdpchin'), outType = 'df')

To get data in data frame format type for one country and indicator.

getForecastData(country ='mexico',  indicator = 'gdp', outType = 'df')

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

getForecastData(country =c('mexico','sweden), indicator = c('gdp','population'), outType = 'df')

Forecasted values by country.

te.getForecastData(country='mexico', output_type='df')

Forecasted values for more than one country.

te.getForecastData(country= ['mexico', 'sweden' ], output_type='df')

Forecasted values for a specific indicator.

te.getForecastData(indicator= 'gdp', output_type='df')

Forecasted values for more than one indicator.

te.getForecastData(indicator= ['gdp', 'population'], output_type='df')

Forecasted values for several countries and indicators.

te.getForecastData(country=['mexico', 'sweden'], indicator=['gdp', 'population'], output_type='df')

Forecasted values for specific country and specific indicator.

te.getForecastData(country='mexico', indicator='gdp', output_type='df')

Forecasted values by specific ticker.

te.getForecastByTicker(ticker= 'usurtot', output_type='df')

Forecasted values by multiple tickers.

te.getForecastByTicker(ticker= ['usurtot', 'wgdpchin'], output_type='df')

*Forecast response fields can be diferent from Html response fields.


Python     --- match ---    Html
                  
yearend    -------------    ForecastValue1 
yearend2   -------------    ForecastValue2 
yearend3   -------------    ForecastValue3 
q1         -------------    ForecastValue1Q 
q2         -------------    ForecastValue2Q 
q3         -------------    ForecastValue3Q 
q4         -------------    ForecastValue4Q 

Get forecasts by country.


    data = te.getForecasts(country = 'mexico').then(function(data){
        console.log(data)     
    });

Get forecasts for multiple countries.


    data = te.getForecasts(country = ['mexico','sweden']).then(function(data){
        console.log(data)     
    });

Get forecasts by indicator.


    data = te.getForecasts(indicator = 'gdp').then(function(data){
        console.log(data)     
    });

Get forecasts for multiple indicators.


    data = te.getForecasts(indicator = ['gdp','population']).then(function(data){
        console.log(data)     
    });

Get forecasts by ticker or tickers.


    data = te.getForecasts(ticker = 'usurtot').then(function(data){
        console.log(data)     
    });

    data = te.getForecasts(ticker = ['usurtot','wgdpchin']).then(function(data){
        console.log(data)     
    });

Get forecasts by country and indicator.


    data = te.getForecasts(country = 'mexico', indicator = 'gdp').then(function(data){
        console.log(data)     
    });

    data = te.getForecasts(country = ['mexico','sweden'], indicator = ['gdp','population']).then(function(data){
        console.log(data)     
    });

Without an API key only a small sample of data will be given.
You can get your test key at https://developer.tradingeconomics.com


To get forecasts for a specific country.


using System;
using System.IO;
using System.Net;

namespace Examples.System.Net
{
    public class Forecasts
    {
        public static void Main()
        {
            // replace guest:guest with your key
            WebRequest request = WebRequest.Create(
                "https://api.tradingeconomics.com/forecast/country/{put country name here}?c=guest:guest");
            WebResponse response = request.GetResponse(); 
            Console.WriteLine(((HttpWebResponse)response).StatusDescription);    

            using (Stream dataStream = response.GetResponseStream())
            { 
                StreamReader reader = new StreamReader(dataStream);
                String responseFromServer = reader.ReadToEnd();
                Console.WriteLine(responseFromServer);
            }     
            response.Close();
        }
    }        
}

Get forecasts for multiple countries.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/forecast/country/{put countries name here}?c=guest:guest");

Get forecasts for a specific indicator or indicators.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/forecast/indicator/{put indicators name here}?c=guest:guest");

Get forecasts for country and indicator.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/forecast/country/{put countries name here}/indicator/{put indicators name here}?c=guest:guest");

Get forecasts by specif ticker or tickers.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/forecast/ticker/{put tickers name here}?c=guest:guest");

This is only a small sample of the code. Check here for the complete sample code.


To get forecasts by country.


public static void getForecastByCountry() throws IOException
{
    //put country name here
    String params = "united states";
    params = params.replaceAll("\\s","%20"");
    //set the path
    String path = "/forecast/country" + "/" + params;   
    System.out.println("Get forecasts by country");
    constructUrl (path);
}

To get forecasts by multiple indicators.


public static void getForecastMultiIndicator() throws IOException
{
    //put indicators name here
    String params = "gdp,population";
    params = params.replaceAll("\\s","%20"");
    //set the path
    String path = "/forecast/indicator" + "/" + params;   
    System.out.println("Get forecasts for multiple indicators");
    constructUrl (path);
}

To get forecasts by country and indicator.


public static void getForecastCountryIndicator() throws IOException
{
    //put country name here
    String params = "united states" + "/";
    params = params.replaceAll("\\s","%20"");
    //put indicator name here
    String params1 = "gdp";
    params1 = params1.replaceAll("\\s","%20"");
    //set the path
    String path = "/forecast/country" + "/" + params + "indicator" + "/" + params1;   
    System.out.println("Get forecasts by country and indicator");
    constructUrl (path);
}

To get forecasts by country or countries.
Remember, without a client key only a sample of data will be provided.

<?php
$url = 'https://api.tradingeconomics.com/forecast/country/{put country or countries name here}';
$headers = array(
    "Accept: application/xml",
    "Authorization: Client guest:guest"
);
$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....
//showing result
echo($data);
?>



To get forecasts by indicator or indicators.


$url = 'https://api.tradingeconomics.com/forecast/indicator/{put indicator or indicators name here}';



To get forecasts by country or countries and by indicator or indicators.


$url = 'https://api.tradingeconomics.com/forecast/country/{put country or countries name here}/indicator/{put indicator or indicators name here}';


Response Fields

Category Name of the indicator
Title Combination of country and indicator name
LatestValue Last released value
LatestValueDate Date of the last released value
ForecastValue1Q * Forecast value for the next quarter
ForecastValue2Q * Forecast value for the quarter following ForecastValue1Q
ForecastValue3Q * Forecast value for the quarter following ForecastValue2Q
ForecastValue4Q * Forecast value for the quarter following ForecastValue3Q
ForecastValue1 * Forecast value for the year end
ForecastValue2 * Forecast value for the year end following ForecastValue1
ForecastValue3 * Forecast value for the year end following ForecastValue2
q1_date Date for ForecastValue1Q
q2_date Date for ForecastValue2Q
q3_date Date for ForecastValue3Q
q4_date Date for ForecastValue4Q
Frequency Frequency of the indicator
Unit Unit of the forecasted values
HistoricalDataSymbol Unique symbol used by Trading Economics


*Check python tab to see response fields representing the fields marked above.

Markets

Get market forecasts for major indexes by category.

Category can be: bond, currency, index, commodity and crypto.

te.getMarketsForecasts(category='bond', output_type='df')

Get major market forecasts by symbol

te.getMarketsForecasts(symbol='aapl:us', output_type='df')

Get major market forecasts by multiple symbols

te.getMarketsForecasts(symbol=['psi20:ind', 'indu:ind'], output_type='df')

Output:
Symbol Date ... Forecast1 Forecast2 Forecast3 0 INDU:IND 2020-01-30T18:22:00 ... 27912.478664 27912.478664 27333.878320 1 PSI20:IND 2020-01-30T00:00:00 ... 5117.214378 5117.214378 5014.337428

Market forecasts for major stock market indexes.

Category can be: index, currency, crypto, commodity and bond

getMarketsForecast(category='index', outType = 'df')
   
getMarketsForecast(category='currency', outType = 'df')
   
getMarketsForecast(category='crypto', outType = 'df')
    
getMarketsForecast(category='commodity', outType = 'df')
    
getMarketsForecast(category='bond', outType = 'df')
    

Market forecasts by symbol.

getMarketsForecast(symbol='BULGARIAGOVB10Y:GOV', outType = 'df')
   

Get major indexes by category (category can be: index, bond, commodity and currency).


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/markets/forecasts/{put category name here}?c=guest:guest");

Get major market forecasts by symbol.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/markets/forecasts/{put symbol here}?c=guest:guest");

Get major market forecasts with multiple symbols.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/markets/forecasts/{put symbols here separated by commas ','}?c=guest:guest");

This is only a small sample of the code. Check here for the complete sample code.


To get market forecasts by category.


public static void getMarketForecastCategory() throws IOException
{
    //put category here (category can be: index, bond, currency and commodity)
    String params = "index";
    params = params.replaceAll("\\s","%20"");
    //set the path
    String path = "/markets/forecasts" +  "/" + params;   
    System.out.println("Market Forecasts by category");
    constructUrl (path);
}

To get market forecasts by symbol or multiple symbols.


    public static void getMarketForecastSymbol() throws IOException
    {
        //put symbols here
        String params = "BULGARIAGOVB10Y:GOV,LITHUANIAGOVBON10Y:GOV,GBGB10YR:GOV";
        params = params.replaceAll("\\s","%20"");
        //set the path
        String path = "/markets/forecasts/symbol" +  "/" + params;   
        System.out.println("Market Forecasts by multiple symbols");
        constructUrl (path);
    }
    

To get market forecasts by category (category can be: index, bond, currency and commodity).

<?php
$url = 'https://api.tradingeconomics.com/markets/forecasts/{put category name here}';
$headers = array(
    "Accept: application/xml",
    "Authorization: Client guest:guest"
);
$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....
//showing result
echo($data);
?>

To get market forecasts for symbol or symbols.


$url = 'https://api.tradingeconomics.com/markets/forecasts/symbol/{put symbol here}';

Get markets forecasts by category.


    data = te.getMarketsForecast(category = 'index').then(function(data){
            console.log(data)     
    });

    data = te.getMarketsForecast(category = 'currency').then(function(data){
            console.log(data)     
    });

    data = te.getMarketsForecast(category = 'crypto').then(function(data){
            console.log(data)     
    });

    data = te.getMarketsForecast(category = 'commodity').then(function(data){
            console.log(data)     
    });

    data = te.getMarketsForecast(category = 'bond').then(function(data){
            console.log(data)     
    });

Get markets forecasts by symbol.


    data = te.getMarketsForecast(symbol = 'aapl:us').then(function(data){
            console.log(data)     
    });

Get markets forecasts by multiple symbols.


    data = te.getMarketsForecast(symbol = ['aapl:us', 'gac:com']).then(function(data){
            console.log(data)     
    });


Response Fields

Symbol Unique symbol used by Trading Economics
Country Country name
Date Release time and date in UTC
Type Market category can be: index, commodities, currency and bond
Last Latest released value
URL Hyperlink at Trading Economics
Importance Indicator importance from 0(lowest) to 1000(highest)
Forecast1 Forecast value for the next quarter
Forecast2 Forecast value for the next quarter following Forecast1
Forecast3 Forecast value for the next quarter following Forecast2
Forecast4 Forecast value for the next quarter following Forecast3

News

Get News

To get the latest news.

te.getNews(output_type = 'df')
te.getNews(start_date = '2021-02-02', end_date = '2021-03-03', output_type = 'df')

To get news by country or countries.

te.getNews(country = 'mexico', output_type = 'df')
te.getNews(country = 'mexico', start_date = '2021-02-02', end_date = '2021-03-03', output_type = 'df')

To get news by Indicator or indicators.

te.getNews(indicator = ['inflation rate','gdp'], output_type = 'df')
te.getNews(indicator = 'inflation rate', start_date = '2021-02-02', end_date = '2021-03-03', output_type = 'df')

To get several countries and indicators.

te.getNews(country ='mexico',indicator='inflation rate')  
te.getNews(country ='mexico',indicator='inflation rate', start_date = '2021-02-02', end_date = '2021-03-03')  

It is possible to limit the amount of news by a start index and a limited number of news to get.

te.getNews(start=10,limit=5)

To get the latest news.

getLatestNews(outType = 'df')

Filter news by date.

getLatestNews(initDate = '2020-01-01', endDate = '2020-12-31',outType = 'df')

To get the latest news by country, or countries and dates.

getLatestNews(country = 'mexico', initDate = '2020-01-01', endDate = '2020-12-31')

To get the latest news by indicator, or indicators and dates.

getLatestNews(indicator = 'gdp')
getLatestNews(indicator = 'gdp', initDate = '2020-01-01', endDate = '2020-12-31')

To get the latest news by start index and news limit.

getLatestNews(limit='2',start = '1')

Get the latest news.


    data = te.getNews().then(function(data){
        console.log(data)     
    });

Get news by country and dates.


    data = te.getNews(country = 'mexico').then(function(data){
        console.log(data)     
    });

    data = te.getNews(country = 'mexico', start_date = '2021-02-02', end_date = '2021-03-03').then(function(data){
        console.log(data)     
    });

Get news by indicator and dates.


    data = te.getNews(indicator = 'imports').then(function(data){
        console.log(data)     
    });

    data = te.getNews(indicator = 'imports', start_date = '2021-01-01', end_date = '2021-02-02').then(function(data){
        console.log(data)     
    });

Get news by country and indicator and dates.


    data = te.getNews(country = 'mexico', indicator = 'inflation rate').then(function(data){
        console.log(data)     
    });

Get news list by specifying start index and list size.


    data = te.getNews(limit = '4', start = '2').then(function(data){
        console.log(data)     
    });

To get the latest news.
Remember, without a client key only a sample of data will be provided.

<?php
$url = 'https://api.tradingeconomics.com/news';
$headers = array(
    "Accept: application/xml",
    "Authorization: Client guest:guest"
);
$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....
//showing result
echo($data);
?>

To filter news by country or countries.


$url = 'https://api.tradingeconomics.com/news/country/{put country or countries name here}';

To paginate news list by specifying start index and list size.


$url = 'https://api.tradingeconomics.com/news?limit={put limit size here}&start={put start index here}';

Without an API key only a small sample of data will be given.
You can get your test key at https://developer.tradingeconomics.com


To get lastest news.


using System;
using System.IO;
using System.Net;

namespace Examples.System.Net
{
    public class News
    {
        public static void Main()
        {
            // replace guest:guest with your key
            WebRequest request = WebRequest.Create(
                "https://api.tradingeconomics.com/news?c=guest:guest");
            WebResponse response = request.GetResponse(); 
            Console.WriteLine(((HttpWebResponse)response).StatusDescription);    

            using (Stream dataStream = response.GetResponseStream())
            { 
                StreamReader reader = new StreamReader(dataStream);
                String responseFromServer = reader.ReadToEnd();
                Console.WriteLine(responseFromServer);
            }     
            response.Close();
        }
    }        
}

Get lastest news by country, or countries.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/news/country/{put country name here}?c=guest:guest");

Get latest news by specifying start index and list size.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/news?c=guest:guest&limit={put list size number}&start={put start index here}");

This is only a small sample of the code. Check here for the complete sample code.


To get the latest news.


public static void getNews() throws IOException
{
    //set the path
    String path = "/news";   
    System.out.println("Get the latest news");
    constructUrl (path);
}

To get news by start index and limit size list.


public static void getNewsByPage() throws IOException
{
    //put limit list size here
    String limit = "15";
    //put start index here
    String start = "10";
    //set the path
    String path = "/news" + "?limit=" + limit + "&start=" + start;   
    System.out.println("Get news by start index and limit size list");
    constructUrl (path);
}

News are short summaries, usually three to five sentences covering a specific release/event related to the data, providing an explanation of what was behind growth/contraction, increase/decrease in the specific dataseries.



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 Trading Economics
Url Hyperlink at Trading Economics
Importance Lowest 0 to 3 highest

Streaming

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.

Economic Calendar






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('calendar')
    te.run(on_message)
    





This is the returned output:


{ 'event' : 'Industrial Production YoY', 'country' : 'Euro Area', 'ticker' : 'EUIPEMUY', 'actual' : '-4.1%', 
    'previous' : '-1.5%', 'revised' : None, 'date' : '2020-02-12T10:00:00', 'referenceDate' : '2019-12-31T00:00:00', 
    'reference' : 'Dec', 'calendarId' : '234510', 'importance' : '2', 'teforecast' : '-2%', 'forecast' : '-1.6%', 
    'symbol' : 'EUROAREAINDPROMOM', 'source' : None, 'topic' : 'calendar' }

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

git clone https://github.com/tradingeconomics/tradingeconomics
    

Step 2

cd tradingeconomics/nodejs/Examples/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: 'wss://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.

Only a single market topic "EURUSD:CUR" can be subscribed using guest:guest. See market streaming


For other markets or calendar topic "key:secret" is required.

  
try 
{
    using (var cws = new ClientWebSocket())
    {    
        await cws.ConnectAsync(new Uri($"wss://stream.tradingeconomics.com/?client={_clientKey}"), CancellationToken.None);
        
        if (cws.State == WebSocketState.Open)
        {
            var buffer = new ArraySegment< byte >(Encoding.UTF8.GetBytes(@"{""topic"": ""subscribe"", ""to"": """ + subscribeTo + @""" }"));
            await result = await cws.SendAsync(buffer, WebSocketMessageType.Binary, true, CancellationToken.None);
        }
        await Task.Delay(1024);
        while (cws.State== WebSocketState.Open)
        {
            var buffer = new ArraySegment< byte >(new byte[1024]);
            var result = await cws.ReceiveAsync(buffer, CancellationToken.None);   
            if (result.MessageType == WebSocketMessageType.Close)
            {
                await cws.CloseAsync(WebSocketCloseStatus.NormalClosure, string.Empty,  CancellationToken.None);
            }
            Console.WriteLine($"Receiving: {Encoding.UTF8.GetString(buffer.Array, 0, result.Count).Trim()}");
        }
    }
}
catch (Exception e)
}
    Console.WriteLine($"Error with message: {e.Message}");
}          
    
    

Check here for the complete sample code.

Two Libraries are require to run this example
- javax.websocket-client-api.1.1.jar
- tyrus-standalone-client-1.9.jar

public class Streaming { 
        public static void main(String[] args) {
            try {
                final WebsocketClient client =  new WebsocketClient(new URI("wss://stream.tradingeconomics.com/?client=guest:guest"));
                client.addMessageHandler(new WebsocketClient.MessageHandler() {
                    public void handleMessage(String message) {
                        System.out.println("Receiving: " + message);
                    }
                });
                Scanner scan =new Scanner(System.in);
                //It will ask you to subscribe to the topic on the terminal.
                System.out.println("Enter topic for subscription: ");
                while(scan.hasNext)) {
                    //input on the terminal will be "calendar"
                    String to =  scan.nextLine();
                    String subs =  "{\"topic\": \"subscribe\", \"to\": \"" + to + "\" }";
                    client.sendMessage(subs);
                }
                Thread.sleep(30000);
            } catch (InterruptedException ex) {   
                System.out.println("InterruptedException exception: " + ex.getMessage());
            } catch (URISyntaxException ex) { 
                System.err.println("URISyntaxException exception: " + ex.getMessage());
            }
        }    
    }
    

Without a client Key, only "EURUSD:CUR" market symbol will give you data. See market streaming


For a detailed list of available live data please contact us


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
ticker Unique ticker used by Trading Economics
reference The period for which released data refers to
referenceDate The date 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 after revision
symbol Unique symbol used by Trading Economics
calendarId Unique calendar ID used by Trading Economics
forecast Average forecast among a representative group of economists
teforecast TE own projections
importance 1 = low, 2 = medium, 3 = high

Markets

Copy this code and execute

Subscribe to one symbol

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)

Subscribe to multiple symbols


te.subscribe( ['EURUSD:CUR', 'AAPL:US', 'CL1:COM'] )
te.run(on_message)

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

git clone https://github.com/tradingeconomics/tradingeconomics

Step 2

cd tradingeconomics/nodejs/Examples/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: 'wss://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.

Only a single market topic "EURUSD:CUR" can be subscribed using guest:guest.
For other markets topic "key:secret" is required.

   
try 
{
    using (var cws = new ClientWebSocket())
    {    
        await cws.ConnectAsync(new Uri($"wss://stream.tradingeconomics.com/?client={_clientKey}"), CancellationToken.None);
        
        if (cws.State == WebSocketState.Open)
        {
            var buffer = new ArraySegment< byte >(Encoding.UTF8.GetBytes(@"{""topic"": ""subscribe"", ""to"": """ + subscribeTo + @""" }"));
            await result = await cws.SendAsync(buffer, WebSocketMessageType.Binary, true, CancellationToken.None);
        }
        await Task.Delay(1024);
        while (cws.State== WebSocketState.Open)
        {
            var buffer = new ArraySegment< byte >(new byte[1024]);
            var result = await cws.ReceiveAsync(buffer, CancellationToken.None);   
            if (result.MessageType == WebSocketMessageType.Close)
            {
                await cws.CloseAsync(WebSocketCloseStatus.NormalClosure, string.Empty,  CancellationToken.None);
            }
            Console.WriteLine($"Receiving: {Encoding.UTF8.GetString(buffer.Array, 0, result.Count).Trim()}");
        }
    }
}
catch (Exception e)
}
    Console.WriteLine($"Error with message: {e.Message}");
} 

Check here for the complete sample code.

Two Libraries are require to run this example
- javax.websocket-client-api.1.1.jar
- tyrus-standalone-client-1.9.jar

public class Streaming { 
    public static void main(String[] args) {
        try {
            final WebsocketClient client =  new WebsocketClient(new URI("wss://stream.tradingeconomics.com/?client=guest:guest"));
            client.addMessageHandler(new WebsocketClient.MessageHandler() {
                public void handleMessage(String message) {
                    System.out.println("Receiving: " + message);
                }
            });
            Scanner scan =new Scanner(System.in);
            //It will ask you to subscribe to the topic on the terminal.
            System.out.println("Enter topic for subscription: ");
            while(scan.hasNext)) {
                //input on the terminal will be a market symbol e.g.:"EURUSD:CUR"
                String to =  scan.nextLine();
                String subs =  "{\"topic\": \"subscribe\", \"to\": \"" + to + "\" }";
                client.sendMessage(subs);
            }
            Thread.sleep(30000);
        } catch (InterruptedException ex) {   
            System.out.println("InterruptedException exception: " + ex.getMessage());
        } catch (URISyntaxException ex) { 
            System.err.println("URISyntaxException exception: " + ex.getMessage());
        }
    }    
}

The Trading Economics streaming service uses WebSocket's to push live and delayed market data into our clients.


Response fields for the markets subscription:

s Symbol
price Latest market price
dt Timestamp of last market price (epoch)
state Market state (open/close)
type Type of market (currency/indexes/commodity)
prev Previous value
dhigh Daily high
dlow Daily low
pch Percentage change
nch Net change

Here you can see a list of available live data, or you can contact us

News

Copy this code and execute

Subscribe to one symbol

import tradingeconomics as te
import json

te.login('guest:guest')

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

te.subscribe('news')
te.run(on_message)





This is the returned output:


{ 'title' : 'Latvia Producer Inflation Hits Fresh Record', 'description' : 'Producer prices in Latvia climbed to an all-time high of 25.1 percent year-on-year 
in December of 2021 from 23.4 percent in the previous month, driven by prices of domestically sold goods (31.4 percent vs 26.7 percent in November).
On the other hand, charges for Latvian exports went up at a slower rate (19.6 percent vs 20.5 percent). Across different industries,
prices of utilities jumped (62.9 percent vs 49.8 percent) and those of mining and quarrying rose slightly (13.8 percent vs 13.1 percent). 
Meanwhile, inflation slowed for manufacturing (18.7 percent vs 19 percent); and water supply, sewerage, and waste management (18.5 percent vs 18.7 percent). 
On a monthly basis, producer prices surged 1.6 percent, accelerating from a 1.2 percent rise in November.'
'country' : 'Latvia', 'category' : 'Producer Prices Change', 'url' : '/latvia/producer-prices-change', 'topic' : stream  } 

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

git clone https://github.com/tradingeconomics/tradingeconomics

Step 2

cd tradingeconomics/nodejs/Examples/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: 'wss://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.

Only a single news topic "news" can be subscribed using guest:guest.
For other markets topic "key:secret" is required.

   
try 
{
    using (var cws = new ClientWebSocket())
    {    
        await cws.ConnectAsync(new Uri($"wss://stream.tradingeconomics.com/?client={_clientKey}"), CancellationToken.None);
        
        if (cws.State == WebSocketState.Open)
        {
            var buffer = new ArraySegment< byte >(Encoding.UTF8.GetBytes(@"{""topic"": ""subscribe"", ""to"": """ + subscribeTo + @""" }"));
            await result = await cws.SendAsync(buffer, WebSocketMessageType.Binary, true, CancellationToken.None);
        }
        await Task.Delay(1024);
        while (cws.State== WebSocketState.Open)
        {
            var buffer = new ArraySegment< byte >(new byte[1024]);
            var result = await cws.ReceiveAsync(buffer, CancellationToken.None);   
            if (result.MessageType == WebSocketMessageType.Close)
            {
                await cws.CloseAsync(WebSocketCloseStatus.NormalClosure, string.Empty,  CancellationToken.None);
            }
            Console.WriteLine($"Receiving: {Encoding.UTF8.GetString(buffer.Array, 0, result.Count).Trim()}");
        }
    }
}
catch (Exception e)
}
    Console.WriteLine($"Error with message: {e.Message}");
} 

Check here for the complete sample code.

Two Libraries are require to run this example
- javax.websocket-client-api.1.1.jar
- tyrus-standalone-client-1.9.jar

public class Streaming { 
    public static void main(String[] args) {
        try {
            final WebsocketClient client =  new WebsocketClient(new URI("wss://stream.tradingeconomics.com/?client=guest:guest"));
            client.addMessageHandler(new WebsocketClient.MessageHandler() {
                public void handleMessage(String message) {
                    System.out.println("Receiving: " + message);
                }
            });
            Scanner scan =new Scanner(System.in);
            //It will ask you to subscribe to the topic on the terminal.
            System.out.println("Enter topic for subscription: ");
            while(scan.hasNext)) {
                ////input on the terminal will be "news"
                String to =  scan.nextLine();
                String subs =  "{\"topic\": \"subscribe\", \"to\": \"" + to + "\" }";
                client.sendMessage(subs);
            }
            Thread.sleep(30000);
        } catch (InterruptedException ex) {   
            System.out.println("InterruptedException exception: " + ex.getMessage());
        } catch (URISyntaxException ex) { 
            System.err.println("URISyntaxException exception: " + ex.getMessage());
        }
    }    
}

The streaming service uses websockets (WebSockets provide a bidirectional, full-duplex communications channel that operates over HTTP through a single TCP/IP socket connection). At its core, the WebSocket protocol facilitates message passing between a client and server. You can connect to our streaming service using the examples listed on the black pane. You need to subscribe to one or more instruments.


Response fields for the News subscription:

title Title
description description
country country
category category
url url
importance Lowest 0 to 3 highest
topic topic

Here you can see a list of available live data, or you can contact us

Search

You can search for keyword, term, or by category. If you do not know which category to look for, just use the search/{term} endpoint option.

To get a list of categories available, search by term/keyword and category.

te.getSearch(output_type = 'df')
te.getSearch(term  = 'japan', category = 'markets', output_type = 'df')
te.getSearch(term  = 'gold', output_type = 'df')

Search for available categories, term and category.


    data = te.getSearch().then(function(data){
        console.log(data)     
    });

    data = te.getSearch(term = 'gold').then(function(data){
        console.log(data)     
    });

    data = te.getSearch(term = 'japan', category = 'markets').then(function(data){
        console.log(data)     
    });

Search for available categories, term and category.

getSearch()
getSearch(search_term = 'Japan', category = 'markets')
getSearch(search_term = 'gold')

Eurostat

The Eurostat database contains more than 46,000 time series divided into 2500 categories for Euro Area, European Union and its 27 member states. Eurostat is a Directorate-General of the European Commission located in Luxembourg. Its main responsibilities are to provide statistical information to the institutions of the European Union (EU) and to promote the harmonisation of statistical methods across its member states and candidates for accession as well as EFTA countries.

Snapshot


To get lists of countries available.

te.getEurostatData(lists = 'countries', output_type = 'df')
   

To get lists of categories available.

te.getEurostatData(lists = 'categories', output_type = 'df')      
   

To get categories list.

getEurostatData(lists = 'categories')

To get Eurostat data by category group.

getEurostatData(category_group = 'Poverty')

To get Eurostat data by category.

getEurostatData(category = 'People at risk of income poverty after social transfers')

To get Eurostat data by country.

getEurostatData(country = 'Denmark')

To get Eurostat data by country and category.

getEurostatData(country = 'Denmark', category = 'People at risk of income poverty after social transfers')

To get Eurostat data by country and category group.

getEurostatData(country = 'Denmark', category_group = 'Poverty')

Get Eurostat available countries.


   data = te.getEurostatData(lists = 'countries').then(function(data){
       console.log(data)     
   });

Get Eurostat available categories.


   data = te.getEurostatData(lists = 'categories').then(function(data){
       console.log(data)     
   });

Get Eurostat data by category group.

te.getEurostatData(category_group = 'Poverty', output_type = 'df')
   

Get Eurostat data by specific category.

te.getEurostatData(category = 'People at risk of income poverty after social transfers', output_type = 'df')      
   

Get Eurostat data by country.

te.getEurostatData(country = 'Denmark', output_type = 'df')
   

Get Eurostat data by country and category.

te.getEurostatData(country = 'Denmark', category = 'People at risk of income poverty after social transfers', output_type = 'df')      
   

Get Eurostat data by country and category group.

te.getEurostatData(country = 'Denmark', category_group = 'Poverty', output_type = 'df')      
   

Get Eurostat data by country.


   data = te.getEurostatData(country = 'Denmark').then(function(data){
       console.log(data)     
   });

Get Eurostat data by category.


   data = te.getEurostatData(category = 'People at risk of income poverty after social transfers').then(function(data){
       console.log(data)     
   });

Get Eurostat data by category group.


   data = te.getEurostatData(category_group = 'Poverty').then(function(data){
       console.log(data)     
   });

Get Eurostat data by country and category.


   data = te.getEurostatData(country = 'Denmark', category = 'People at risk of income poverty after social transfers').then(function(data){
       console.log(data)     
   });

Get Eurostat data by country and category group.


   data = te.getEurostatData(country = 'Denmark', category_group = 'Poverty').then(function(data){
       console.log(data)     
   });


Historical


Get historical Eurostat data by ID.

te.getHistoricalEurostat(ID = '24804', output_type = 'df')
    

Get historical Eurostat data by ID and a start date.

te.getHistoricalEurostat(ID = '24804', initDate = '2015-01-01', output_type = 'df')
    

Get historical Eurostat data by ID and a date range.

te.getHistoricalEurostat(ID = '24804', initDate = '2015-01-01', endDate = '2020-01-01', output_type = 'df')
    

Get historical data by ID.


    data = te.getEurostatHistorical(id = '24804').then(function(data){
        console.log(data)     
    });
 

Get historical data by ID and a start date.


    data = te.getEurostatHistorical(id = '24804', start_date = '2017-01-01').then(function(data){
        console.log(data)     
    });
 

Get historical data by ID between a date range.


    data = te.getEurostatHistorical(id = '24804', start_date = '2017-01-01', end_date = '2020-05-05').then(function(data){
        console.log(data)     
    });
 

To get historical Eurostat data by ID.

getEurostatHistorical(id = '24804')
 

To get historical Eurostat data by ID and a start date.

getEurostatHistorical(id = '24804', start_date = '2018-01-01' )
 

To get historical Eurostat data by ID and dates.

getEurostatHistorical(id = '24804', start_date = '2018-01-01', end_date = '2021-05-10')
 

Response Fields

ID Trading Economics unique identifier
Country Country name
Category Category name
Category Group Category Group name
URL Hyperlink at Trading Economics
Frequency Frequency of the indicator
Unit Unit of the value
LatestValue Latest value
LatestValueDate Latest value date
PreviousValue Previous value
PreviousValueDate Previous value date
FirstValue First historical value
FirstValueDate First historical value date
HighestValue Highest value
HighestValueDate Highest value date
LowestValue Lowest value
LowestValueDate Lowest value date
LastUpdate Time when new data was inserted or changed
Date Release time and date in UTC
Value Value

World Bank

Snapshot


With no category specified, a list of categories will be provided.

te.getWBCategories(category = None)

             category                                          
0         Agriculture                     
1   Aid Effectiveness     
2        Demographics
...      

To get World Bank data by category.

te.getWBCategories(category = 'Demographics')

To get World Bank data for all countries and one indicator.

te.getWBIndicator(series_code = 'fr.inr.rinr', output_type='df)
    

To get World Bank main categories.

getWorldBankCategories(outType = 'df')

Output:
               category   
2           Agriculture
21    Aid Effectiveness
3          Demographics    

To get World Bank data by specific category.

getWorldBankCategories(category = 'education')

Output:      
       category                                                             title                          lastupdate    
2     Education        Literacy rate, youth total (% of people ages 15-24) UNESCO             2017-10-16T08:40:06.803    
21    Education           School enrolment, preprimary, national source (% gross)             2017-10-16T08:40:17.397    
3     Education             Gross intake ratio in grade 1, total, national source             2017-10-16T08:40:17.053    

Get World Bank categories.


    data = te.getWorldBank().then(function(data){
        console.log(data)     
    });

Get World Bank data by a specific category.


    data = te.getWorldBank(category = 'education').then(function(data){
        console.log(data)     
    });

To get World Bank categories.

<?php
$url = 'https://api.tradingeconomics.com/worldBank/categories';
$headers = array(
    "Accept: application/xml",
    "Authorization: Client guest:guest"
);
$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....
//showing result
echo($data);
?>

To get world bank data by category.


$url = 'https://api.tradingeconomics.com/worldBank/category/{put category name here}';

Without an API key only a small sample of data will be given.
You can get your test key at https://developer.tradingeconomics.com


To get world bank categories.


using System;
using System.IO;
using System.Net;

namespace Examples.System.Net
{
    public class WorldBank
    {
        public static void Main()
        {
            // replace guest:guest with your key
            WebRequest request = WebRequest.Create(
                "https://api.tradingeconomics.com/worldBank/categories?c=guest:guest");
            WebResponse response = request.GetResponse(); 
            Console.WriteLine(((HttpWebResponse)response).StatusDescription);    

            using (Stream dataStream = response.GetResponseStream())
            { 
                StreamReader reader = new StreamReader(dataStream);
                String responseFromServer = reader.ReadToEnd();
                Console.WriteLine(responseFromServer);
            }     
            response.Close();
        }
    }        
}

Filtering by category.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/worldBank/category/{put category name here}?c=guest:guest");

This is only a small sample of the code. Check here for the complete sample code.


To get world bank main categories.


public static void getWBCategories() throws IOException
{
    //set the path
    String path = "/worldBank/categories";   
    System.out.println("Get main categories");
    constructUrl (path);
}

Get world bank data by category.


public static void getWBByCategory() throws IOException
{
    //put category  name here
    String params = "Education";
    params = params.replaceAll("\\s","%20"");
    //set the path
    String path = "/worldBank/category" + "/" + params;   
    System.out.println("Get world bank data by category");
    constructUrl (path);
}

To get World Bank data by indicator (series_code).

te.getWBIndicator(series_code = 'usa.fr.inr.rinr')
    
                     symbol        last    previous     ...                 title                                URL                 lastUpdate                          
    0       usa.fr.inr.rinr      2.2077     2.15223     ...    Real interest rate    /united-states/real-interest...    2018-04-27T13:49:37.133             
    

To get World Bank data by URL.

te.getWBIndicator(url = '/united-states/real-interest-rate-percent-wb-data.html')
    
                     symbol    last    previous    ...                 title                                                   URL                 lastUpdate                          
    0       usa.fr.inr.rinr  2.2077     2.15223    ...    Real interest rate     /united-states/real-interest-rate-percent-wb-d...    2018-04-27T13:49:37.133             
    

To get World Bank data by country.

te.getWBCountry(country = 'Portugal')
    
                        symbol             last      ...                                                      URL                 lastUpdate                          
    0       prt.bx.svf.totl.cd     1.555543e+09      ...        /portugal/factor-service-receipts-us$-bop-wb-d...    2018-06-10T10:02:51.023 
    0       prt.bx.svn.totl.cd     5.327495e+09      ...        /portugal/non-factor-services-receipts-us$-bop...    2018-06-10T10:02:51.023
    0       prt.bx.trf.curr.cd     6.370007e+09      ...        /portugal/current-transfers-receipts-bop-us-do...    2018-05-12T07:15:10.083            
    ...
    

To get World Bank data for all countries by specific indicator.

getWorldBankIndicators(series_code = 'fr.inr.rinr')
    
        Output:
                         symbol       country                                                                   URL    
    2           abw.fr.inr.rinr         Aruba                        /aruba/real-interest-rate-percent-wb-data.html    
    210         afg.fr.inr.rinr   Afghanistan                  /afghanistan/real-interest-rate-percent-wb-data.html    
    3           ago.fr.inr.rinr        Angola                       /angola/real-interest-rate-percent-wb-data.html    
    
    

To get World Bank data by country.

getWorldBankIndicators(category = 'country', identifier = 'Portugal')
    
    Output:      
           country                       symbol          last    
    2     Portugal        prt.bar.sec.schl.25up          2.16    
    21    Portugal     prt.bar.sec.schl.25up.fe          2.19    
    3     Portugal        prt.bar.sec.schl.3034          3.59    
    
    

To get World Bank data by URL.

getWorldBankIndicators(URL = '/united-states/real-interest-rate-percent-wb-data.html')
    
    Output:
                         symbol               country                                                               URL    
    1           usa.fr.inr.rinr         United States            /united-states/real-interest-rate-percent-wb-data.html    
    
    

Get World Bank data by series code.


        data = te.getWorldBank(series_code = 'fr.inr.rinr').then(function(data){
            console.log(data)     
        });
    

Get World Bank data by country.


        data = te.getWorldBank(country = 'united states').then(function(data){
            console.log(data)     
        });
    

Get World Bank data by url.


        data = te.getWorldBank(URL = '/united-states/real-interest-rate-percent-wb-data.html').then(function(data){
            console.log(data)     
        });
    

To get world bank data by series code.

<?php
    $url = 'https://api.tradingeconomics.com/worldBank/indicator?s={put series_code here}';
$headers = array(
    "Accept: application/xml",
    "Authorization: Client guest:guest"
);
$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....
//showing result
echo($data);
?>

To get a list of indicators available for a specific country.


$url = 'https://api.tradingeconomics.com/worldBank/country/{put country name here}';

To get world bank data by url.


$url = 'https://api.tradingeconomics.com/worldBank/indicator?url={put url path here}';


To get world bank information by indicators series code.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/worldBank/indicator?c=guest:guest&s={put series_code here}");


Filtering by url.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/worldBank/indicator?c=guest:guest&url={put url here}");


Filtering by the country.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/worldBank/country/{put country name here}?c=guest:guest");

Get world bank data by specific indicator.


public static void getWBIndicator() throws IOException
{
    //put series code here
    String series_code = "fr.inr.rinr";
    params = params.replaceAll("\\s","%20"");
    //set the path
    String path = "/worldBank/indicator" + "?s=" + series_code;   
    System.out.println("Get world bank data by specific indicator");
    constructUrl (path);
}

Get world bank data by specific country.


public static void getWBCountryPage() throws IOException
{
    //put country  name here
    String params = "portugal";
    params = params.replaceAll("\\s","%20"");
    //set the path
    String path = "/worldBank/country" + "/" + params;   
    System.out.println("Get world bank data by specific country");
    constructUrl (path);
}

Get world bank data by specific url.


public static void getWBByUrl() throws IOException
{
    //put category  name here
    String url = "/united-states/real-interest-rate-percent-wb-data.html";
    url = url.replaceAll("\\s","%20"");
    //set the path
    String path = "/worldBank/indicator" + "?url=" + url;   
    System.out.println("Get world bank data by specific url");
    constructUrl (path);
}

The World Bank Database is a collection of around 300,000 development indicators, compiled from officially-recognized international sources. It presents the most current and accurate global development data available.

Indicators and Countries


Historical


To get World Bank historical data for a symbol.

te.getWBHistorical(series_code = 'usa.fr.inr.rinr')
    

To get World Bank historical data for multiple symbols.

te.getWBHistorical(series_code = 'usa.fr.inr.rinr, prt.ag.con.fert.pt.zs')
    

To get World Bank historical data for a symbol.

getWorldBankHistorical('usa.fr.inr.rinr')
    
    

To get World Bank historical data for multiple symbols.

getWorldBankHistorical('usa.fr.inr.rinr, prt.ag.con.fert.pt.zs)
    
    

To get World Bank historical data for a specific or multiple symbols.


    $url = 'https://api.tradingeconomics.com/worldBank/historical?s={put symbol here}';
    

To get World Bank historical data for a specific or multiple symbols.


        // replace guest:guest with your key
        WebRequest request = WebRequest.Create(
        "https://api.tradingeconomics.com/worldBank/historical?c=guest:guest&s={put symbol here}");
    

To get World Bank historical data for a specific or multiple symbols.


    public static void getWBHistorical() throws IOException
    {
        //put series code here
        String series_code = "usa.fr.inr.rinr";
        params = params.replaceAll("\\s","%20"");
        //set the path
        String path = "/worldBank/historical" + "?s=" + symbol;   
        System.out.println("Get world bank historical data by specific series code");
        constructUrl (path);
    }
    

To get World Bank historical data for a symbol.


        data = te.getWorldBankHistorical(series_code = 'usa.fr.inr.rinr').then(function(data){
            console.log(data)     
        });
    

To get World Bank historical data for multiple symbols.


        data = te.getWorldBankHistorical(series_code = 'usa.fr.inr.rinr, prt.ag.con.fert.pt.zs').then(function(data){
            console.log(data)     
        });
    


Response Fields

Symbol Unique symbol used by Trading Economics
Last Latest released value
Date Release time and date in UTC
Value Released value
Previous Value for the previous period after the revision (if revision is applicable)
PreviousDate Release time and date in UTC of the previous value
Category Category name
series_code WB symbol for the series
series_name WB Name for the series
sub_category WB Sub category name
sub_category2 WB Sub category name
sub_category3 WB Sub category name
Title WB Series title
long_definition WB Series long definition
short_definition WB Series short definition
Source Data source
general_comments WB general comments
aggregation_method WB aggregation method
URL Hyperlink at Trading Economics
Organization WB Organization
Description Description
Frequency Frequency of the indicator
Unit Unit
verbose_unit WB Verbose Unit
last_update Time when new data was inserted or changed

Comtrade

Snapshot


To get Comtrade categories.

te.getCmtCategories(category = None)

        id   ...                                 pretty_name           
0       01   ...                                Live animals
1     0101   ...      Horses, asses, mules and hinnies, live
2     0102   ...                        Bovine animals, live        
...

To get Comtrade categories.

getComtradeCategories( outType = 'df')

    Output:
     parent_id                                 pretty_name          
2           a1                                Live animals    
210         01      Horses, asses, mules and hinnies, live    
3           01                        Bovine animals, live    

Get Comtrade categories.


    data = te.getComtrade(category = 'categories').then(function(data){
        console.log(data)     
    });

    data = te.getComtrade(category = 'updates').then(function(data){
        console.log(data)     
    });

Get total Imports by country for all main categories.


    data = te.getComtradeTotalByType(country = 'Portugal', type = 'import').then(function(data){
        console.log(data)     
    });

Get total Exports by country for all main categories.


    data = te.getComtradeTotalByType(country = 'United States', type = 'export').then(function(data){
    console.log(data)      
    });

Get Imports/Exports by specific category.


    data = te.getCmtCountryByCategory(country = 'United States', type = 'export', category = 'live animals').then(function(data){
    console.log(data)      
    });

To get Comtrade categories.

<?php
$url = 'https://api.tradingeconomics.com/comtrade/categories';
$headers = array(
    "Accept: application/xml",
    "Authorization: Client guest:guest"
);
$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....
//showing result
echo($data);
?>

To get comtrade categories.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/comtrade/categories?c=guest:guest");

This is only a small sample of the code. Check here for the complete sample code.


Get detailed information about comtrade main categories.


public static void getComtradeCategories() throws IOException
{
    //set the path
    String path = "/comtrade/categories";   
    System.out.println("Get detailed information about comtrade main categories");
    constructUrl (path);
}

Get the latest updated indicators

te.getCmtUpdates(output_type = 'df')

Get total Imports by country for all main categories.

te.getCmtTotalByTypeAndMainCategory(country = 'India', type='import',output_type = 'df')

Get total Exports by country for all main categories.

te.getCmtTotalByTypeAndMainCategory(country = 'United States', type='export',output_type = 'df')

Get total Imports by specific category.

te.getCmtTotalByTypeAndMainCategory(country = 'United kingdom', type='import',category='Coffee, tea, mate and spices',output_type = 'df')
te.getCmtTotalByTypeAndMainCategory(country = 'India', type='import',category='Live animals',output_type = 'df')

To get detailed information about Comtrade countries.

te.getCmtCountry(output_type = 'df')

To get detailed information for one country.

te.getCmtCountry(country = 'China')

           symbol   ...                                                  title           
0     CHN473XX011   ...           China Imports from LAIA, nes of Live animals
1     CHN473XX022   ...      China Exports to LAIA, nes of Meat and edible ...
2     CHN473XX032   ...      China Exports to LAIA, nes of Fish, crustacean...        
...

To get detailed information for multiple countries.

te.getCmtCountry(country =['China','Portugal'])

          symbol   ...                                                   title           
0     CHN473XX011   ...            China Imports from LAIA, nes of Live animals
1     CHN473XX022   ...       China Exports to LAIA, nes of Meat and edible ...
24    CHNPRT41082   ...       China Exports to Portugal of Chamois (includin...
25    CHNPRT41091   ...       China Imports from Portugal of Patent and pate...        
...

To get Snapshot of data per country filtered by type: import or export.

te.getCmtSnapshotByType(country ='Portugal',type='export',output_type='df')

To get Snapshot of trade between two countries filtered by type: import or export.

te.getCmtCountryFilterByType(country1 ='portugal',country2 ='spain',type='import',output_type='df')

To get Comtrade between two countries.

te.getCmtTwoCountries(country1 ='portugal',country2 ='spain')

Get detailed information about Comtrade countries.

getComtradeCountry( outType = 'df')

    Output:
            id               name        region   
2            0              World         World
291         10         Antarctica    Antarctica
3          100           Bulgaria        Europe

Get a snapshot of data per country.

getComtradeCountry('Portugal')

    Output:
                 symbol         country1          type   
2           PRT49001061         Portugal        Import
291         PRT49003022         Portugal        Export
3           PRT49003032         Portugal        Export

Get a snapshot of data between countries.

getComtradeCountry(c('Portugal', 'Spain'))

    Output:
                 symbol         country1   country2      type   
2           PRTESP35032         Portugal      Spain    Export
291         PRTESP35041         Portugal      Spain    Import
3           PRTESP35042         Portugal      Spain    Export

Get detailed information about Comtrade countries.


    data = te.getComtrade(category = 'countries').then(function(data){
        console.log(data)     
    });

Get a snapshot of data per country and type.


    data = te.getComtrade(country = 'china').then(function(data){
        console.log(data)     
    });

    data = te.getCmtCountryFilterByType(country1 = 'united states', type = 'export').then(function(data){
        console.log(data)     
    });

Get a snapshot of trade between two countries and type.


    data = te.getComtrade(country = 'united states', country1 = 'china').then(function(data){
        console.log(data)     
    });

    data = te.getCmtCountryFilterByType(country = 'portugal', country1 = 'spain', type = 'import').then(function(data){
        console.log(data)     
    });

To get detailed information about comtrade countries.


$url = 'https://api.tradingeconomics.com/comtrade/countries';

To get comtrade data by country.


$url = 'https://api.tradingeconomics.com/comtrade/country/{put country name here}';

To get comtrade data between two countries.


$url = 'https://api.tradingeconomics.com/comtrade/country/{put country1 name here}/{put country2 name here}';

Get comtrade countries .


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/comtrade/countries?c=guest:guest");

Filtering by the country.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/comtrade/country/{put country name here}?c=guest:guest");

Get comtrade between two countries.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/comtrade/country/{put country1 name here}/{put country2 name here}?c=guest:guest");

Get detailed information about comtrade countries.


public static void getComtradeCountries() throws IOException
{
    //set the path
    String path = "/comtrade/countries";   
    System.out.println("Get detailed information about comtrade countries");
    constructUrl (path);
}

Get comtrade data between countries.


public static void getComtradeBetweenTwoCountries() throws IOException
{
    //put country1  name here
    String params = "portugal";
    params = params.replaceAll("\\s","%20"");
    //put country2  name here
    String params1 = "spain";
    params1 = params1.replaceAll("\\s","%20"");
    //set the path
    String path = "/comtrade/country" + "/" + params + "/" + params1;   
    System.out.println("Get comtrade data between countries");
    constructUrl (path);
}

UN Comtrade Database consists of around 19 million data series with detailed harmonized global trade data divided into categories and countries.

Historical


To get Comtrade historical data for a symbol.

te.getCmtHistorical(symbol = 'PRTESP24031')
    
                 symbol                      date      value           
    0       PRTESP24031       2021-12-31T00:00:00    91268.0
    1       PRTESP24031       2020-12-31T00:00:00    80070.0
    2       PRTESP24031       2019-12-31T00:00:00  3479548.0          
    ...
    

To get Comtrade historical data for multiple symbols.

te.getCmtHistorical(symbol = 'PRTESP24031, NORZWEXX991')
    
                 symbol                      date      value           
    0       PRTESP24031       2021-12-31T00:00:00    91268.0
    1       PRTESP24031       2020-12-31T00:00:00    80070.0
    2       PRTESP24031       2019-12-31T00:00:00  3479548.0        
    ...
    22      NORZWEXX991       2003-12-31T00:00:00      627.0
    23      NORZWEXX991       2001-12-31T00:00:00     3039.0
    24      NORZWEXX991       1995-12-31T00:00:00     3161.0        
    

To get Comtrade historical data for a symbol.

getComtradeHistorical('PRTESP24031')
    
    

To get Comtrade historical data for multiple symbols.

getComtradeHistorical('PRTESP24031, NORZWEXX991')
    
    

To get Comtrade historical data for a symbol.


        data = te.getComtrade(symbol = 'PRTESP24031').then(function(data){
            console.log(data)     
        });
    

To get Comtrade historical data for multiple symbols.


        data = te.getComtrade(symbol = 'PRTESP24031, NORZWEXX991').then(function(data){
            console.log(data)     
        });
    

To get Comtrade historical data for a specific or multiple symbols.


    $url = 'https://api.tradingeconomics.com/comtrade/historical/{put symbol name here}';
    

To get Comtrade historical data for a specific or multiple symbols.


        // replace guest:guest with your key
        WebRequest request = WebRequest.Create(
        "https://api.tradingeconomics.com/comtrade/historical/{put symbol name here}?c=guest:guest");
    

To get Comtrade historical data for a specific or multiple symbols.


    public static void getComtradeHistorical() throws IOException
    {
        //put symbol  name here
        String params = "PRTESP24031";
        params = params.replaceAll("\\s","%20"");
        //set the path
        String path = "/comtrade/historical" + "/" + params;   
        System.out.println("Get comtrade historical data by symbol");
        constructUrl (path);
    }
    

Response Fields

Id Comtrade identifier
Name Category name
ParentId Comtrade identifier
Pretty_Name Category pretty name
Symbol Unique symbol used by Trading Economics
Country1 First country name
Country2 Second country name
Type Trade type
Value Value
Date Year of the updated series
Category Category name
URL Hyperlink at Trading Economics
Title Title
StartDate Start Year of the data series
Region Region
Subregion Subregion
ISO Three letter country code
Year Last update

*Country2 is not used for total imports/exports by country.

Federal Reserve

Snapshot

To get Federal Reserve states and counties.

With no county specified, a list of all states will be provided.

te.getFedRStates(output_type = 'df')
    
    
te.getFedRStates(county = 'arkansas')

Get a list of all US states.

getFedReserve(category = 'states')

    Output:
            name                         
8        Alabama         
9         Alaska         
10       Arizona         

Get a list of all US states.


    data = te.getFred().then(function(data){
        console.log(data)     
    });

Get a list of all counties per state.


    data = te.getFred(counties = 'arkansas').then(function(data){
        console.log(data)     
    });

To get a list of all US states.

<?php
$url = 'https://api.tradingeconomics.com/fred/states';
$headers = array(
    "Accept: application/xml",
    "Authorization: Client guest:guest"
);
$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....
//showing result
echo($data);
?>

To get fred states.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/fred/states?c=guest:guest");

To get fred counties per state.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/fred/counties/{put county name here}?c=guest:guest");

This is only a small sample of the code. Check here for the complete sample code.


Get a list of all states.


public static void getFredStates() throws IOException
{
    //set the path
    String path = "/fred/states";   
    System.out.println("Get a list of all states");
    constructUrl (path);
}

To get Federal Reserve snapshots by symbol.

te.getFedRSnaps(symbol = 'ALLMARGATTN')
    

To get Federal Reserve snapshots by url.

te.getFedRSnaps(url = 'united states''/united-states/white-to-non-white-racial-dissimilarity-index-for-benton-county-ar-fed-data.html')                     
    

To get Federal Reserve snapshots by country.

te.getFedRSnaps(country = 'united states')                     
    

To get Federal Reserve snapshots by state.

te.getFedRSnaps(state = 'tennessee')                     
    

to get a list of Counties of a state.

te.getFedRCounty(state='arkansas', output_type = None)                     
    

To get a list of indicators of a county.

te.getFedRCounty(county='Pike County, AR', output_type = None)                     
    

Get a snapshot of Federal Reserve by symbol.

getFedReserveSnapshot('ALLMARGATTN')
    
        Output:
                       symbol  Country                                       Category             
    1        ALLMARGATTN   Tennessee      All Marginally Attached Workers for Tennessee
            
    

Get a snapshot of Federal Reserve by URL.

getFedReserveSnapshot(URL = '/united-states/income-inequality-in-aleutians-east-borough-ak-fed-data.html')
    
        Output:
                      symbol  Previous                                                                              URL             
    1        2020RATIO002013   9.93339      /united-states/income-inequality-in-aleutians-east-borough-ak-fed-data.html
            
    

Get a snapshot of Federal Reserve by county.

getFedReserveSnapshot(county = 'arkansas')
    
        Output:
              symbol            Country                                      Category             
    1        ARCLLFN   Clark County, AR      Civilian Labor Force in Clark County, AR
            
    

Get a snapshot of Federal Reserve by country.

getFedReserveSnapshot(country = 'united states')
    
        Output:
                        symbol         Country                                       Category             
    186        A2218C1A027NBEA   United States                                 Dividends paid
    187        A2219C1A027NBEA   United States    Dividends paid: Domestic corporate business
    188        A221RC1A027NBEA   United States      Government saving: Social insurance funds        
    

Get a snapshot of Federal Reserve data by symbol.


        data = te.getFred(symbol = 'ALLMARGATTN').then(function(data){
            console.log(data)     
        });
    

Get a snapshot of Federal Reserve data by county.


        data = te.getFred(county = 'arkansas').then(function(data){
            console.log(data)     
        });
    

Get a snapshot of Federal Reserve data by state.


        data = te.getFred(state = 'tennessee').then(function(data){
            console.log(data)     
        });
    

Get a snapshot of Federal Reserve data by url.


        data = te.getFred(URL = '/united-states/income-inequality-in-aleutians-east-borough-ak-fed-data.html').then(function(data){
            console.log(data)     
        });
    

To get federal reserve data by symbol.


    $url = 'https://api.tradingeconomics.com/fred/snapshot/symbol/{put symbol name here}';
    

To get federal reserve data by url.


    $url = 'https://api.tradingeconomics.com/fred/snapshot/url?url={put url path here}';
    

To get federal reserve data by country.


    $url = 'https://api.tradingeconomics.com/fred/snapshot/country/{put country name here}';
    

To get federal reserve data by state.


    $url = 'https://api.tradingeconomics.com/fred/snapshot/state/{put state name here}';
    

To get federal reserve data by county.


    $url = 'https://api.tradingeconomics.com/fred/snapshot/county/{put county name here}';
    

To get federal reserve data by county and page number.


    $url = 'https://api.tradingeconomics.com/fred/snapshot/county/{put county name here}';
    

Filtering by symbol.


        // replace guest:guest with your key
        WebRequest request = WebRequest.Create(
        "https://api.tradingeconomics.com/fred/snapshot/symbol/{put symbol name here}?c=guest:guest");
    

Filtering by url.


        // replace guest:guest with your key
        WebRequest request = WebRequest.Create(
        "https://api.tradingeconomics.com/fred/snapshot/url?c=guest:guest&url={put url here}");
    

Get fred data by country.


        // replace guest:guest with your key
        WebRequest request = WebRequest.Create(
        "https://api.tradingeconomics.com/fred/snapshot/country/{put country here}?c=guest:guest");
    

Get fred data by state.


        // replace guest:guest with your key
        WebRequest request = WebRequest.Create(
        "https://api.tradingeconomics.com/fred/snapshot/state/{put state here}?c=guest:guest");
    

Get fred data by county.


        // replace guest:guest with your key
        WebRequest request = WebRequest.Create(
        "https://api.tradingeconomics.com/fred/snapshot/county/{put county here}?c=guest:guest");
    

Get fred data by country and page.


        // replace guest:guest with your key
        WebRequest request = WebRequest.Create(
        "https://api.tradingeconomics.com/fred/snapshot/country/{put country here}?c=guest:guest");
    

Get fred snapshot by symbol.


    public static void getFredSymbol() throws IOException
    {
        //put symbol   name here
        String params = "ALLMARGATTN";
        params = params.replaceAll("\\s","%20"");
        //set the path
        String path = "/fred/snapshot/symbol" + "/" + params;   
        System.out.println("Get fred snapshot by symbol");
        constructUrl (path);
    }
    

Get fred data by county.


    public static void getFredCounty() throws IOException
    {
        //put category  name here
        String params = "arkansas";
        params = params.replaceAll("\\s","%20"");
        //set the path
        String path = "/fred/snapshot/county" + "/" + params;   
        System.out.println("Get fred data by county");
        constructUrl (path);
    }
    

*United States only.

**Pages parameter starts at 0; Only used on endpoints where it is not possible to use start and end dates and exceeds the limits of rows.

Historical

To get Federal Reserve historical data using TE symbol.

te.getHistorical('racedisparity005007:fred')

To get Federal Reserve historical data by more than one symbol and dates.

te.getFedRHistorical(symbol = [ 'racedisparity005007', '2020ratio002013'] )                     
te.getFedRHistorical(symbol = [ 'racedisparity005007', '2020ratio002013'], initDate  = '2018-05-01')                     
te.getFedRHistorical(symbol = [ 'racedisparity005007', '2020ratio002013'], initDate  = '2018-05-01', endDate  = '2019-01-01')                     

Get Federal Reserve historical data using TE symbol.

getHistorical('RACEDISPARITY005007:fred')

Get Federal Reserve historical data.

getFedHistorical('RACEDISPARITY005007')

    Output:
                      symbol                  date         value             
2        RACEDISPARITY005007   2009-01-01T00:00:00      33.60301
21       RACEDISPARITY005007   2010-01-01T00:00:00      36.29680
3        RACEDISPARITY005007   2011-01-01T00:00:00      36.59937        

Get historical data of Federal Reserve by symbol or symbols and dates.


    data = te.getFred(historical_symbol = 'RACEDISPARITY005007').then(function(data){
        console.log(data)     
    });

    data = te.getFred(historical_symbol = 'RACEDISPARITY005007', start_date = '2017-05-01').then(function(data){
        console.log(data)     
    });

    data = te.getFred(historical_symbol = 'RACEDISPARITY005007', start_date = '2017-05-01', end_date = '2018-12-31').then(function(data){
        console.log(data)     
    });

To get federal reserve historical data by symbol.


$url = 'https://api.tradingeconomics.com/fred/historical/{put symbol name here}';

To get federal reserve historical data by more than one symbol.


$url = 'https://api.tradingeconomics.com/fred/historical/{put symbols name here}';

Get fred historical by symbol or symbols.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/fred/historical/{put symbol here}?c=guest:guest");

Get fred historical data by symbol or symbols.


public static void getFredHistoricalSymbol() throws IOException
{
    //put symbol or symbols name here
    String params = "RACEDISPARITY005007,2020RATIO002013";
    params = params.replaceAll("\\s","%20"");
    //set the path
    String path = "/fred/historical" + "/" + params;   
    System.out.println("Get fred historical data by symbols");
    constructUrl (path);
}

Response Fields

Symbol Unique symbol used by Trading Economics
Country Name of country, state or county
Name* State name
County** County name
Category Indicator category name
Last Latest released value
Value 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 Popularity ranking
Start Indicator start date
Unit Unit of the value
Adjustment Adjustment
URL Hyperlink at Trading Economics
LastUpdate Time when new data was inserted or changed

*Name is used only in 'List of all US states' endpoint.
**County is used only in 'List of all counties per state' endpoint.