Historical

The historical endpoint contains a time series with an indicator identifier, the reference date and the observed value. It allows one to check the evolution of key indicators over time.

By symbol

Using Requests:

import requests
api_key = 'YOUR_API_KEY'
url = f'https://api.tradingeconomics.com/comtrade/historical/PRTESP24031,NORZWEXX991?c={api_key}'
data = requests.get(url).json()
print(data)

Or using our package:

import tradingeconomics as te
te.login('your_api_key')
te.getCmtHistorical(symbol = 'PRTESP24031')

With multi symbols:

te.getCmtHistorical(symbol = 'PRTESP24031, NORZWEXX991')

Using Requests:

const axios = require('axios');
(async () => {
    const api_key = 'YOUR_API_KEY'
    const response = await axios.get(`https://api.tradingeconomics.com/comtrade/historical/PRTESP24031,NORZWEXX991?c=${api_key}`)
    console.log(response.data)
})()

Or using our package:

const te = require('tradingeconomics');
te.login('your_api_key');
data = te.getComtrade(symbol = 'PRTESP24031').then(function(data){
    console.log(data)     
});

With multi symbols:

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

Using Requests:

using (var httpClient = new HttpClient())
{
    using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/comtrade/historical/PRTESP24031,NORZWEXX991?c=your_api_key"))
    {
        request.Headers.TryAddWithoutValidation("Upgrade-Insecure-Requests", "1");
        var response = await httpClient.SendAsync(request);
        if (response.IsSuccessStatusCode)
        {
            var content = await response.Content.ReadAsStringAsync(); 
            Console.WriteLine(content);
        }
    }
}

With multi symbols:

using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/comtrade/historical/PRTESP24031,NORZWEXX991?c=your_api_key"))

The response data format can be configured by appending the &f= parameter to the URL request.

/comtrade/historical/{symbols}

symboldatevalue
PRTESP2403112/31/1997 12:00:00 AM707
PRTESP2403112/31/1998 12:00:00 AM7020
PRTESP2403112/31/2000 12:00:00 AM54310

/comtrade/historical/{symbols}?f=json

[{"symbol":"PRTESP24031","date":"1997-12-31T00:00:00","value":707.0},{"symbol":"PRTESP24031","date":"1998-12-31T00:00:00","value":7020.0},{"symbol":"PRTESP24031","date":"2000-12-31T00:00:00","value":54310.0}]

/comtrade/historical/{symbols}?f=csv

symbol,date,value
PRTESP24031,12/31/1997 12:00:00 AM,707
PRTESP24031,12/31/1998 12:00:00 AM,7020
PRTESP24031,12/31/2000 12:00:00 AM,54310

/comtrade/historical/{symbols}?f=xml

<ArrayOfComtradeHistorical xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/APILib.DB">
ComtradeHistorical>
<date>1997-12-31T00:00:00</date>
<symbol>PRTESP24031</symbol>
<value>707</value>
</ComtradeHistorical>
<ComtradeHistorical>
<date>1998-12-31T00:00:00</date>
<symbol>PRTESP24031</symbol>
<value>7020</value>
</ComtradeHistorical>
<ComtradeHistorical>
<date>2000-12-31T00:00:00</date>
<symbol>PRTESP24031</symbol>
<value>54310</value>
</ComtradeHistorical>
</ArrayOfComtradeHistorical>

Response fields

FieldTypeDescriptionExample
SymbolstringUnique symbol used by Trading Economics“NORZWEXX991”
DatestringYear of the updated series“1995-12-31T00:00:00”
ValuestringTrade value3161.0