Unparalleled suite of productivity-boosting Web APIs & cloud-based micro-service applications for developers and companies of any size.

APICurrency

A Complete Guide To Exchange Rates API

The development of technology and the transition of the age to the digital age have increased the number of multinational countries. New job opportunities, new structures have begun to bring people together. As a result of this, it indirectly increased the conversion between different currencies. People nowadays convert between currencies for multiple reason

Today, investors and businesses instantly convert between hundreds of official currencies through digital banks and thousands of other applications. While the volume of trading transactions is increasing, the duration of the transactions is in milliseconds.

Applications that enable millions of users to transact between hundreds of currencies instantly use exchange currency API services.

In this article, exchangerates API, which is the most useful service that provides exchange currency API service, will be examined.

What is Exchangerates API

One of the services that provides Exchange Currency API and Currency Conversion API services over a single service is Exchangerates API. Exchangerates API provides a powerful endpoint for exchange rates and currency conversion and is used today by big companies like Honda, Morton, Elders.

It offers a huge data repository for businesses, supporting more than 20 official currencies worldwide. It updates the data pool every minute and provides the most up-to-date data to its users in the fastest way.

Exchangerates API provides more than 200 official currency data and conversions between them in just milliseconds to maximize user satisfaction.

People who trade currency as an investment often need to analyze historical data. Provides Exchangerates API users with historical exchange rate data up to January 1, 1999.

Exchangerates API offers the following services to its users via endpoint.

  • 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 of 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.

Let’s take a look at how these services are used.

Testing Exchangerates API services with PHP

An API key is needed to integrate and use the Exchangerates API in your project. API key can be obtained by signing up for one of the packages on the official website of Exchangerates.

Endpoint for latest rates

Request:

<?php
$client = new http\Client;
$request = new http\Client\Request;
$request->setRequestUrl(‘http://api.exchangeratesapi.io/v1/latest?access_key=b5*****5&base=USD&symbols=GBP,JPY,EUR’);
$request->setRequestMethod(‘GET’);
$request->setOptions(array());

$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();

Response:

{
    “success”: true,
    “timestamp”: 1519296206,
    “base”: “USD”,
    “date”: “2021-03-17”,
    “rates”: {
        “GBP”: 0.72007,
        “JPY”: 107.346001,
        “EUR”: 0.813399,
    }
}

Endpoint for conversion

Currency conversion can be done by using the ‘from’, ‘to’ and ‘amount’ parameters with the Exchangerates API.

It is also possible to convert currencies using historical exchange rate data. To do this, please also use the date parameter of the API and set it to the preferred date. (YYYY-MM-DD format).

Request:

<?php
$client = new http\Client;
$request = new http\Client\Request;
$request->setRequestUrl(‘http://api.exchangeratesapi.io/v1/convert?access_key=b5*****5&&from=GBP&to=JPY&amount=25’);
$request->setRequestMethod(‘GET’);
$request->setOptions(array());

$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();

Response:

{
    “success”: true,
    “query”: {
        “from”: “GBP”,
        “to”: “JPY”,
        “amount”: 25
    },
    “info”: {
        “timestamp”: 1519328414,
        “rate”: 148.972231
    },
    “historical”: “”
    “date”: “2018-02-22”
    “result”: 3724.305775
}

Endpoint for historical rates

With this service, historical rates of currencies up to 1999 can be accessed. Most data of currencies are available up to 1999. It can be queried for historical exchange rates by adding a date (format YYYY-MM-DD).

Request:

<?php
$client = new http\Client;
$request = new http\Client\Request;
$request->setRequestUrl(‘http://api.exchangeratesapi.io/v1/2013-12-24?access_key=b5*****5&base=GBP&symbols=USD,CAD,EUR’);
$request->setRequestMethod(‘GET’);
$request->setOptions(array());

$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();

Response:

{
    “success”: true,
    “historical”: true,
    “date”: “2013-12-24”,
    “timestamp”: 1387929599,
    “base”: “GBP”,
    “rates”: {
        “USD”: 1.636492,
        “EUR”: 1.196476,
        “CAD”: 1.739516
    }
}

Endpoint for Time-Series Data

The Exchangerates API allows querying for historical daily rates between two dates you choose, with a maximum time frame of 365 days.

equest:

<?php
$client = new http\Client;
$request = new http\Client\Request;
$request->setRequestUrl(‘http://api.exchangeratesapi.io/v1/timeseries?access_key=b5*****5&start_date=2012-05-01&end_date=2012-05-25’);
$request->setRequestMethod(‘GET’);
$request->setOptions(array());

$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();

Response:

{
    “success”: true,
    “timeseries”: true,
    “start_date”: “2012-05-01”,
    “end_date”: “2012-05-03”,
    “base”: “EUR”,
    “rates”: {
        “2012-05-01”:{
          “USD”: 1.322891,
          “AUD”: 1.278047,
          “CAD”: 1.302303
        },
        “2012-05-02”: {
          “USD”: 1.315066,
          “AUD”: 1.274202,
          “CAD”: 1.299083
        },
        “2012-05-03”: {
          “USD”: 1.314491,
          “AUD”: 1.280135,
          “CAD”: 1.296868
        },
        […]
    }
}

Endpoint for fluctuation data

With the Exchangerates API, you can get information about the fluctuation of the currency on a daily basis.

Request:

<?php
$client = new http\Client;
$request = new http\Client\Request;
$request->setRequestUrl(‘http://api.exchangeratesapi.io/v1/fluctuation?access_key=b5*****5&start_date=2015-12-01&end_date=2015-12-24’);
$request->setRequestMethod(‘GET’);
$request->setOptions(array());

$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();

Response:

{
    “success”:true,
    “fluctuation”:true,
    “start_date”:“2018-02-25”,
    “end_date”:“2018-02-26”,
    “base”:“EUR”,
    “rates”:{
        “USD”:{
            “start_rate”:1.228952,
            “end_rate”:1.232735,
            “change”:0.0038,
            “change_pct”:0.3078
        },
        “JPY”:{
            “start_rate”:131.587611,
            “end_rate”:131.651142,
            “change”:0.0635,
            “change_pct”:0.0483
        },
        […]
    }
}

Conclusion

By using the currency conversion API and exchange currency API services provided by Exchangerates API, you can serve up-to-date data to your users in milliseconds.

Related posts
API

Zenserp vs. Yandex Reverse Image Search: What's The Best?

API

7 Best Free Currency Converter APIs In 2022

API

What Is Geolocation Data, Where To Get It, And Examples

APIAutomation

Automated Background Removal with PicWish API

Leave a Reply

Your email address will not be published. Required fields are marked *