Exchangesrateapi API

With data from over 15 exchange rate sources, the Exchangesrateapi API provides real-time exchange rates for 170 currencies worldwide. It offers different tools for various needs, like checking the latest rates, converting currencies, and tracking fluctuations over time.

In this guide, you'll learn how the API works, find examples, and troubleshoot issues. Got questions? Just reach out, and we'll help you out!

Quickstart Tool

Short on time to delve into lengthy documentation? Fear not! Head over to the Dashboard section of your control panel, where you'll find our Quickstart tool ready and waiting. With just a click, you can test all API endpoints effortlessly.

Go to Quickstart Tool

Getting Started

Definitions

Definition Description
API Key A unique key assigned to each API account used to authenticate with the API.
Symbol Refers to the three-letter currency code of a given currency.
Base Currency The currency to which exchange rates are relative to. (If 1 USD = X EUR, USD is the base currency)
Target Currency The currency an amount is converted to. (If 1 USD = X EUR, EUR is the target currency)
Base URL Refers to URL which all API request endpoints and URLs are based on.

API Key

Your API Key is a special code used in the apiKey parameter of the API's URL. It's like a password that allows you to connect to and use the Exchangesrateapi API.

Base URL:

http://exchangesrateapi.com/api/

Append your API Key: Here is how to authenticate with the Exchangesrateapi API:

Run API Requesthttp://exchangesrateapi.com/api/latest
    ? apiKey = f2746121123b7e80c1b6581b615d8ecd

API Response

By default, exchange rates provided by the Exchangesrateapi API are in relation to EUR. All information is presented in standard JSON format, ensuring easy parsing with any programming language.

Example Response: Below, you'll find an example of an API response showcasing several commonly used world currencies. These rates are relative to the EUR currency and are timestamped at the precise moment they were collected.

{
    "timestamp": 1710405320,
    "base": "EUR",
    "date": "2024-03-14",
    "rates": {
        "AUD": 1.67123,
        "CAD": 1.47466,
        "CHF": 0.96131,
        "CNY": 7.81,
        "GBP": 0.85535,
        "JPY": 163.095,
        "USD": 1.08481,
    [...]
    }
}

When you request real-time exchange rates via the API, you'll receive the timestamp of data collection, the base currency code, the date, and the actual exchange rates.

Available Endpoints

The Exchangesrateapi API offers endpoints, each serving a unique function. Please be aware that the availability of specific API endpoints may vary depending on your subscription plan.

  • Latest rates endpointThis endpoint returns real-time exchange rate data for either all available currencies or a specific set of currencies.
  • Convert endpointThis endpoint enables the conversion of any amount from one currency to another.
  • Historical rates endpointThis endpoint provides historical exchange rate data for either all available currencies or a specific set of currencies.
  • Time-Series data endpointThis endpoint retrieves daily historical exchange rate data between two specified dates for either all available currencies or a specific set of currencies.
  • Fluctuation data endpointThis endpoint returns fluctuation data between two specified dates for either all available currencies or a specific set of currencies.

SSL Connection

All paid subscription plans offered on exchangesrateapi.com include 256-bit SSL encryption. To establish a secure connection to the API, simply utilize the https protocol.

Access-Control / CORS

Exchangesrateapi additionally supports Cross-Origin Resource Sharing (CORS) and Access-Control Headers, facilitating the utilization of the Exchangesrateapi API through Cross-Origin HTTP Requests.

Learn more about CORS »

Potential Errors

If a requested resource is unavailable or if an API call fails for any other reason, a HTTP error is returned. These errors always include an error code and a corresponding description.

Example Error: The following error is returned when your monthly API request volume has been exceeded.

{
  "statusCode": 403,
  "message": "You have exceeded your request limit",
  "error": "Forbidden"
}

Endpoints

Supported Symbols Endpoint

The Exchangesrateapi API provides a constantly updated endpoint that returns a list of all available currencies. To access this list, simply make a request to the API's symbols endpoint.

API Request:

Run API Requesthttp://exchangesrateapi.com/api/symbols
    ? apiKey = f2746121123b7e80c1b6581b615d8ecd

Request Parameters:

Parameter Description
apiKey [Required] Your API Key.

API Response:

{
  "symbols": {
    "AED": "United Arab Emirates Dirham",
    "AFN": "Afghan Afghani",
    "ALL": "Albanian Lek",
    "AMD": "Armenian Dram",
    [...]
    }
}

Response Objects:

Response Object Description
symbols This endpoint returns all supported currencies along with their respective three-letter currency codes and names.

Latest Rates Endpoint

Based on your subscription plan, the API's latest endpoint refreshes real-time exchange rate data at intervals of either 60 minutes, or realtime.

API Request:

Run API Requesthttp://exchangesrateapi.com/api/latest
    ? apiKey = f2746121123b7e80c1b6581b615d8ecd
    & base = USD
    & symbols = GBP,JPY,EUR

Request Parameters:

Parameter Description
apiKey [required] Your API Key.
base [optional] Enter the three-letter currency code of your preferred base currency.
symbols [optional] Enter a list of comma-separated currency codes to limit output currencies.

API Response:

{
    "timestamp": 1710409717,
    "base": "USD",
    "date": "2024-03-14",
    "rates": {
        "GBP": 0.78845,
        "JPY": 150.34,
        "EUR": 0.92187,
    }
}

Response Objects:

Response Object Description
timestamp Returns the exact date and time (UNIX time stamp) the given rates were collected.
base Returns the three-letter currency code of the base currency used for this request.
rates Returns exchange rate data for the currencies you have requested.

Historical Rates Endpoint

The Exchangesrateapi API allows access to historical rates for most currencies, reaching back to the year 1999. To retrieve historical rates, append a date in the format YYYY-MM-DD to the base URL when querying the API.

API Request:

Run API Requesthttp://exchangesrateapi.com/api/2023-12-12
    ? apiKey = f2746121123b7e80c1b6581b615d8ecd
    & base = EUR
    & symbols = USD

Request Parameters:

Parameter Description
YYYY-MM-DD [required] A date in the past for which historical rates are requested.
apiKey [required] Your API Key.
base [optional] Enter the three-letter currency code of your preferred base currency.
symbols [optional] Enter a list of comma-separated currency codes to limit output currencies.

API Response:

{
    "date": "2023-12-12",
    "timestamp": 1710424750,
    "base": "EUR",
    "rates": {
        "USD": 1.08,
    }
}

Response Objects:

Response Object Description
date Returns the date for which historical rates were requested.
timestamp Returns the exact date and time (UNIX time stamp) the given rates were collected.
base Returns the three-letter currency code of the base currency used for this request.
rates Returns exchange rate data for the currencies you have requested.

Specify Symbols

To minimize bandwidth usage, you can restrict the number of output currencies to a specific set of your preference on most API endpoints. Simply append the symbols parameter of the Exchangesrateapi API to your API request and assign it one or more comma-separated currency codes.

Example:

Run API Requesthttp://exchangesrateapi.com/api/latest
    ? apiKey = f2746121123b7e80c1b6581b615d8ecd
    & symbols = USD,CAD,JPY

The response from the API for the given request will only include data for the currencies USD, CAD, and JPY.

Changing base currency

If your subscription plan supports changing the base currency, you can specify the currency to which your output currency rates are relative by appending the base parameter to your API request URL and setting it to the three-letter code of your desired base currency.

Example:

Run API Requesthttp://exchangesrateapi.com/api/latest
    ? apiKey = f2746121123b7e80c1b6581b615d8ecd
    & base = USD

Please note: The default base currency is EUR.

Convert Endpoint

The Exchangesrateapi API includes a dedicated currency conversion endpoint, allowing you to convert any amount from one currency to another. To perform currency conversion, utilize the API's convert endpoint, append the from and to parameters, and set them to your desired base and target currency codes.

Additionally, you can convert currencies using historical exchange rate data. To accomplish this, utilize the API's date parameter and set it to your desired date in the format YYYY-MM-DD, alongside the from and to parameters for the base and target currencies, respectively.

API Request:

Run API Requesthttp://exchangesrateapi.com/api/convert
    ? apiKey = f2746121123b7e80c1b6581b615d8ecd
    & from = EUR
    & to = USD
    & amount = 50

Request Parameters:

Parameter Description
apiKey [required] Your API Key.
from [required] The three-letter currency code of the currency you would like to convert from.
to [required] The three-letter currency code of the currency you would like to convert to.
amount [required] The amount to be converted.
date [optional] Specify a date (format YYYY-MM-DD) to use historical rates for this conversion.

API Response:

{
    "query": {
        "from": "EUR",
        "to": "USD",
        "amount": 50
    },
    "info": {
        "timestamp": 1710412190,
        "rate": 1.08481
    },
    "date": "2024-03-14"
    "result": 54.2405
}

Response Objects:

Response Object Description
query > from Returns the three-letter currency code of the currency converted from.
query > to Returns the three-letter currency code of the currency converted to.
query > to Returns the amount that is converted.
info > timestamp Returns the exact date and time (UNIX time stamp) the given exchange rare was collected.
info > rate Returns the exchange rate used for your conversion.
date Returns the date (format YYYY-MM-DD) the given exchange rate data was collected.
result Returns your conversion result.

Time-Series Endpoint

Additionally, if your subscription plan allows, you can make use of the Exchangesrateapi API's timeseries endpoint. This endpoint enables you to retrieve daily historical rates for a specified time period, with a maximum duration of 365 days.

API Request:

Run API Requesthttp://exchangesrateapi.com/api/timeseries
    ? apiKey = f2746121123b7e80c1b6581b615d8ecd
    & startDate = 2024-02-05
    & endDate = 2024-03-05

Request Parameters:

Parameter Description
apiKey [required] Your API Key.
startDate [required] The start date of your preferred timeframe.
endDate [required] The end date of your preferred timeframe.
base [optional] Enter the three-letter currency code of your preferred base currency.
symbols [optional] Enter a list of comma-separated currency codes to limit output currencies.

API Response:

{
    "startDate": "2023-04-05",
    "endDate": "2024-03-05",
    "base": "EUR",
    "rates": {
        "2024-03-04":{
          "USD": 1.09,
            },
        "2024-03-03": {
          "USD": 1.09,
        },
        "2024-03-02": {
          "USD": 1.0839,
            },
        [...]
    }
}

Response Objects:

Response Object Description
startDate The start date of your time frame.
endDate The end date of your time frame.
base Returns the three-letter currency code of the base currency used for this request.
rates Returns exchange rate data for the currencies you have requested.

Fluctuation Endpoint

By leveraging the Exchangesrateapi API's fluctuation endpoint, you can access data on currency fluctuations on a day-to-day basis. To utilize this functionality, append a startDate and endDate to your request and specify the currencies (symbols) you wish to query the API for. Keep in mind that the maximum allowable timeframe is 365 days.

API Request:

Run API Requesthttp://exchangesrateapi.com/api/fluctuation
    ? apiKey = f2746121123b7e80c1b6581b615d8ecd
    & startDate = 2023-05-05
    & endDate = 2024-04-05

Request Parameters:

Parameter Description
apiKey [required] Your API Key.
startDate [required] The start date of your preferred fluctuation timeframe.
endDate [required] The end date of your preferred fluctuation timeframe.
base [optional] Enter the three-letter currency code of your preferred base currency.
symbols [optional] Enter a list of comma-separated currency codes to limit output currencies.

API Response:

{
    "success":true,
    "startDate":"2023-05-05",
    "endDate":"2024-04-05",
    "base":"EUR",
    "rates":{
        "USD":{
            "startRate":1.102293,
            "endRate":1.08589,
            "change":-0.016403,
            "changePercent":-1.48807985
        },
        [...]
    }
}

Response Objects:

Response Object Description
startDate The start date of your time frame.
endDate The end date of your time frame.
base Returns the three-letter currency code of the base currency used for this request.
rates Returns exchange rate data for the currencies you have requested.
rates > startRate Returns the exchange collected on your start date.
rates > endRate Returns the exchange collected on your end date.
rates > change Returns the change (decimal number) of the given currency rate between your start and end date.
rates > change Returns the percentage change of the given currency rate between your start and end date.

Sample Code

PHP (cURL)

Real-time rates: Below is a straightforward PHP example for fetching real-time exchange rate data using the latest endpoint of the Exchangesrateapi API.

// set API Endpoint and API key
$endpoint = 'latest';
$apiKey = 'f2746121123b7e80c1b6581b615d8ecd';

// Initialize CURL:
$ch = curl_init('http://exchangesrateapi.com/api/'.$endpoint.'?apiKey='.$apiKey.'');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Store the data:
$json = curl_exec($ch);
curl_close($ch);

// Decode JSON response:
$exchangeRates = json_decode($json, true);

// Access the exchange rate values, e.g. GBP:
echo $exchangeRates['rates']['GBP'];

Currency Conversion: Here's a guide on performing currency conversion using PHP cURL.

// set API Endpoint, access key, required parameters
$endpoint = 'convert';
$apiKey = 'f2746121123b7e80c1b6581b615d8ecd';

$from = 'USD';
$to = 'EUR';
$amount = 10;

// initialize CURL:
$ch = curl_init('http://exchangesrateapi.com/api/'.$endpoint.'?apiKey='.$apiKey.'&from='.$from.'&to='.$to.'&amount='.$amount.'');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// get the JSON data:
$json = curl_exec($ch);
curl_close($ch);

// Decode JSON response:
$conversionResult = json_decode($json, true);

// access the conversion result
echo $conversionResult['result'];

JavaScript (jQuery.ajax)

Real-time rates: Below is a simple example using jQuery.ajax to fetch real-time exchange rate data from the latest endpoint of the Exchangesrateapi API.

// set endpoint and your access key
endpoint = 'latest'
apiKey = 'f2746121123b7e80c1b6581b615d8ecd';

// get the most recent exchange rates via the "latest" endpoint:
$.ajax({
    url: 'http://exchangesrateapi.com/api/' + endpoint + '?apiKey=' + apiKey,
    dataType: 'jsonp',
    success: function(json) {

        // exchange rata data is stored in json.rates
        alert(json.rates.GBP);

        // base currency is stored in json.base
        alert(json.base);

        // timestamp can be accessed in json.timestamp
        alert(json.timestamp);

    }
});

Convert currencies: Below is a guide on how to convert currencies using jQuery.ajax.

// set endpoint and your API key
endpoint = 'convert';
apiKey = 'f2746121123b7e80c1b6581b615d8ecd';

// define from currency, to currency, and amount
from = 'EUR';
to = 'GBP';
amount = '10';

// execute the conversion using the "convert" endpoint:
$.ajax({
    url: 'http://exchangesrateapi.com/api/' + endpoint + '?apiKey=' + apiKey +'&from=' + from + '&to=' + to + '&amount=' + amount,
    dataType: 'jsonp',
    success: function(json) {

        // access the conversion result in json.result
        alert(json.result);

    }
});

Business Continuity - API Overages

At the core of our mission is ensuring our customers achieve success. That's why we're introducing our Business Continuity plan, which guarantees uninterrupted coverage for your end users. While each plan includes a specific number of monthly API calls, we're committed to ensuring that your website or application's performance and user experience remain unaffected, even in the event of increased traffic.

What is an overage?

An overage happens when you exceed the quota for your API plan. Once you reach your API calls limit, we'll charge a nominal fee for each additional API call to ensure uninterrupted service and enable your website or application to continue operating seamlessly.

The prices for additional API calls will vary depending on your plan. Please refer to the table below for the prices per call and an example of overage billing:

Plan Name Monthly Price Number of Calls Overage Price per call Overage Total price
Basic $9.99 20,000 0.0006 5000 $12.59
Professional $24.99 250,000 0.00012 25000 $27.99
Professional Plus $49.99 1,000,000 0.00006 75,000 $54.49

Why do we have overage fees?

Overage fees enable developers to maintain API usage once they've reached their quota limit, providing them with the opportunity to upgrade their plan based on anticipated future needs. At the same time, overage fees ensure that API providers are compensated for increased usage.

How can I determine if I'll incur overage charges?

You'll receive automatic notifications when you're nearing your monthly API calls limit, typically at 75%, 90%, and 100% of your quota. However, it's essential for you to monitor your plan's usage limitations regularly. It's your responsibility to keep track of your quota usage to avoid overages.

How will I be charged for my API subscription?

You will be charged for your monthly subscription plan, plus any overage fees applied. Your credit card will be billed after the billing period has ended.

What happens if I don’t have any overage fees?

In this case, there will be no change to your monthly invoice. Only billing cycles that incur overages will see any difference in monthly charges. The Business Continuity plan is an insurance plan to be used only if needed and guarantees your end users never see a drop in coverage from you.

What if I consistently have more API calls than my plan allows?

If your site consistently surpasses the set limits each month, you may face additional charges for the excess usage. Nevertheless, as your monthly usage reaches a certain threshold, it becomes more practical to consider upgrading to the next plan. By doing so, you ensure a smoother and more accommodating experience for your growing customer base.

I would like to upgrade my plan. How can I do that?

You can easily upgrade your plan by going to your Dashboard and selecting the new plan that would be more suitable for your business needs.