Historical Forex Data
fxdata provides a simple API to access historical foreign exchange rates in USD based on statistical data provided by the Bank for International Settlements (BIS).
About fxdata.foorilla.com
When we launched a public salary database on our job sites in 2021 (see https://ai-jobs.net/salaries/ or https://infosec-jobs.com/salaries/) with dozens of different currencies, we wanted to add a reference column to the dataset by converting all non-USD salaries into USD for better comparability.
For this we needed historical daily data to calculate a yearly average USD rate for these currencies and we didn't want to go with complicated APIs or paid data providers. As a result this project came into existence serving exactly this need.
We ended up building an API so anyone can use it for something similar and have a quick and simple way to access this kind of historical foreign exchange rate data with currently 82 areas covered by 63 currencies, of which some even date back to the 1950s.
Data source and updates
The data behind this API is being updated roughly once a week with the most recent CSV vertical file available on the BIS website, which depends on their release schedule.
Here are the links to the BIS statistics page (overview) and the original dataset (US dollar exchange rates, Daily data, CSV vertical).
- Statistics overview: https://www.bis.org/statistics
- US dollar exchange rates: https://www.bis.org/statistics/xrusd.htm
- Copyright and permissions: https://www.bis.org/terms_conditions.htm
fxdata API Documentation and functionality
Introduction
The root URL for the fxdata API web service is https://fxdata.foorilla.com/api/
Using the API web service doesn't require authentication but there is a rate limit of 100 requests per hour for anonymous clients. You can reach out to us via fxdata@foorilla.com if you have any special needs or require a higher request limit.
Data endpoints
List results support pagination (via the page
GET parameter) and always return a maximum of 200 items per page.
Areas
Get a list of all areas with their name, country code and attached currency code.
Endpoint: https://fxdata.foorilla.com/api/areas/ (GET, JSON)
Example:
$ curl https://fxdata.foorilla.com/api/areas/
Response:
{"count":81,"next":null,"previous":null,"results":[{"code":"AE","name":"United Arab Emirates","currency":"AED"},{"code":"AL","name":"Albania","currency":"ALL"},{"code":"AR","name":"Argentina","currency":"ARS"},{"code":"AT","name":"Austria","currency":"EUR"},...
Currencies
Get a list of all currencies with their currency code and name.
Endpoint: https://fxdata.foorilla.com/api/currencies/ (GET, JSON)
Example:
$ curl https://fxdata.foorilla.com/api/currencies/
Response:
{"count":62,"next":null,"previous":null,"results":[{"code":"AED","name":"UAE Dirham"},{"code":"ALL","name":"Albanian Lek"},{"code":"ARS","name":"Argentine Peso"},{"code":"AUD","name":"Australian Dollar"},...
Currency - yearly average
Get the yearly average USD rate for a specific currency calculated across all its rates for that year. This endpoint needs the currency code as a URL parameter and the following additional get parameter:
- yearly_average - the year to calculate the averate USD rate for (required)
Endpoint: https://fxdata.foorilla.com/api/currencies/<currency:required>/ (GET, JSON)
Example:
$ curl https://fxdata.foorilla.com/api/currencies/CHF/?yearly_average=2019
Response:
{"code":"CHF","name":"Swiss Franc","avg_year":"2019","avg_usdrate":"0.993719"}
USD rates
Get a list of all USD rates for all currencies with their date, currency code and USD rate decimal value. This endpoint also accepts the following GET parameters for filtering the results:
- currency - get results for a specific currency only (optional)
- date_max - get all rates for and before the given date (optional)
- date_min - get all rates for and after the given date (optional)
Endpoint: https://fxdata.foorilla.com/api/usdrates/ (GET, JSON)
Example:
$ curl https://fxdata.foorilla.com/api/usdrates/
Response:
{"count":639017,"next":"https://fxdata.foorilla.com/api/usdrates/?page=2","previous":null,"results":[{"id":639017,"date":"2021-07-05","currency":"ZAR","value":"14.226614"},{"id":639015,"date":"2021-07-05","currency":"USD","value":"1.000000"},{"id":639014,"date":"2021-07-05","currency":"UAH","value":"27.412100"},{"id":639013,"date":"2021-07-05","currency":"TRY","value":"8.670908"},...
Example (with parameters):
$ curl "https://fxdata.foorilla.com/api/usdrates/?currency=CHF&date_min=2015-01-13&date_max=2015-01-16"
Response:
{"count":4,"next":null,"previous":null,"results":[{"id":540887,"date":"2015-01-16","currency":"CHF","value":"0.874008"},{"id":540827,"date":"2015-01-15","currency":"CHF","value":"0.878032"},{"id":540765,"date":"2015-01-14","currency":"CHF","value":"1.019958"},{"id":540703,"date":"2015-01-13","currency":"CHF","value":"1.019352"}]}