1 Step Quickstart Example

Take the shortcut and learn to make requests to the exchangeratesapi API in 3 simple steps.

Get API Access Key

Code Examples

Jump to the Code Examples section and get sample code for PHP (cURL), JavaScript (jQuery), and Java.

Code Examples

Exchange Rates API

With over 15 exchange rate data sources, the Exchangerates API is delivering exchanging rates data for more than 170 world currencies. This API has several endpoints, where each of them serves a different purpose, use case. The endpoints include functionalities like receiving the latest exchange rates information for a specific set, or for all currencies; conversion from one to another currency; receiving data Time-series for multiple or for one currency, and preserving the API daily for the fluctuation data.

API Key

The API has a unique identifier as an API key that gets passed into the API as a URL parameter access_key. This parameter serves as a unique identifying authentication with the Exchangerates API.

Base URL:

Copy Append your API Key: Append your API Key: See an example of how to authenticate the Exchangerates API with the access_key parameter: https

API Response:

The delivered exchange rates with the API are, by default, connected to the Euro. The data gets returned in a standard JSON format and can easily be reparsed in any programming language.

Example Response: See below an example of an API response that provides information about several world currencies that are commonly used, all in connection with the Euro currency and time-stamped with time information of the collected information.

As we can see from the example above, when it is queried for exchange rates in real-time, the API response always contains a timestamp object, which is a standard UNIX timestamp that shows the time when the provided exchange rate information was collected. Also, we have a base object, which contains the short currency code of the currency, an object that contains the date when the given exchange rate information was collected, and rates object that contains the exchange rate data. Below, in the Endpoints section, we will discuss the API response structure more in detail. https

Available Endpoints

The API comes with a number of endpoints where each of them provides different functionality. Please have in mind that depending on your subscribed plan, some endpoints will be available and some may not be available.

Latest Rates EndpointThis endpoint, depending on your subscription plan will return real-time exchange rate data which gets updated every 60 minutes, every 10 minutes, or every 60 seconds.
Endpoint for conversion:With this endpoint, we have any amount conversion from one currency to another.
Endpoint for historical rates:Endpoint for receiving historical exchange rate information for all available currencies or for a set of currencies.

SSL Connection

Every paid subscription plan on exchangeratesapi.net is with 256-bit SSL encryption. Simply use the https protocol instead of http in order to connect to the API through SSL.

JSONP Callbacks

The JSONP Callbacks feature is included in the Exchangerates API. With this feature, you can specify the function name and send it as the API's 'callback' GET parameter, making the API respond to your request with the API response wrapped in that function. https

Example Call:

From the above example, we can see a request from the API to use the callback function MY_FUNCTION. https.

Example Response: docexampleResponseDescription

Access-Control / CORS

Cross-Origin Resource Sharing (CORS) and Access-Control Headers are also supported in the Exchangerates API. This gives you the possibility to use the Exchangerates API via Cross-Origin HTTP Requests.

Learn more about CORS »

HTTP ETags

You can request new Exchangerates API data only if there are changes in the rates data since your last API response. This can be done with HTTP ETags.

What are ETags?

An ETag is a part of the HTTP protocol and one of the several mechanisms used for cache validation. The ETag is an identifier assigned to a data resource on a server, and if that resource is ever updated at the server, the ETag is changed. Whenever a resource is requested (via its URL), the data and ETag are retrieved and stored in the Web cache, and the ETag is sent along with subsequent requests. If the ETag at the server has not changed, a 'Not Modified' message is returned, and the cached data is used. (Definition by pcmag.com)

ETags - Quickstart Guide

Step 1

The primary request sent to the Exchangerates API will create an ETag object that will contain a unique ETag key and a Date object containing the exact date and time at which the data was last modified. This data, along with the entire API response, must be cached in order for ETags to work. https

Step 2

When you make another API request, be sure to include the 'If-None-Match' HTTP header and set it to your previously generated ETag value. Moreover, you will need to add the 'If-Modified-Since' HTTP header to your API request containing the date and time data from your last request. https

Step 3

Based on whether your result set has been updated or not since your last API request, the API will return:

Same results as your initial API request along with a '304 – Not Modified' HTTP header, which indicates that no change has happened. In this case, the size of the API response will be very small (0.2kb); or new results containing a completely new set of ETag and Date objects that will indicate that new data has been accessed. In this case, the size of your API response will be normal.

Potential Errors

When you send API requests, but the requested data is not available, or the API call fails for some reason, a JSON error is returned. Errors always come together with an error code and a description.

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

Other Errors:

Error CodeDescription
404The requested resource does not exist.
101No API Key was specified or an invalid API Key was specified.
103The requested API endpoint does not exist.
104The maximum allowed API amount of monthly API requests has been reached.
105The current subscription plan does not support this API endpoint.
106The current request did not return any results.
102The account this API request is coming from is inactive.
201An invalid base currency has been entered.
202One or more invalid symbols have been specified.
301No date has been specified. [historical]
302An invalid date has been specified. [historical, convert]
403No or an invalid amount has been specified. [convert]
501No or an invalid timeframe has been specified. [timeseries]
502No or an invalid "start_date" has been specified. [timeseries, fluctuation]
503No or an invalid "end_date" has been specified. [timeseries, fluctuation]
504An invalid timeframe has been specified. [timeseries, fluctuation]
505The specified timeframe is too long, exceeding 365 days. [timeseries, fluctuation]

Endpoints

Supported Symbols Endpoint

The API comes with an updated endpoint that returns all of the available currencies. To receive the list, make an API request to the symbols endpoint.

API Request:

Request Parameters:

ParameterDescription
access_key[Required] Your API Key.

API Response:

Response Objects:

Response ObjectDescription
successreturns true or false depending on whether or not your API request has succeeded
symbolsReturns all supported currencies with their respective three-letter currency codes and names.

Latest Rates Endpoint

This endpoint, depending on your subscription plan will return real-time exchange rate data which gets updated every 60 minutes, every 10 minutes, or every 60 seconds.

API Requests:

Request Parameters:

ParameterDescription
access_key[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:

Response Objects:

ParameterDescription
successReturns true or false depending on whether or not your API request has succeeded.
timestampReturns the exact date and time (UNIX time stamp) the given rates were collected.
baseReturns the three-letter currency code of the base currency used for this request.
ratesReturns exchange rate data for the currencies you have requested.

Historical Rates Endpoint

With this endpoint we have the possibility to see historical rates of the currencies back to 1999, most of the currencies data are available until 1999. You can query the Exchangerates API for historical rates by appending a date (format YYYY-MM-DD ) to the base URL.

API Request:

Request Parameters:

ParameterDescription
YYYY-MM-DD>[required] A date in the past for which historical rates are requested.
access_key[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:

Response Objects:

Response ObjectDescription
successReturns true or false depending on whether or not your API request has succeeded.
historicalReturns true false.
dateReturns the date for which historical rates were requested.
timestampReturns the exact date and time (UNIX time stamp) the given rates were collected.
baseReturns the three-letter currency code of the base currency used for this request.
ratesReturns exchange rate data for the currencies you have requested.

Specify Symbols

In order to have reduced bandwidth, you can limit the number of output currencies to a specific set of your choice on most API endpoints. To do this, simply append the Exchangerates API's symbolsparameter to your API request and set it to one or more comma-separated currency codes.

Example:

The API's response for the request above will be limited to the currencies USD, CAD and JPY.

Changing base currency

Provided changing base currency is supported on your subscription plan, you can change the currency to which your output currency rates are relative to by appending the base parameter to your API request URL and setting it to the three-letter code of your preferred base currency.

Example:

Please note: The default base currency is EUR.

Convert Endpoint

This is a separate endpoint for currency conversion that comes with the Exchangerates API and can be used toconvert an amount from one currency to another. Please use this API endpoint for the conversion of any currency.
It is also possible to convert currencies using historical exchange rate data. To do this, please also use the API'sdate parameter and set it to your preferred date. (format YYYY-MM-DD).

API Request:

Request Parameters:

ParameterDescription
access_key[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:

Response Objects:

Response ObjectDescription
successReturns true or false depending on whether or not your API request has succeeded
query > fromReturns the three-letter currency code of the currency converted from.
query > toReturns the three-letter currency code of the currency converted to.
query > toReturns the amount that is converted.
info > timestampReturns the exact date and time (UNIX time stamp) the given exchange rare was collected.
info > rateReturns the exchange rate used for your conversion.
historicalReturns true if historical rates are used for this conversion.
dateReturns the date (format YYYY-MM-DD) the given exchange rate data was collected.
resultReturns your conversion result.

Time-Series Endpoint

If supported by your subscription plan, the Exchangerates API's time series endpoint lets you query the API for daily historical rates between two dates of your choice, with a maximum time frame of 365 days.

API Request:

Request Parameters:

ParameterDescription
access_key[required] Your API Key.
start_date[required] The start date of your preferred timeframe.
end_date[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:

Response Objects:

Response ObjectDescription
successReturns true or false depending on whether or not your API request has succeeded
timeseriesReturns true if a request to the timeseries endpoint is made.
start_dateThe start date of your time frame.
end_dateThe end date of your time frame.
baseReturns the three-letter currency code of the base currency used for this request.
ratesReturns exchange rate data for the currencies you have requested.

Fluctuation Endpoint

With the fluctuation API endpoint, you can receive information about the currency'sfluctuation on a day-to-day basis. To be able to use this feature, add thestart_date and end_date and select which currencies (symbols) you would like to receive info for from the API. Please note that the maximum allowed timeframe is 365 days.

API Request:

Request Parameters:

ParameterDescription
access_key[required] Your API Key.
start_date[required] The start date of your preferred fluctuation timeframe.
end_date[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:

Response Objects:

Response ObjectsDescription
successReturns true or false depending on whether or not your API request has succeeded
fluctuationReturns true if a request to the fluctuation endpoint is made.
start_dateThe start date of your time frame.
end_dateThe end date of your time frame.
baseReturns the three-letter currency code of the base currency used for this request.
ratesReturns exchange rate data for the currencies you have requested.
rates > start_rateReturns the exchange collected on your start date.
rates > end_rateReturns the exchange collected on your end date.
rates > changeReturns the change (decimal number) of the given currency rate between your start and end date.
rates > changeReturns the percentage change of the given currency rate between your start and end date.

Sample Code

PHP (cURL)

Real-time rates: Find below a simple PHP example for getting exchange rate data via the Exchangerates API's latest endpoint.

Convert currencies: Here is how to convert currencies using PHP cURL.

JavaScript (jQuery.ajax)

Real-time rates: Find below a simple jQuery.ajax example for getting exchange rate data via the Exchangerates API's latest endpoint.

Convert currencies: Here is how to convert currencies using jQuery.ajax.

Business Continuity - API Overages

Ensuring our customers achieve success is paramount to what we do at APILayer. For this reason, we will be rolling out our Business Continuity plan guaranteeing your end users will never see a drop in coverage. Every plan has a certain amount of API calls that you can make in the given month. However, we would never want to cut your traffic or impact user experience negatively for your website or application in case you get more traffic.

What is an overage?

An overage occurs when you go over a quota for your API plan. When you reach your API calls limit, we will charge you a small amount for each new API call so we can make sure there will be no disruption in the service we provide to you and your website or application can continue running smoothly.

Prices for additional API calls will vary based on your plan. See table below for prices per call and example of an overage billing.

Plan NameMonthly PriceNumber of CallsOverage Price per callOverageTotal price
Basic$10.0010,0000.00122000$12.40
Pro Plan$40.00100,0000.0004820,000$49.60
Business$80.00500,0000.000192100,000$99.20

Why does APILayer have overage fees?

Overage fees allow developers to continue using an API once a quota limit is reached and give them time to upgrade their plan based on projected future use while ensuring API providers get paid for higher usage.

How do I know if I will be charged for overages?

When you are close to reaching your API calls limit for the month, you will receive an automatic notification (at 75%, 90% and 100% of your monthly quota). However, it is your responsibility to review and monitor for the plan's usage limitations. You are required to keep track of your quota usage to prevent overages. You can do this by tracking the number of API calls you make and checking the Dashboard for up-to-date usage statistics.

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. Additionally, you may contact your false to discuss a custom plan if you expect a continuous increase in usage.