Markets Historical

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.680000000000191.700000000000188.470000000000189.760000000000
GAC:COM11/07/20231675.0000000000001675.0000000000001675.0000000000001675.000000000000
AAPL:US11/07/2023189.160000000000189.300000000000186.600000000000188.080000000000

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

[{"Symbol":"AAPL:US","Date":"10/10/2023","Open":178.100000000000,"High":179.720000000000,"Low":177.950000000000,"Close":178.390000000000},{"Symbol":"GAC:COM","Date":"10/10/2023","Open":1955.000000000000,"High":1980.000000000000,"Low":1930.000000000000,"Close":1955.000000000000},{"Symbol":"GAC:COM","Date":"09/10/2023","Open":1955.000000000000,"High":1980.000000000000,"Low":1930.000000000000,"Close":1955.000000000000}]

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

Symbol,Date,Open,High,Low,Close
AAPL:US,10/10/2023,178.100000000000,179.720000000000,177.950000000000,178.390000000000
GAC:COM,10/10/2023,1955.000000000000,1980.000000000000,1930.000000000000,1955.000000000000
GAC:COM,09/10/2023,1955.000000000000,1980.000000000000,1930.000000000000,1955.000000000000

/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.390000000000</Close>
<Date>10/10/2023</Date>
<High>179.720000000000</High>
<Low>177.950000000000</Low>
<Open>178.100000000000</Open>
<Symbol>AAPL:US</Symbol>
</Markets.HistoricalMarketsItem>
<Markets.HistoricalMarketsItem>
<Close>1955.000000000000</Close>
<Date>10/10/2023</Date>
<High>1980.000000000000</High>
<Low>1930.000000000000</Low>
<Open>1955.000000000000</Open>
<Symbol>GAC:COM</Symbol>
</Markets.HistoricalMarketsItem>
<Markets.HistoricalMarketsItem>
<Close>1955.000000000000</Close>
<Date>09/10/2023</Date>
<High>1980.000000000000</High>
<Low>1930.000000000000</Low>
<Open>1955.000000000000</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.680000000000191.700000000000188.470000000000189.820000000000
GAC:COM11/07/20231675.0000000000001675.0000000000001675.0000000000001675.000000000000
AAPL:US11/07/2023189.160000000000189.300000000000186.600000000000188.080000000000

/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.100000000000,"High":179.720000000000,"Low":177.950000000000,"Close":178.390000000000},{"Symbol":"GAC:COM","Date":"10/10/2023","Open":1955.000000000000,"High":1980.000000000000,"Low":1930.000000000000,"Close":1955.000000000000},{"Symbol":"GAC:COM","Date":"09/10/2023","Open":1955.000000000000,"High":1980.000000000000,"Low":1930.000000000000,"Close":1955.000000000000}]

/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.100000000000,179.720000000000,177.950000000000,178.390000000000
GAC:COM,10/10/2023,1955.000000000000,1980.000000000000,1930.000000000000,1955.000000000000
GAC:COM,09/10/2023,1955.000000000000,1980.000000000000,1930.000000000000,1955.000000000000

/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.390000000000</Close>
<Date>10/10/2023</Date>
<High>179.720000000000</High>
<Low>177.950000000000</Low>
<Open>178.100000000000</Open>
<Symbol>AAPL:US</Symbol>
</Markets.HistoricalMarketsItem>
<Markets.HistoricalMarketsItem>
<Close>1955.000000000000</Close>
<Date>10/10/2023</Date>
<High>1980.000000000000</High>
<Low>1930.000000000000</Low>
<Open>1955.000000000000</Open>
<Symbol>GAC:COM</Symbol>
</Markets.HistoricalMarketsItem>
<Markets.HistoricalMarketsItem>
<Close>1955.000000000000</Close>
<Date>09/10/2023</Date>
<High>1980.000000000000</High>
<Low>1930.000000000000</Low>
<Open>1955.000000000000</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.63000
HighnumberHigh value165.61860
LownumberLow value161.42000
ClosenumberClose value165.50999