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 series code
Using Requests:
import requests
api_key = 'YOUR_API_KEY'
url = f'https://api.tradingeconomics.com/worldbank/historical?s=usa.fr.inr.rinr&c={api_key}'
data = requests.get(url).json()
print(data)
Or using our package:
import tradingeconomics as te
te.login('your_api_key')
te.getWBHistorical(series_code = 'usa.fr.inr.rinr')
With multi series codes:
te.getWBHistorical(series_code = 'usa.fr.inr.rinr, prt.ag.con.fert.pt.zs')
Using Requests:
const axios = require('axios');
(async () => {
const api_key = 'YOUR_API_KEY'
const response = await axios.get(`https://api.tradingeconomics.com/worldbank/historical?s=usa.fr.inr.rinr&c=${api_key}`)
console.log(response.data)
})()
Or using our package:
const te = require('tradingeconomics');
te.login('your_api_key');
data = te.getworldbankHistorical(series_code = 'usa.fr.inr.rinr').then(function(data){
console.log(data)
});
With multi series codes:
data = te.getworldbankHistorical(series_code = 'usa.fr.inr.rinr, prt.ag.con.fert.pt.zs')
Using Requests:
using (var httpClient = new HttpClient())
{
using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/worldbank/historical?s=usa.fr.inr.rinr&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 series codes:
using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/worldbank/historical?s=usa.fr.inr.rinr,prt.ag.con.fert.pt.zs&c=your_api_key"))
The response data format can be configured by appending the &f= parameter to the URL request.
/worldbank/historical?c=guest:guest&s=(series_code)
symbol | date | value |
---|---|---|
usa.fr.inr.rinr | 6/15/1961 12:00:00 AM | 3.10788 |
usa.fr.inr.rinr | 6/15/1962 12:00:00 AM | 3.21535 |
usa.fr.inr.rinr | 6/15/1963 12:00:00 AM | 3.37488 |
/worldbank/historical?c=guest:guest&s=(series_code)&f=json
[{"symbol":"usa.fr.inr.rinr","date":"1961-06-15T00:00:00","value":3.10788},{"symbol":"usa.fr.inr.rinr","date":"1962-06-15T00:00:00","value":3.21535},{"symbol":"usa.fr.inr.rinr","date":"1963-06-15T00:00:00","value":3.37488}]
/worldbank/historical?c=guest:guest&s=(series_code)&f=csv
symbol,date,value
usa.fr.inr.rinr,6/15/1961 12:00:00 AM,3.10788
usa.fr.inr.rinr,6/15/1962 12:00:00 AM,3.21535
usa.fr.inr.rinr,6/15/1963 12:00:00 AM,3.37488
/worldbank/historical?c=guest:guest&s=(series_code)&f=xml
<ArrayOfWorldbankHistorical xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/API.Models">
<WorldbankHistorical>
<date>1961-06-15T00:00:00</date>
<symbol>usa.fr.inr.rinr</symbol>
<value>3.10788</value>
</WorldbankHistorical>
<WorldbankHistorical>
<date>1962-06-15T00:00:00</date>
<symbol>usa.fr.inr.rinr</symbol>
<value>3.21535</value>
</WorldbankHistorical>
<WorldbankHistorical>
<date>1963-06-15T00:00:00</date>
<symbol>usa.fr.inr.rinr</symbol>
<value>3.37488</value>
</WorldbankHistorical>
</ArrayOfWorldbankHistorical>
Response fields
Field | Type | Description | Example |
---|---|---|---|
Symbol | string | Unique symbol used by Trading Economics | “usa.fr.inr.rinr” |
Date | string | Release time and date in UTC | “1961-06-15T00:00:00” |
Value | number | Released value | 3.10788 |