API Access Key & Authentication
API Key
The API has a unique identifier as an API key that gets passed into the API as an URL parameter access_key. This parameter serves as a unique identifying authentication with the Exchangerates API.
Base URL:
Append your API Key: See an example of how to authenticate the Exchangerates API with the access_key parameter:
Sign Up to Run API Request
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 easily can 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, have an object which 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.
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.
Endpoint for latest rates: This endpoint returns exchange rate data in real-time for all available currencies or for a specific set.
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.
Endpoint for Time-Series Data: It returns the daily historical data for exchange rates, between two specified dates. The data can be returned for all available currency or for specified ones.
Endpoint for fluctuation data: This endpoint returns the fluctuation data between specified dates. The data can be for all available currencies or for a specific set.
SSL Connection
Every paid subscription plan on Exchangerates.io 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 is a feature included in the Exchangerates API. With this feature, you can specify the function name and send it into the API’s callback
GET parameter and make the API respond to your request with the API response wrapped in that function.
Example Call:
From the above example, we can see a request from the API to use the callback function MY_FUNCTION
.
Example Response: Your API response will be wrapped inside your preferred callback function.
Access-Control / CORS
Cross-Origin Resource Sharing (CORS) and Access-Control Headers are also supported into 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 in cases if there are changes into 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 in 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 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.
Step 2
When you will make another API request, be sure to include the If-None-Match
HTTP header abd set ut 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.
Step 3
Based on if your result set has 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
andDate
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 we 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 Code | Description |
---|---|
404 | The requested resource does not exist. |
101 | No API Key was specified or an invalid API Key was specified. |
103 | The requested API endpoint does not exist. |
104 | The maximum allowed API amount of monthly API requests has been reached. |
105 | The current subscription plan does not support this API endpoint. |
106 | The current request did not return any results. |
102 | The account this API request is coming from is inactive. |
201 | An invalid base currency has been entered. |
202 | One or more invalid symbols have been specified. |
301 | No date has been specified. [historical ] |
302 | An invalid date has been specified. [historical , convert ] |
403 | No or an invalid amount has been specified. [convert ] |
501 | No or an invalid timeframe has been specified. [timeseries ] |
502 | No or an invalid "start_date" has been specified. [timeseries , fluctuation ] |
503 | No or an invalid "end_date" has been specified. [timeseries , fluctuation ] |
504 | An invalid timeframe has been specified. [timeseries , fluctuation ] |
505 | The specified timeframe is too long, exceeding 365 days. [timeseries , fluctuation ] |