Get started

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

Authentication

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

Note: without an API key, all requests will return the default sample data.

Endpoint

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

curl -i "https://api.tradingeconomics.com/country/mexico/?client=guest:guest"

Using Headers auth:

curl -i "https://api.tradingeconomics.com/country/mexico/" -H "Authorization: Client guest:guest"

Packages

You can get Python from: python.org/downloads. Then you need to install the tradingeconomics package.
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

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

import tradingeconomics as te
te.login('Your_Key:Your_Secret')

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

te.login()

You can get Node.js from: nodejs.org/en/download. Then you need to install the 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');
te.login('client_key');

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

te.login()

You can use any server based language to get data from the API. In this documentation the examples will be in C#.

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

namespace Examples.System.Net
{
    public class Indicators
    {
        public static void Main()
        {
            WebRequest request = WebRequest.Create("https://api.tradingeconomics.com/indicators?c=your_api_key");
            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();
        }
    }        
}

If you don’t have an API key and just want to try a demo of our API, use guest:guest in the endpoints:

 WebRequest request = WebRequest.Create("https://api.tradingeconomics.com/indicators?c=guest:guest");

You can get a test key at User dashboard.

GitHub

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

Data Types

You can request data in several formats:

Status codes

  • 200 - OK
  • 401 - Unauthorized (The user doesn’t have an access, client key missing or wrong)
  • 403 - Forbidden (The user hit the maximum limit of downloads or was blocked)
  • 400 - Bad Request (Some error with a request, like a typo, wrong parameter, etc.)
  • 409 - Conflict (Throttle, too many requests per second, beyond the API limit - 1 request per second)

Rate Limits

  • API calls for historical data have a maximum limitation of 10000 rows.
  • API calls for the Economic Calendar have a maximum limitation of 1000 rows.
  • One API call is limited to 260 characters.
  • There is a general limitation of 1 request per second.