Historical
The historical endpoint contains a time series with fields such as country, category, datetime, close, frequency, historicalDataSymbol, lastupdate, and observed value. It allows one to check the evolution of key indicators over time.
By country and indicator
Using Requests:
import requests
api_key = 'YOUR_API_KEY'
url = f'https://api.tradingeconomics.com/historical/country/mexico/indicator/gdp?c={api_key}'
data = requests.get(url).json()
print(data)
Or using our package:
import tradingeconomics as te
te.login('your_api_key')
te.getHistoricalData(country='mexico', indicator='gdp')
With multi countries and indicators:
te.getHistoricalData(country=['mexico', 'sweden'], indicator=['gdp','population'],
initDate='2015-01-01')
Using Requests:
const axios = require('axios');
(async () => {
const api_key = 'YOUR_API_KEY'
const response = await axios.get(`https://api.tradingeconomics.com/historical/country/mexico/indicator/gdp?c=${api_key}`)
console.log(response.data)
})()
Or using our package:
const te = require('tradingeconomics');
te.login('your_api_key');
data = te.getHistoricalData(country = 'mexico', indicator = 'gdp').then(function(data){
console.log(data)
});
With multi countries and indicators:
data = te.getHistoricalData(country = ['mexico','sweden'], indicator = ['gdp','population'],
start_date = '2015-01-01').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/historical/country/mexico/indicator/gdp?c=guest:guest"))
{
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 countries and indicators:
new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/historical/country/mexico,sweden/indicator/gdp,population/2015-01-01?c=guest:guest");
The response data format can be configured by appending the &f= parameter to the URL request.
/historical/country/{country}/indicator/{indicator}
Country | Category | DateTime | Close | Frequency | HistoricalDataSymbol | LastUpdate |
---|---|---|---|---|---|---|
Mexico | GDP | 12/31/2022 12:00:00 AM | 1414.1900 | Yearly | WGDPMEXI | 6/30/2023 3:54:00 PM |
Mexico | Population | 12/31/2022 12:00:00 AM | 129.0000 | Yearly | MEX SP.POP.TOTL | 5/30/2023 6:48:00 PM |
Sweden | GDP | 12/31/2022 12:00:00 AM | 585.9400 | Yearly | WGDPSWED | 6/30/2023 3:55:00 PM |
/historical/country/{country}/indicator/{indicator}?f=json
[{"Country":"Mexico","Category":"GDP","DateTime":"2020-12-31T00:00:00","Value":1090.5100,"Frequency":"Yearly","HistoricalDataSymbol":"WGDPMEXI","LastUpdate":"2023-06-30T15:54:00"},{"Country":"Mexico","Category":"GDP","DateTime":"2021-12-31T00:00:00","Value":1272.8400,"Frequency":"Yearly","HistoricalDataSymbol":"WGDPMEXI","LastUpdate":"2022-12-30T12:46:00"},{"Country":"Mexico","Category":"GDP","DateTime":"2022-12-31T00:00:00","Value":1414.1900,"Frequency":"Yearly","HistoricalDataSymbol":"WGDPMEXI","LastUpdate":"2023-06-30T15:54:00"}]
/historical/country/{country}/indicator/{indicator}?f=csv
Country,Category,DateTime,Close,Frequency,HistoricalDataSymbol,LastUpdate
Mexico,GDP,12/31/2020 12:00:00 AM,1090.5100,Yearly,WGDPMEXI,6/30/2023 3:54:00 PM
Mexico,GDP,12/31/2021 12:00:00 AM,1272.8400,Yearly,WGDPMEXI,12/30/2022 12:46:00 PM
Mexico,GDP,12/31/2022 12:00:00 AM,1414.1900,Yearly,WGDPMEXI,6/30/2023 3:54:00 PM
/historical/country/{country}/indicator/{indicator}?f=xml
<ArrayOfHistoricalIndicator xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/API.Models">
<HistoricalIndicator>
<Category>GDP</Category>
<Country>Mexico</Country>
<DateTime>2020-12-31T00:00:00</DateTime>
<Frequency>Yearly</Frequency>
<HistoricalDataSymbol>WGDPMEXI</HistoricalDataSymbol>
<LastUpdate>2023-06-30T15:54:00</LastUpdate>
<Value>1090.5100</Value>
</HistoricalIndicator>
<HistoricalIndicator>
<Category>GDP</Category>
<Country>Mexico</Country>
<DateTime>2021-12-31T00:00:00</DateTime>
<Frequency>Yearly</Frequency>
<HistoricalDataSymbol>WGDPMEXI</HistoricalDataSymbol>
<LastUpdate>2022-12-30T12:46:00</LastUpdate>
<Value>1272.8400</Value>
</HistoricalIndicator>
<HistoricalIndicator>
<Category>GDP</Category>
<Country>Mexico</Country>
<DateTime>2022-12-31T00:00:00</DateTime>
<Frequency>Yearly</Frequency>
<HistoricalDataSymbol>WGDPMEXI</HistoricalDataSymbol>
<LastUpdate>2023-06-30T15:54:00</LastUpdate>
<Value>1414.1900</Value>
</HistoricalIndicator>
</ArrayOfHistoricalIndicator>
By country, indicator and date
Using Requests:
import requests
api_key = 'YOUR_API_KEY'
url = f'https://api.tradingeconomics.com/historical/country/mexico,sweden/indicator/gdp,population/2015-01-01/2015-12-31?c={api_key}'
data = requests.get(url).json()
print(data)
Or using our package:
te.getHistoricalData(country=['mexico', 'sweden'], indicator=['gdp','population'],
initDate='2015-01-01', endDate='2015-12-31')
Using Requests:
const axios = require('axios');
(async () => {
const api_key = 'YOUR_API_KEY'
const response = await axios.get(`https://api.tradingeconomics.com/historical/country/mexico,sweden/indicator/gdp,population/2015-01-01/2015-12-31?c=${api_key}`)
console.log(response.data)
})()
Or using our package:
data = te.getHistoricalData(country = ['mexico','sweden'], indicator = ['gdp','population'],
start_date = '2015-01-01', end_date = '2015-12-31').then(function(data){
console.log(data)
});
Using Requests:
new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/historical/country/mexico,sweden/indicator/gdp,population/2015-01-01/2015-12-31?c=guest:guest");
/historical/country/{countries}/indicator/{indicators}/{yyyy-mm-dd}/{yyyy-mm-dd}
Country | Category | DateTime | Close | Frequency | HistoricalDataSymbol | LastUpdate |
---|---|---|---|---|---|---|
Mexico | GDP | 12/31/2022 12:00:00 AM | 1414.1900 | Yearly | WGDPMEXI | 6/30/2023 3:54:00 PM |
Mexico | Population | 12/31/2022 12:00:00 AM | 129.0000 | Yearly | MEX SP.POP.TOTL | 5/30/2023 6:48:00 PM |
Sweden | GDP | 12/31/2022 12:00:00 AM | 585.9400 | Yearly | WGDPSWED | 6/30/2023 3:55:00 PM |
/historical/country/{countries}/indicator/{indicators}/{yyyy-mm-dd}/{yyyy-mm-dd}?f=json
[{"Country":"Mexico","Category":"GDP","DateTime":"2022-12-31T00:00:00","Value":1414.1900,"Frequency":"Yearly","HistoricalDataSymbol":"WGDPMEXI","LastUpdate":"2023-06-30T15:54:00"},{"Country":"Mexico","Category":"Population","DateTime":"2022-12-31T00:00:00","Value":129.0000,"Frequency":"Yearly","HistoricalDataSymbol":"MEX SP.POP.TOTL","LastUpdate":"2023-05-30T18:48:00"},{"Country":"Sweden","Category":"GDP","DateTime":"2022-12-31T00:00:00","Value":585.9400,"Frequency":"Yearly","HistoricalDataSymbol":"WGDPSWED","LastUpdate":"2023-06-30T15:55:00"}]
/historical/country/{countries}/indicator/{indicators}/{yyyy-mm-dd}/{yyyy-mm-dd}?f=csv
Country,Category,DateTime,Close,Frequency,HistoricalDataSymbol,LastUpdate
Mexico,GDP,12/31/2022 12:00:00 AM,1414.1900,Yearly,WGDPMEXI,6/30/2023 3:54:00 PM
Mexico,Population,12/31/2022 12:00:00 AM,129.0000,Yearly,MEX SP.POP.TOTL,5/30/2023 6:48:00 PM
Sweden,GDP,12/31/2022 12:00:00 AM,585.9400,Yearly,WGDPSWED,6/30/2023 3:55:00 PM
/historical/country/{countries}/indicator/{indicators}/{yyyy-mm-dd}/{yyyy-mm-dd}?f=xml
<ArrayOfHistoricalIndicator xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/API.Models">
<HistoricalIndicator>
<Category>GDP</Category>
<Country>Mexico</Country>
<DateTime>2022-12-31T00:00:00</DateTime>
<Frequency>Yearly</Frequency>
<HistoricalDataSymbol>WGDPMEXI</HistoricalDataSymbol>
<LastUpdate>2023-06-30T15:54:00</LastUpdate>
<Value>1414.1900</Value>
</HistoricalIndicator>
<HistoricalIndicator>
<Category>Population</Category>
<Country>Mexico</Country>
<DateTime>2022-12-31T00:00:00</DateTime>
<Frequency>Yearly</Frequency>
<HistoricalDataSymbol>MEX SP.POP.TOTL</HistoricalDataSymbol>
<LastUpdate>2023-05-30T18:48:00</LastUpdate>
<Value>129.0000</Value>
</HistoricalIndicator>
<HistoricalIndicator>
<Category>GDP</Category>
<Country>Sweden</Country>
<DateTime>2022-12-31T00:00:00</DateTime>
<Frequency>Yearly</Frequency>
<HistoricalDataSymbol>WGDPSWED</HistoricalDataSymbol>
<LastUpdate>2023-06-30T15:55:00</LastUpdate>
<Value>585.9400</Value>
</HistoricalIndicator>
</ArrayOfHistoricalIndicator>
By ticker
Using Requests:
import requests
api_key = 'YOUR_API_KEY'
url = f'https://api.tradingeconomics.com/historical/ticker/USURTOT/2015-03-01?c={api_key}'
data = requests.get(url).json()
print(data)
Or using our package:
te.getHistoricalByTicker(ticker = 'USURTOT', start_date = '2015-03-01')
Using Requests:
const axios = require('axios');
(async () => {
const api_key = 'YOUR_API_KEY'
const response = await axios.get(`https://api.tradingeconomics.com/historical/ticker/USURTOT/2015-03-01?c=${api_key}`)
console.log(response.data)
})()
Or using our package:
data = te.getHistoricalData(ticker = 'usurtot', start_date = '2015-03-01' ).then(function(data){
console.log(data)
});
Using Requests:
new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/historical/ticker/USURTOT/2015-03-01?c=guest:guest");
/historical/ticker/{ticker}/{yyyy-mm-dd}
Country | Category | DateTime | Close | Frequency | HistoricalDataSymbol | LastUpdate |
---|---|---|---|---|---|---|
United States | Unemployment Rate | 4/30/2023 12:00:00 AM | 3.4000 | Monthly | USURTOT | 6/2/2023 12:30:00 PM |
United States | Unemployment Rate | 5/31/2023 12:00:00 AM | 3.7000 | Monthly | USURTOT | 7/7/2023 12:30:00 PM |
United States | Unemployment Rate | 6/30/2023 12:00:00 AM | 3.6000 | Monthly | USURTOT | 7/7/2023 12:30:00 PM |
/historical/ticker/{ticker}/{yyyy-mm-dd}?f=json
[{"Country":"United States","Category":"Unemployment Rate","DateTime":"2023-07-31T00:00:00","Value":3.5000,"Frequency":"Monthly","HistoricalDataSymbol":"USURTOT","LastUpdate":"2023-09-01T12:30:00"},{"Country":"United States","Category":"Unemployment Rate","DateTime":"2023-08-31T00:00:00","Value":3.8000,"Frequency":"Monthly","HistoricalDataSymbol":"USURTOT","LastUpdate":"2023-10-06T12:30:00"},{"Country":"United States","Category":"Unemployment Rate","DateTime":"2023-09-30T00:00:00","Value":3.8000,"Frequency":"Monthly","HistoricalDataSymbol":"USURTOT","LastUpdate":"2023-10-06T12:30:00"}]
/historical/ticker/{ticker}/{yyyy-mm-dd}?f=csv
Country,Category,DateTime,Close,Frequency,HistoricalDataSymbol,LastUpdate
United States,Unemployment Rate,7/31/2023 12:00:00 AM,3.5000,Monthly,USURTOT,9/1/2023 12:30:00 PM
United States,Unemployment Rate,8/31/2023 12:00:00 AM,3.8000,Monthly,USURTOT,10/6/2023 12:30:00 PM
United States,Unemployment Rate,9/30/2023 12:00:00 AM,3.8000,Monthly,USURTOT,10/6/2023 12:30:00 PM
/historical/ticker/{ticker}/{yyyy-mm-dd}?f=xml
<ArrayOfHistoricalIndicator xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/API.Models">
<HistoricalIndicator>
<Category>Unemployment Rate</Category>
<Country>United States</Country>
<DateTime>2023-07-31T00:00:00</DateTime>
<Frequency>Monthly</Frequency>
<HistoricalDataSymbol>USURTOT</HistoricalDataSymbol>
<LastUpdate>2023-09-01T12:30:00</LastUpdate>
<Value>3.5000</Value>
</HistoricalIndicator>
<HistoricalIndicator>
<Category>Unemployment Rate</Category>
<Country>United States</Country>
<DateTime>2023-08-31T00:00:00</DateTime>
<Frequency>Monthly</Frequency>
<HistoricalDataSymbol>USURTOT</HistoricalDataSymbol>
<LastUpdate>2023-10-06T12:30:00</LastUpdate>
<Value>3.8000</Value>
</HistoricalIndicator>
<HistoricalIndicator>
<Category>Unemployment Rate</Category>
<Country>United States</Country>
<DateTime>2023-09-30T00:00:00</DateTime>
<Frequency>Monthly</Frequency>
<HistoricalDataSymbol>USURTOT</HistoricalDataSymbol>
<LastUpdate>2023-10-06T12:30:00</LastUpdate>
<Value>3.8000</Value>
</HistoricalIndicator>
</ArrayOfHistoricalIndicator>
Latest updates
Using Requests:
import requests
api_key = 'YOUR_API_KEY'
url = f'https://api.tradingeconomics.com/historical/ticker/USURTOT/2015-03-01?c={api_key}'
data = requests.get(url).json()
print(data)
Or using our package:
te.getHistoricalUpdates()
Using Requests:
const axios = require('axios');
(async () => {
const api_key = 'YOUR_API_KEY'
const response = await axios.get(`https://api.tradingeconomics.com/historical/ticker/USURTOT/2015-03-01?c=${api_key}`)
console.log(response.data)
})()
Or using our package:
data = te.getHistoricalUpdates().then(function(data){
console.log(data)
});
Using Requests:
new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/historical/updates?c=guest:guest");
Country | Category | HistoricalDataSymbol | LastUpdate |
---|---|---|---|
United States | Consumer Credit | UNITEDSTACONCRE | 7/10/2023 7:01:00 PM |
Nicaragua | Foreign Direct Investment | NICARAGUAFORDIRINV | 7/10/2023 5:17:00 PM |
Dominican Republic | External Debt to GDP | DOMEDTG | 7/10/2023 4:29:00 PM |
[{"Country":"Austria","Category":"Capital Flows","HistoricalDataSymbol":"AUSTRIACAPFLO","LastUpdate":"2023-10-09T16:39:00"},{"Country":"Tanzania","Category":"Inflation Rate","HistoricalDataSymbol":"TANZANIAIR","LastUpdate":"2023-10-09T16:28:00"},{"Country":"Uganda","Category":"Deposit Interest Rate","HistoricalDataSymbol":"UGAFRINRDPST","LastUpdate":"2023-10-09T16:06:00"}]
Country,Category,HistoricalDataSymbol,LastUpdate
Austria,Capital Flows,AUSTRIACAPFLO,10/9/2023 4:39:00 PM
Tanzania,Inflation Rate,TANZANIAIR,10/9/2023 4:28:00 PM
Uganda,Deposit Interest Rate,UGAFRINRDPST,10/9/2023 4:06:00 PM
<ArrayOfUpdatedItem xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/API.Models">
<UpdatedItem>
<Category>Capital Flows</Category>
<Country>Austria</Country>
<HistoricalDataSymbol>AUSTRIACAPFLO</HistoricalDataSymbol>
<LastUpdate>2023-10-09T16:39:00</LastUpdate>
</UpdatedItem>
<UpdatedItem>
<Category>Inflation Rate</Category>
<Country>Tanzania</Country>
<HistoricalDataSymbol>TANZANIAIR</HistoricalDataSymbol>
<LastUpdate>2023-10-09T16:28:00</LastUpdate>
</UpdatedItem>
<UpdatedItem>
<Category>Deposit Interest Rate</Category>
<Country>Uganda</Country>
<HistoricalDataSymbol>UGAFRINRDPST</HistoricalDataSymbol>
<LastUpdate>2023-10-09T16:06:00</LastUpdate>
</UpdatedItem>
</ArrayOfUpdatedItem>
Response fields
Field | Type | Description | Example |
---|---|---|---|
Country | string | Country name | “Mexico” |
Category | string | Indicator category name | “GDP” |
Date Time | string | Release time and date in UTC | “2021-12-31T00:00:00” |
Close | number | Value * | 1272.8400 |
Frequency | string | Frequency of the indicator | “Yearly” |
HistoricalDataSymbol | string | Unique symbol used by TradingEconomics | “WGDPMEXI” |
LastUpdate | string | Time when new data was inserted or changed | “2022-12-30T12:46:00” |
Fields in ‘Latest updates’
Field | Type | Description | Example |
---|---|---|---|
Country | string | Country name | “Mexico” |
Category | string | Indicator category name | “GDP” |
HistoricalDataSymbol | string | Unique symbol used by TradingEconomics | “WGDPMEXI” |
LastUpdate | string | Time when new data was inserted or changed | “2022-12-30T12:46:00” |
*Python package response field returns Value instead of ‘Close’.