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/fred/historical/RACEDISPARITY005007,2020RATIO002013?c={api_key}'
data = requests.get(url).json()
print(data)
Or using our package:
import tradingeconomics as te
te.login('your_api_key')
te.getFedRHistorical(symbol = 'racedisparity005007')
With multi symbols
te.getFedRHistorical(symbol = ['racedisparity005007', '2020ratio002013'])
Using Requests:
const axios = require('axios');
(async () => {
const api_key = 'YOUR_API_KEY'
const response = await axios.get(`https://api.tradingeconomics.com/fred/historical/RACEDISPARITY005007,2020RATIO002013?c=${api_key}`)
console.log(response.data)
})()
Or using our package:
const te = require('tradingeconomics');
te.login('your_api_key');
data = te.getFred(historical_symbol = 'RACEDISPARITY005007').then(function(data){
console.log(data)
});
With multi symbols:
data = te.getFred(historical_symbol = ['racedisparity005007',
'2020ratio002013']).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/fred/historical/RACEDISPARITY005007?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/fred/historical/RACEDISPARITY005007,2020RATIO002013?c=your_api_key"))
The response data format can be configured by appending the &f= parameter to the URL request.
symbol | date | value |
---|---|---|
racedisparity005007 | 1/1/2009 12:00:00 AM | 33.6030 |
2020ratio002013 | 1/1/2010 12:00:00 AM | 9.5066 |
racedisparity005007 | 1/1/2010 12:00:00 AM | 36.2968 |
/fred/historical/{symbols}?f=json
[{"symbol":"racedisparity005007","date":"2009-01-01T00:00:00","value":33.6030},{"symbol":"2020ratio002013","date":"2010-01-01T00:00:00","value":9.5066},{"symbol":"racedisparity005007","date":"2010-01-01T00:00:00","value":36.2968}]
/fred/historical/{symbols}?f=csv
symbol,date,value
racedisparity005007,1/1/2009 12:00:00 AM,33.6030
2020ratio002013,1/1/2010 12:00:00 AM,9.5066
racedisparity005007,1/1/2010 12:00:00 AM,36.2968
/fred/historical/{symbols}?f=xml
<ArrayOfFredHistorical xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/API.Models">
<FredHistorical>
<date>2009-01-01T00:00:00</date>
<symbol>racedisparity005007</symbol>
<value>33.6030</value>
</FredHistorical>
<FredHistorical>
<date>2010-01-01T00:00:00</date>
<symbol>2020ratio002013</symbol>
<value>9.5066</value>
</FredHistorical>
<FredHistorical>
<date>2010-01-01T00:00:00</date>
<symbol>racedisparity005007</symbol>
<value>36.2968</value>
</FredHistorical>
</ArrayOfFredHistorical>
By symbol and a date
It’s possible to use multiple symbols.
Using Requests:
import requests
api_key = 'YOUR_API_KEY'
url = f'https://api.tradingeconomics.com/fred/historical/BAMLC0A1CAAAEY?d1=2017-05-01&d2=2019-01-01&c={api_key}'
data = requests.get(url).json()
print(data)
Or using our package:
te.getFedRHistorical(symbol = 'BAMLC0A1CAAAEY', initDate = '2017-05-01')
With end date:
te.getFedRHistorical(symbol = 'BAMLC0A1CAAAEY', initDate = '2017-05-01',
endDate = '2019-01-01')
Using Requests:
const axios = require('axios');
(async () => {
const api_key = 'YOUR_API_KEY'
const response = await axios.get(`https://api.tradingeconomics.com/fred/historical/BAMLC0A1CAAAEY?d1=2017-05-01&d2=2019-01-01&c=${api_key}`)
console.log(response.data)
})()
Or using our package:
data = te.getFred(historical_symbol = 'BAMLC0A1CAAAEY', start_date = '2017-05-01').then(function(data){
console.log(data)
});
With end date:
data = te.getFred(historical_symbol = 'BAMLC0A1CAAAEY', start_date = '2017-05-01',
end_date = '2019-01-01').then(function(data){
console.log(data)
});
Using Requests:
using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/fred/historical/BAMLC0A1CAAAEY?d1=2017-05-01&c=your_api_key"))
With end date:
using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/fred/historical/BAMLC0A1CAAAEY?d1=2017-05-01&d2=2019-01-01&c=your_api_key"))
/fred/historical/{symbols}?d1={yyyy-mm-dd}&d2={yyyy-mm-dd}
symbol | date | value |
---|---|---|
bamlc0a1caaaey | 5/1/2017 12:00:00 AM | 3.0300 |
bamlc0a1caaaey | 5/2/2017 12:00:00 AM | 2.9900 |
bamlc0a1caaaey | 5/3/2017 12:00:00 AM | 2.9900 |
/fred/historical/{symbols}?d1={yyyy-mm-dd}&d2={yyyy-mm-dd}&f=json
[{"symbol":"bamlc0a1caaaey","date":"2017-05-01T00:00:00","value":3.0300},{"symbol":"bamlc0a1caaaey","date":"2017-05-02T00:00:00","value":2.9900},{"symbol":"bamlc0a1caaaey","date":"2017-05-03T00:00:00","value":2.9900}]
/fred/historical/{symbols}?d1={yyyy-mm-dd}&d2={yyyy-mm-dd}&f=csv
symbol,date,value
bamlc0a1caaaey,5/1/2017 12:00:00 AM,3.0300
bamlc0a1caaaey,5/2/2017 12:00:00 AM,2.9900
bamlc0a1caaaey,5/3/2017 12:00:00 AM,2.9900
/fred/historical/{symbols}?d1={yyyy-mm-dd}&d2={yyyy-mm-dd}&f=xml
<ArrayOfFredHistorical xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/API.Models">
<FredHistorical>
<date>2017-05-01T00:00:00</date>
<symbol>bamlc0a1caaaey</symbol>
<value>3.0300</value>
</FredHistorical>
<FredHistorical>
<date>2017-05-02T00:00:00</date>
<symbol>bamlc0a1caaaey</symbol>
<value>2.9900</value>
</FredHistorical>
<FredHistorical>
<date>2017-05-03T00:00:00</date>
<symbol>bamlc0a1caaaey</symbol>
<value>2.9900</value>
</FredHistorical>
</ArrayOfFredHistorical>
Response fields
Field | Type | Description | Example |
---|---|---|---|
Symbol | string | Unique symbol used by Trading Economics | “racedisparity005007” |
Date | string | Release time and date in UTC | “2009-01-01T00:00:00” |
Value | number | Released value | 33.6030 |