Markets Historical

The historical endpoint contains a time series with fields such as symbol, date, open, high, low, close, and 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/markets/historical/aapl:us,gac:com?c={api_key}'
data = requests.get(url).json()
print(data)

Or using our package:

import tradingeconomics as te
te.login('your_api_key')
te.getHistorical(symbol='aapl:us')

With multi symbols:

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

Using Requests:

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

Or using our package:

const te = require('tradingeconomics');
te.login('your_api_key');
data = te.getHistoricalMarkets(symbol = 'aapl:us').then(function(data){
  console.log(data)     
});

With multi symbols:

data = te.getHistoricalMarkets(symbol = ['aapl:us','gac:com']).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/markets/historical/aapl:us?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:

new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/markets/historical/aapl:us,gac:com?c=your_api_key");

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

/markets/historical/{symbols}

SymbolDateOpenHighLowClose
AAPL:US12/07/2023189.6800191.7000188.4700189.7600
GAC:COM11/07/20231675.00001675.00001675.00001675.0000
AAPL:US11/07/2023189.1600189.3000186.6000188.0800

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

[{"Symbol":"AAPL:US","Date":"10/10/2023","Open":178.1000,"High":179.7200,"Low":177.9500,"Close":178.3900},{"Symbol":"GAC:COM","Date":"10/10/2023","Open":1955.0000,"High":1980.0000,"Low":1930.0000,"Close":1955.0000},{"Symbol":"GAC:COM","Date":"09/10/2023","Open":1955.0000,"High":1980.0000,"Low":1930.0000,"Close":1955.0000}]

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

Symbol,Date,Open,High,Low,Close
AAPL:US,10/10/2023,178.1000,179.7200,177.9500,178.3900
GAC:COM,10/10/2023,1955.0000,1980.0000,1930.0000,1955.0000
GAC:COM,09/10/2023,1955.0000,1980.0000,1930.0000,1955.0000

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

<ArrayOfMarkets.HistoricalMarketsItem xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/APILib.DB">
<Markets.HistoricalMarketsItem>
<Close>178.3900</Close>
<Date>10/10/2023</Date>
<High>179.7200</High>
<Low>177.9500</Low>
<Open>178.1000</Open>
<Symbol>AAPL:US</Symbol>
</Markets.HistoricalMarketsItem>
<Markets.HistoricalMarketsItem>
<Close>1955.0000</Close>
<Date>10/10/2023</Date>
<High>1980.0000</High>
<Low>1930.0000</Low>
<Open>1955.0000</Open>
<Symbol>GAC:COM</Symbol>
</Markets.HistoricalMarketsItem>
<Markets.HistoricalMarketsItem>
<Close>1955.0000</Close>
<Date>09/10/2023</Date>
<High>1980.0000</High>
<Low>1930.0000</Low>
<Open>1955.0000</Open>
<Symbol>GAC:COM</Symbol>
</Markets.HistoricalMarketsItem>
</ArrayOfMarkets.HistoricalMarketsItem>

By symbol and date

Using Requests:

import requests
api_key = 'YOUR_API_KEY'
url = f'https://api.tradingeconomics.com/markets/historical/aapl:us,gac:com?c={api_key}&d1=2017-08-01&d2=2017-08-08'
data = requests.get(url).json()
print(data)

Or using our package:

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

With end date:

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

Using Requests:

const axios = require('axios');
(async () => {
    const api_key = 'YOUR_API_KEY'
    const response = await axios.get(`https://api.tradingeconomics.com/markets/historical/aapl:us,gac:com?c=${api_key}&d1=2017-08-01&d2=2017-08-08`)
    console.log(response.data)
})()

Or using our package:

data = te.getHistoricalMarkets(symbol= ['aapl:us','gac:com'], start_date = '2017-08-01').then(function(data){
  console.log(data)     
});

With end date:

data = te.getHistoricalMarkets(symbol= ['aapl:us','gac:com'], start_date = '2017-08-01',
 end_date = '2017-08-08').then(function(data){
  console.log(data)     
});

Using Requests:

new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/markets/historical/aapl:us,gac:com?c=your_api_key&d1=2017-08-01");

With end date:

new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/markets/historical/aapl:us,gac:com?c=your_api_key&d1=2017-08-01&d2=2017-08-08");

/markets/historical/{symbols}?c=Your_api_key&d1=yyyy-mm-dd&d2=yyyy-mm-dd

SymbolDateOpenHighLowClose
AAPL:US12/07/2023189.6800191.7000188.4700189.8200
GAC:COM11/07/20231675.00001675.00001675.00001675.0000
AAPL:US11/07/2023189.1600189.3000186.6000188.0800

/markets/historical/{symbols}?c=Your_api_key&d1=yyyy-mm-dd&d2=yyyy-mm-dd?f=json

[{"Symbol":"AAPL:US","Date":"10/10/2023","Open":178.1000,"High":179.7200,"Low":177.9500,"Close":178.3900},{"Symbol":"GAC:COM","Date":"10/10/2023","Open":1955.0000,"High":1980.0000,"Low":1930.0000,"Close":1955.0000},{"Symbol":"GAC:COM","Date":"09/10/2023","Open":1955.0000,"High":1980.0000,"Low":1930.0000,"Close":1955.0000}]

/markets/historical/{symbols}?c=Your_api_key&d1=yyyy-mm-dd&d2=yyyy-mm-dd?f=csv

Symbol,Date,Open,High,Low,Close
AAPL:US,10/10/2023,178.1000,179.7200,177.9500,178.3900
GAC:COM,10/10/2023,1955.0000,1980.0000,1930.0000,1955.0000
GAC:COM,09/10/2023,1955.0000,1980.0000,1930.0000,1955.0000

/markets/historical/{symbols}?c=Your_api_key&d1=yyyy-mm-dd&d2=yyyy-mm-dd?f=xml

<ArrayOfMarkets.HistoricalMarketsItem xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/APILib.DB">
<Markets.HistoricalMarketsItem>
<Close>178.3900</Close>
<Date>10/10/2023</Date>
<High>179.7200</High>
<Low>177.9500</Low>
<Open>178.1000</Open>
<Symbol>AAPL:US</Symbol>
</Markets.HistoricalMarketsItem>
<Markets.HistoricalMarketsItem>
<Close>1955.0000</Close>
<Date>10/10/2023</Date>
<High>1980.0000</High>
<Low>1930.0000</Low>
<Open>1955.0000</Open>
<Symbol>GAC:COM</Symbol>
</Markets.HistoricalMarketsItem>
<Markets.HistoricalMarketsItem>
<Close>1955.0000</Close>
<Date>09/10/2023</Date>
<High>1980.0000</High>
<Low>1930.0000</Low>
<Open>1955.0000</Open>
<Symbol>GAC:COM</Symbol>
</Markets.HistoricalMarketsItem>
</ArrayOfMarkets.HistoricalMarketsItem>

Response fields

FieldTypeDescriptionExample
SymbolstringUnique symbol used by Trading Economics“AAPL:US”
DatestringRelease time and date in UTC“13/04/2023”
OpennumberOpen value161.6300
HighnumberHigh value165.6186
LownumberLow value161.4200
ClosenumberClose value165.5099