NAV Navbar
Logo
Python R Javascript C# Java PHP

Introduction

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

We support Python 2.7 and Python 3.6. Then you need to install the tradingeconomics package. You can do so in a variety of ways.


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

pip install tradingeconomics

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


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

install.packages("devtools")

Load the devtools package.

library(devtools)

Install the tradingeconomics package.

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

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

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.

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 http://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/portugal,brazil,russia/indicator/gdp,currency





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/portugal,brazil,russia/indicator/gdp,currency

Multiple Parameters

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

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:

Authentication

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

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

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

Without APIkeys all requests will return the default sample data.

Error codes

Notes

Indicators

Here you can get a list of all indicators, indicators by country, country-indicator pair and historical information for specific country and indicator. Click on any method below for a sample.

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

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

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

To get several countries and indicators

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

        Output:
              country              Category  LatestValue   
2               China                   GDP       275.00
21              China        Inflation Rate          2.5
3       United States                   GDP      19390.6
4       United States        Inflation Rate            2

To get a list of all indicators per country.

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

        Output:
                 country                      Category   LatestValue   
2          United States         ADP Employment Change        275.00
21         United States    API Crude Oil Stock Change          2.40
3          United States           Asylum Applications       7267.00

To get List of Indicators by Country:

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

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

To get Country/Indicator pair:

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

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

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 indicators by country or countries.


    data = te.getIndicatorData(country = ['china', 'portugal']).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)       
  });

Without an API key only a small sample of data will be given.
You can get your test key at http://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}';

Methods

Response Fields

Country Country name
Category Category name
Title Combination of country/category
LatestValueDate Date of the last released value
LatestValue Last released value
Source Source of data
Unit Unit of the value
URL Hyperlink at Trading Economics
CategoryGroup Category group name
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
PreviousValue Previously released value
PreviousValueDate Date of the previously released value

Historical

To get historical data of imports in United Kingdom type.

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

        Output:
                  country        Category     Frequency   
2          United Kingdom         Imports       Monthly
21         United Kingdom         Imports       Monthly
3          United Kingdom         Imports       Monthly

To get historical data for several countries and indicators.

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

To get historical data by ticker.

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

    Output:
                country                     DateTime     Frequency   
2          United States         2018-07-31T00:00:00       Monthly
21         United States         2018-08-31T00:00:00       Monthly
3          United States         2018-09-30T00:00:00       Monthly

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

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

Out[2]: 
                  0
2006-12-31  2588.08
2007-12-31  2969.73
              ...
2013-12-31  2712.30
2014-12-31  2990.20

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



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

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

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


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

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


    data = te.getHistoricalData(country = ['china','portugal' ], indicator = 'gdp', start_date = '2018-02-02', 
    end_date = '2019-02-02').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 = '2018-02-02' ).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}';

Methods

Response Fields

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

Credit Rating



To get Credit Rating data for one country.

te.getRatings(country= 'United states', output_type='df')


To get Credit Rating data for several countries.

te.getRatings(country=['United states','Japan'], output_type='df')

             Country     TE   TE_Outlook      SP    SP_Outlook    Moodys    Moodys_Outlook    Fitch    Fitch_Outlook    Outlook
  0            Japan     77     Positive      A+      Positive        A1            Stable        A           Stable        NaN
  1    United States     98       Stable     AA+        Stable       Aaa            Stable      AAA           Stable        NaN


To get Credit Rating historical data for one country.

te.getHistoricalRatings(country= 'United states', output_type='df')


To get Credit Rating historical data for several countries.

te.getHistoricalRatings(country=['United states','United Kingdom'])

              Country           Date       Agency    Rating           Outlook    
  0    United Kingdom     20-02-2019        Fitch        AA    Negative Watch               
  1    United Kingdom     22-09-2017      Moody's       Aa2            Stable 
  3     United States     21-03-2014         DBRS       AAA            Stable
  4     United States     15-10-2013        Fitch       AAA            Stable
      

To get the last ratings for all countries.


getCreditRating('United States')  

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

To get Credit Rating by country.


getCreditRating('United States')            

To get Credit Rating by several countries.


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

To get Historical Credit Rating by country.


getCreditRatingHistorical('United States' )          

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 = 'china').then(function(data){
        console.log(data)       
    });

To get credit ratings for multiple countries.


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

To get historical ratings.


    data = te.getRatings(historical = 'united states').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 http://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);
}

Methods

Response Fields

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

Latest updates

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


To get latest updates using a starting date.

te.getLatestUpdates(initDate='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 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, 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.


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

Methods

Response Fields

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

Economic Calendar

Events

To get all calendar events.

getCalendarData()           

To get information about calendar events for the United Kingdom

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

                  Date        Country               Category                                 Event Reference Unit                         Source Actual Previous Forecast TEForecast
1  2016-11-23T11:30:00 United Kingdom          Interest Rate                     BoE Forbes Speech                               Bank of England                                    
2  2016-11-23T11:40:00 United Kingdom          Interest Rate                       BoE Rule Speech                               Bank of England                                    
3  2016-11-23T12:30:00 United Kingdom               Calendar Philip Hammond Makes Autumn Statement                                                                                  
4  2016-11-24T09:30:00 United Kingdom               Calendar                BBA Mortgage Approvals       Oct                                               38.3K    38.8K      40.5K
5  2016-11-25T09:30:00 United Kingdom        GDP Growth Rate           GDP Growth Rate QoQ 2nd Est        Q3      Office for National Statistics            0.7%     0.5%       0.5%

To get information about calendar events for several countries and indicators

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

To get information about calendar events for specific indicator.

getCalendarData(indicator = 'initial jobless claims')

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

getCalendarData(indicator = 'initial jobless claims', 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 = c('IJCUSA', 'SPAINFACORD'))

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 data for a specific country, in data frame format, run:

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

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

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

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

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

Get Calendar events by a specific Id.


te.getCalendarId(id= 160025)

  CalendarId                 Date    ...                 Category   Importance
0     160025  2018-06-21T07:00:00    ...           Factory Orders            1

Get Calendar events by multiple Ids.


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

  CalendarId                 Date    ...                 Category   Importance
0     160025  2018-06-21T07:00:00    ...           Factory Orders            1
1     160030  2018-06-23T06:15:00    ...           Inflation Rate            1
2     174108  2018-06-19T00:00:00    ...                 Holidays            1

To get all calendar events, no parameters are required.


    data = te.getCalendar().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 = 'china').then(function(data){
        console.log(data)     
    });

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


    data = te.getCalendar(country = 'china', 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 = 'interest 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)     
    });

Filter calendar events by calendar ID.


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

Filter calendar events by ticker.


    data = te.getCalendar(ticker = ['SPAINFACORD','BAHRAININFNRATE']).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 http://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}';

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

Methods

Response Fields

Date Release time and date in UTC
Country Country name
Category Indicator category name
Event Specific event name in the calendar
Reference The period for which released data refers to
Source Source of data
Actual Latest released value
Previous Value for the previous period after the revision (if revision is applicable)
Forecast Average forecast among a representative group of economists
TEForecast TE own projections
URL Hyperlink at Trading Economics
DateSpan 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)
OCountry Country’s original name
OCategory Category’s original name
Ticker Unique ticker used by Trading Economics
Symbol Unique symbol used by Trading Economics
CalendarID Unique calendar ID used by Trading Economics

Streaming









Copy this code and execute

import tradingeconomics as te
import json

te.login('guest:guest')

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

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

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

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

Step 2

cd open-api/stream/nodejs

Step 3 - Install dependencies

npm install

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

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

Step 5 - Run it

node app.js

Check here for the complete sample code.

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($"ws://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("ws://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);
            System.out.println("Enter topic for subscription: ");
            while(scan.hasNext)) {
                String to =  scan.nextLine();
                String subs =  "{\"topic\": \"subscribe\", \"to\": \"" + to + "\calendar" }";
                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

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

Response fields for the calendar subscription:

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

Forecast

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

getForecastData(country ='united states')

        Output:
                 country                      Category         Q1         Q2         Q3        Q4
2          United States         ADP Employment Change     190.00     160.00     145.00    180.00   
21         United States    API Crude Oil Stock Change      -3.20       5.20      -3.20     -3.20 
3          United States       Average Hourly Earnings       0.20       0.30       0.20      0.20 

To get forecast data by country and indicator.

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

        Output:
                 country        Category         Q1         Q2         Q3        Q4
2          United States         Imports     262000     269000     258000    255000   

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

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

        Output:
                 country          Category        Q1         Q2         Q3       Q4
2                  China               GDP   13200.0    13200.0    13200.0    13900   
21                 China    Inflation Rate       1.8        1.9        1.9        2 
3          United States               GDP   20220.0    20220.0    20220.0  20700.0 
3          United States    Inflation Rate       1.8        1.7        1.9      1.8 


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


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

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


Forecasted values for more than one country.

te.getForecastData(country= ['united states', 'china' ], 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=['united states', 'china'], indicator=['gdp', 'population'], output_type='df')

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

Get forecasts by country.


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

Get forecasts for multiple countries.


    data = te.getForecasts(country = ['china','united states']).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.


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

Get forecasts by country and indicator.


    data = te.getForecasts(country = 'united states', indicator = 'interest rate').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 http://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}';

Methods

Response Fields

Category Name of the indicator
Title Combination of country and indicator name
ForecastDate Date of the forecast
ForecastValue Forecast value at the time of the forecast date
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
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
LatestValue Last released value
LatestValueDate Date of the last released value
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
HistoricalDataSymbol Unique symbol used by Trading Economics

Markets

Snapshots

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.

marketsField can be:
Commodities

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    ...

Index

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

Currency

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             

Bond

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

To get stock market index data:

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

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

To get stock market data filtered by symbol:

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

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

To get stock market data filtered by symbols:

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

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

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 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', 'indu:ind']).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 market by country.


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

Get stock market searching for country.


    data = te.getMarketSnap(search_term = 'united states', category = 'index').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 stock market searching for country and page number.


    data = te.getMarketSnap(search_term = 'united states', category = 'index', page = '0').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 http://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 and page number.


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

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

Search for country and category and page number.


public static void getMarketCategoryPage() 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"");
    //put page number here
    String page = "2";
    //set the path
    String path = "/markets/search" + "/" + params + "?category=" + params1 + "&page";   
    System.out.println("Search for country and category and page number");
    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 and page number.


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

Methods

Market Lists

To get closely related items of a certain symbol:

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

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

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

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

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

To get components of the certain index:

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

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

To get components of the group of indexes:

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

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

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 search markets by country.

te.getMarketsSearch(country='japan')

To search markets by country and category.

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

To search markets by country and categories and page number.

te.getMarketsSearch(country='japan', category = ['index', 'markets'], page = 2  )

To get markets search by country, category and page number.

getMarketsSearch('Japan', 'index' , '2')

        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 = ('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                

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

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

Because this endpoint can yield too many results, this method has pagination. Each page is limited to 250 items, you can request each page separately.

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


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

Historical

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

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

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

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

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

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

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',
    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','INDU:IND'), initDate = '2011-01-01',endDate='2016-01-01', outType = 'df')

    Output: 
       Symbol         Open            High              Low         Close   
1     AAPL:US      65.5871         65.6399          64.0499       64.8028        
2    INDU:IND   13860.5800      14019.7800       13860.5800    14009.7900                
3    INDU:IND   12632.7600      12784.6200       12632.7600    12716.4600                
4     AAPL:US      65.4871         65.5699          65.0785       65.1699                
                

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

Methods

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='indu:ind')

Output:
        Symbol                 Date     ...             Low       Close
0     INDU:IND  2018-04-30T08:30:00     ...      24409.2109  24409.2109
1     INDU:IND  2018-04-30T08:31:00     ...      24407.2207  24409.2109
2     INDU:IND  2018-04-30T08:32:00     ...      24410.2109  24411.2109
 ...       ...                  ...     ...             ...         ...

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

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

Output:
        Symbol                 Date     ...             Low       Close
0     INDU:IND  2018-03-13T15:30:00     ...      25198.0606  25209.9609
1     INDU:IND  2018-03-13T15:31:00     ...      25201.9395  25206.9395
2     INDU:IND  2018-03-13T15:32:00     ...      25201.8809  25208.8809
 ...       ...                  ...     ...             ...         ...

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

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

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

Methods

Response Fields

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

Streaming

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/open-api.git

Step 2

cd open-api/stream/nodejs

Step 3 - Install dependencies

npm install

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

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

Step 5 - Run it

node app.js

Check here for the complete sample code.

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($"ws://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("ws://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);
            System.out.println("Enter topic for subscription: ");
            while(scan.hasNext)) {
                String to =  scan.nextLine();
                String subs =  "{\"topic\": \"subscribe\", \"to\": \"" + to + "\EURUSD:CUR" }";
                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());
        }
    }    
}

Response fields for the markets subscription:

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

For a detailed list of available live data please contact us

Market Forecasts

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

Methods

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

Earnings

To get earnings by country.

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

To get earnings by date.

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

To get earnings by category.

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

To get earnings by type. Type can be: earnings, dividends, ipo.

getEarnings(type='dividends')

        Output: 
          Symbol                   Date   Actual    Country           
 1     600309:CH    2019-05-27T00:00:00       2       China              
 2       AMRT:IJ    2019-05-27T00:00:00    6.24   Indonesia                      
 3       BMRI:IJ    2019-05-27T00:00:00  241.22   Indonesia                     
              
 

To get default earnings calendar:

te.getEarnings()

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

To get earnings calendar filtered by symbol and date:

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

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

To get earnings calendar by country:

te.getEarnings(country = 'united states')

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

Get earnings default calendar, no parameters are required.


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

Get earnings calendar by date.


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

Get earnings calendar by symbol and date.


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

Get earnings calendar by country.


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

Get earnings calendar by type. Type can be: earnings, ipo and dividends.


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

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

<?php
$url = 'https://api.tradingeconomics.com/earnings';
$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 calendar by date. Date format - yyyy-mm-dd.


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

To filter earnings calendar by market and date.


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

To filter earnings calendar by country.


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

To get default earnings calendar.


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

Get earnings calendar by market and date.


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

Get earnings 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/symbol/{put symbol name here}?d1={put date here}&d2={put date here}&c=guest:guest");

Filter earnings by country.


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

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


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/earnings?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 calendar.


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

Get earnings 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/symbol" + "/" + params + "?d1=" + date;   
    System.out.println("Get earnings by symbol within a date interval");
    constructUrl (path);
}

Methods

Response Fields

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

News

Latest news

To get the latest news.


te.getNews(output_type = None)

To get several countries and indicators.


te.getNews(country =[ 'united states','China'],indicator=['Imports','Exports'])

             id                                     title         ...        symbol                         url
0         71068        China Exports Rebound Unexpectedly         ...      CNFREXPD              /china/exports                
1         71067     China Imports Fall Less than Expected         ...      CNFRIMPD              /china/imports
2         70737          US Imports Drop 2.9% in November         ...       TBIMTOT      /united-states/imports
3         69595          US Exports Fall 0.6% in November         ...       TBEXTOT      /united-states/exports
   


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



te.getNews(country ='united states',indicator='Imports',start=10,limit=5)

             id                                     title         ...        symbol                         url
0         51979        US Imports Remain At All Time High         ...       TBIMTOT      /united-states/imports                
1         50419          US Imports Jump 2.5% to a Record         ...       TBIMTOT      /united-states/imports
2         48921              US Imports Hit All-Time High         ...       TBIMTOT      /united-states/imports
3         45470     US Imports Rise 1.6% to All-Time High         ...       TBIMTOT      /united-states/imports
4         44150           US Imports Rebound in September         ...       TBIMTOT      /united-states/imports   

To get the latest news by country, or countries.

getLatestNews(c('united states','japan'))

To get the latest news by category.

getLatestNews(identifier='inflation rate',category = 'indicator')

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

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

        Output: 
                    Symbol                                                 title                        Date             
 1                GCAN10YR                 Canada 10Y Bond Yield Hits 9-week Low     2019-05-29T14:11:27.193                    
 2                GNTH10YR          Netherlands 10Y Bond Yield Hits 31-month Low      2019-05-29T14:28:18.69                     
 3    UNITEDSTARICFEDMANIN     US Fifth District Manufacturing Activity Index Up         2019-05-29T14:05:00                    
              
 

Get the latest news.


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

Get news by country.


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

Get news by indicator.


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

Get news by country and indicator.


    data = te.getNews(country = 'china', indicator = 'imports').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 http://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);
}

Methods

Response Fields

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

Latest articles

To get the latest articles by several countries and indicators and also with a start index and limit size.

te.getArticles(country =[ 'united states','Portugal'],indicator=['Imports','Interest rate'],start=10,lim=5)

             id                                     title         ...     symbol                               url
0         25574                   Fed Leaves Rates Steady         ...       FDTR      /articles/08012018180303.htm                
1         25451      Fed Sees Intensified Risks Around...         ...       FDTR      /articles/07052018182602.htm
2         25361                           Fed Hikes Rates         ...       FDTR      /articles/06132018180220.htm
3         25257  Fed Signals Next Rate Hike Soon, June...         ...       FDTR      /articles/05232018183719.htm
4         25156                  Fed Leaves Rates on Hold         ...       FDTR      /articles/05022018180155.htm   

To get the latest articles by country and within a specific date.

te.getArticles(country = 'united states',initDate='2018-10-10',endDate='2018-10-15')

       id                                          title                     date   ...         symbol                               url
0   26902      US Consumer Sentiment Lower than Expected      2018-12-10T09:28:07   ...       CONCCONF      /articles/10122018140928.htm                
1   26894    US Jobless Claims Unexpectadly Rise to 214K      2018-11-10T12:54:40   ...         IJCUSA      /articles/10112018123423.htm
2   26895           US Inflation Rate Lowest in 7 Months      2018-11-10T12:49:32   ...        CPI YOY      /articles/10112018123453.htm
 

To get the latest articles by Id.

te.getArticleId(id = '26902')

       id                                          title                     date   ...         symbol                               url
0   26902      US Consumer Sentiment Lower than Expected      2018-12-10T09:28:07   ...       CONCCONF      /articles/10122018140928.htm                

  

To get the latest articles by country, or countries.

getLatestArticles(c('united states','portugal'))

To get the latest articles by indicator.

getLatestArticles(indicator='inflation rate')

To get the latest articles by start index and article limit.

getLatestArticles(limit='5',start = '2')

To get the latest articles by country, or countries and indicator.

getLatestArticles(c('united states','portugal'),'inflation rate')

Get the latest articles, no parameters are required.


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

Get latest articles by country.


    data = te.getArticles(country = 'portugal').then(function(data){
        console.log(data)     
    });

Get latest articles by indicator or indicators.


    data = te.getArticles(indicator = 'exports').then(function(data){
        console.log(data)     
    });

Get latest articles by country or countries and indicator or indicators.


    data = te.getArticles(country = 'china', indicator = 'exports').then(function(data){
        console.log(data)     
    });

Get articles by a specific ID.


    data = te.getArticles(id = '20580').then(function(data){
        console.log(data)     
    });

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


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

To filter articles by country.


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

To get articles by country within a date interval. Date format - yyyy-mm-dd.


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

To filter articles by id.


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

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


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

To get lastest Articles.


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

Get lastest articles by country, or countries.


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

Get latest articles by indicator, or indicators.


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

Get articles by country and indicator, or countries and indicators.


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

Paginate articles list by specifying start index and list size.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/articles?c=guest:guest&lim={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 articles.


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

Get articles by country.


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

Methods

Response Fields

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

World Bank

Category


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 by category, and page number.

te.getWBCategories(category = 'Demographics',page_number=2)

            category     ...                last_update                                 
0       Demographics     ...     2017-10-16T09:03:02.75             
1       Demographics     ...    2017-10-16T09:03:02.733
2       Demographics     ...     2017-10-16T09:03:02.72
...      

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    

To get World Bank data by category and page number.

getWorldBankCategories(category = 'Education', page = '2')

Output:
                      series_code          category                                                                                                      URL    
3           5.2.6_ETH.BAS.AID.FIN         Education            /country-list/international-aid-disbursed-to-basic-education-finland-to-ethiopia-wb-data.html    
4           5.2.6_GHA.BAS.AID.WFP         Education                /country-list/international-aid-disbursed-to-basic-education-wfp-to-djibouti-wb-data.html    
5      5.2.6_GIN.BAS.AID.ADPP.KFW         Education                  /country-list/international-aid-disbursed-to-basic-education-kfw-to-guinea-wb-data.html    

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

Get World Bank data by a specific category and page number.


    data = te.getWorldBank(category = 'education', page = '2').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}';

To get world bank data by category, and page number.


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

Without an API key only a small sample of data will be given.
You can get your test key at http://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");

Filtering by the category and page number.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/worldBank/category/{put category name here}/{put page number 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);
}

Get world bank data by category and page number.


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

Methods

Response Fields

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

Indicators and Countries


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 and page number.

te.getWBCountry(country = 'Portugal',page_number = 3)

                    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 and page number.

getWorldBankIndicators(category = 'country', identifier = 'Portugal', page_number = '2')

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 and page number.


    data = te.getWorldBank(country = 'united states', page = '2').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 and page number.


$url = 'https://api.tradingeconomics.com/worldBank/country/{put country name here}/{put page number 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 and page number.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/worldBank/country/{put country name here}/{put page number 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 and page.


public static void getWBCountryPage() throws IOException
{
    //put country  name here
    String params = "portugal";
    params = params.replaceAll("\\s","%20"");
    //put page number here
    String page = "2";
    //set the path
    String path = "/worldBank/country" + "/" + params + "/" + page;   
    System.out.println("Get world bank data by specific country and page");
    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);
}

Methods

Response Fields

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

Historical


To get World Bank historical data by specific indicator.

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

                 symbol                      date      value           
0       usa.fr.inr.rinr       1961-06-15T00:00:00    3.10788
1       usa.fr.inr.rinr       2018-06-10T00:00:00    3.21535
2       usa.fr.inr.rinr       2018-05-12T00:00:00    3.37488        
...

To get World Bank historical data by series code.

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

    Output:
                     symbol                  date         value    
2           usa.fr.inr.rinr   1961-06-15T00:00:00       3.10788    
210         usa.fr.inr.rinr   1962-06-15T00:00:00       3.21535    
3           usa.fr.inr.rinr   1963-06-15T00:00:00       3.37488    

To get world bank historical data for a specific indicator.


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

Historical data for a specific indicator.


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

Get world bank historical data by specific series code.


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=" + series_code;   
    System.out.println("Get world bank historical data by specific series code");
    constructUrl (path);
}

Get World Bank historical data.


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

Methods

Response Fields

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

Comtrade


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

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

Methods

Response Fields

Id
Name
ParentId
Pretty_Name

Country

To get Comtrade by 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 Comtrade by several countries.

te.getCmtCountry(country = ['China', 'united states', 'japan'])

To get Comtrade by countries and page number.

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

          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 Comtrade by country and page number.

te.getCmtCountry(country ='China', page_number=3)

To get Comtrade between two countries and page number.

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

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'), page_number = '4')

    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.


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

You can request each page separately.


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

Get a snapshot of trade between two countries (with pagination).


    data = te.getComtrade(country = 'united states', country1 = 'china', page = '2').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 by country and page number.


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

To get comtrade data between two countries.


$url = 'https://api.tradingeconomics.com/comtrade/country/{put country1 name here}/{put country2 name here}/{put page number 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 and page number.


    // 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 by country and page number.


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

Get comtrade between two countries and page number.


    // replace guest:guest with your key
    WebRequest request = WebRequest.Create(
    "https://api.tradingeconomics.com/comtrade/country/{put country1 name here}/{put country2 name here}/{put page number 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 and page number.


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"");
    //put page number here
    String page = "2";
    //set the path
    String path = "/comtrade/country" + "/" + params + "/" + params1 + "/" + page;   
    System.out.println("Get comtrade data between countries and page number");
    constructUrl (path);
}

Methods

Response Fields

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

Historical


To get Comtrade historical data by specific symbol.

te.getCmtHistorical(symbol = 'PRTESP24031')

             symbol                      date    value           
0       PRTESP24031       1997-12-31T00:00:00    707.0
1       PRTESP24031       1998-12-31T00:00:00   7020.0
2       PRTESP24031       2000-12-31T00:00:00  54310.0        
...

Get detailed information about Comtrade historical data by symbol.

getComtradeHistorical('PRTESP24031')

    Output:
                symbol                        date        value   
2          PRTESP24031         1997-12-31T00:00:00          707
21         PRTESP24031         1998-12-31T00:00:00         7020
3          PRTESP24031         2000-12-31T00:00:00        54310

Get Comtrade historical data by symbol.


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

To get comtrade historical data.


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

Get comtrade historical data by symbol.


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

Get comtrade historical data by symbol.


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

Methods

Response Fields

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

Federal Reserve


To get Federal Reserve states and counties.

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


te.getFedRStates(county = 'arkansas')

                   county                             
0     Arkansas County, AR       
1       Ashley County, AR      
2        Boone County, AR              
...

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

Methods

Response Fields

Name State
County County

Snapshots


To get Federal Reserve snapshots by symbol.


te.getFedRSnaps(symbol = 'AGEXMAK2A647NCEN')

                   symbol   ...            lastUpdate                          
0        AGEXMAK2A647NCEN   ...   20-02-2019T13:47:00       

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 Federal Reserve snapshots by county or state and page number.


te.getFedRSnaps(state = 'tennesse',page_number = 5)

         symbol   ...                lastUpdate                          
0        TNODIV   ...   2019-03-03T19:57:18.903 
1        TNOFAR   ...   2019-03-03T19:57:18.713 
2        TNOI96   ...   2019-03-03T19:57:18.217       
...

To get Federal Reserve snapshots on Pike County, AR.


te.getFedRCounty(output_type = None)                     

Get a snapshot of Federal Reserve by symbol.

getFedReserveSnapshot('AGEXMAK2A647NCEN')

    Output:
                   symbol  Country                                       Category             
1        AGEXMAK2A647NCEN   Alaska      Age 65 and Over Tax Exemptions for Alaska
        

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 and page number.

getFedReserveSnapshot(country = 'united states', page = '2')

    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 = 'AGEXMAK2A647NCEN').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}/{put page number 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}/{put page number here}?c=guest:guest");

Get fred snapshot by symbol.


public static void getFredSymbol() throws IOException
{
    //put symbol   name here
    String params = "AGEXMAK2A647NCEN";
    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);
}

Get fred data by country and page number.


public static void getFredCountryPage() throws IOException
{
    //put country  name here
    String params = "united states";
    params = params.replaceAll("\\s","%20"");
    //put page number here
    String page = "2";
    //set the path
    String path = "/fred/snapshot/country" + "/" + params + "/" + page;   
    System.out.println("Get fred data by country and page number");
    constructUrl (path);
}

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

Methods

Response Fields

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

Historical

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

te.getFedRHistorical(symbol = [ 'racedisparity005007', '2020ratio002013'] )                     

To get Federal Reserve historical data by symbol.


te.getFedRHistorical(symbol = 'racedisparity005007')

                      symbol                     date        value                
0        racedisparity005007      2009-01-01T00:00:00     33.60301
1        racedisparity005007      2010-01-01T00:00:00     36.29680
2        racedisparity005007      2011-01-01T00:00:00     36.59937 
...

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.


    data = te.getFred(historical_symbol = 'RACEDISPARITY005007').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);
}

Methods

Response Fields

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