# Historical Exchange Rates

Returns exchange rates for a specific date. Generally, we provide data going back to 1999.

Request Method: GET
Request URL: https://api.fxapi.com/v1/historical

# Request Parameters

Parameter Type Mandatory Description
apikey string ️ Your API Key
date string ️ Date to retrieve historical rates from (format: 2021-12-31)
Must be at least one day in the past and not before 1999-01-01, otherwise the request fails with a 422 validation error
Not required when you send dates
dates string Instead of date: up to 31 dates, comma-separated (2022-01-31,2022-02-28) or as dates[]=2022-01-31&dates[]=2022-02-28
Not together with date, see several dates
base_currency string The base currency to which all results are behaving relative to
By default all values are based on USD
currencies string A list of comma-separated currency codes which you want to get (EUR,USD,CAD)
The array form currencies[]=EUR&currencies[]=USD is also accepted
By default all available currencies will be shown
type string Filter the returned currencies by type
Possible Values: fiat, metal, crypto
By default currencies of all types are returned
shape string default or compact
With compact every rate is a plain value ("EUR": 0.918456) instead of a code/value object
precision integer Round every value to this many decimals (0 to 10)
By default values carry up to 10 decimals (10 significant digits below 0.1)
inverse boolean true adds inverse to every rate: the value of one unit of the currency in the base currency (1 / value)
Not together with shape=compact
format string json (default), csv or xlsx. The CSV has one row per currency (and date): datetime,base_currency,currency,value, plus inverse with inverse=true
xlsx gives the same table as an Excel workbook, see Excel downloads (opens new window)

These options work as on the latest (opens new window) endpoint (without include=change).

# Sample Response

The API response comes in easy-to-read JSON format and contains the end-of-day data for the provided date parameter for all currencies. meta holds last_updated_at, the base_currency of the values and the requested date.

{
    "meta": {
        "last_updated_at": "2022-01-01T23:59:59Z",
        "base_currency": "USD",
        "date": "2022-01-01"
    },
    "data": {
        "AED": {
            "code": "AED",
            "value": 3.67306
        },
        "AFN": {
            "code": "AFN",
            "value": 91.80254
        },
        "ALL": {
            "code": "ALL",
            "value": 108.22904
        },
        "AMD": {
            "code": "AMD",
            "value": 480.41659
        },
        "...": "150+ more currencies"
    }
}

# Several dates in one request

With dates instead of date you get up to 31 days in one response. data is then keyed by date, oldest first, and each date is answered once. meta holds the base_currency and the dates answered.

Every date costs one request of your quota, as it would on its own; the X-Cost response header tells you how many were counted (here 2).

curl -G https://api.fxapi.com/v1/historical \
    -d dates=2022-01-31,2022-02-28 \
    -d currencies=EUR,GBP \
    -d shape=compact \
    -H "apikey: YOUR-API-KEY"
{
    "meta": {
        "base_currency": "USD",
        "dates": ["2022-01-31", "2022-02-28"]
    },
    "data": {
        "2022-01-31": {
            "EUR": 0.890103,
            "GBP": 0.743712
        },
        "2022-02-28": {
            "EUR": 0.891437,
            "GBP": 0.745601
        }
    }
}

With format=csv the dates follow each other in one table:

datetime,base_currency,currency,value
2022-01-31T23:59:59Z,USD,EUR,0.890103
2022-01-31T23:59:59Z,USD,GBP,0.743712
2022-02-28T23:59:59Z,USD,EUR,0.891437
2022-02-28T23:59:59Z,USD,GBP,0.745601