API Documentation

Detailed examples for easy integration, examples include jQuery, Python, and PHP

We provide a JSON REST API with both live and historical currency exchange rates for over 40 currencies. Data is sourced from an aggregated feed of institutional providers, (not a broker feed), giving you reliable and up-to date traded rates that are used by banks globally. We have systems in place to remove irregular prices, giving you the cleanest prices available. Our API powers applications and financial software in major financial insitutions all around the world.

Overview

Authentication with API Key

API key can be accessed by signing up to the service. The API's data endpoints can be accessed using the api_key. To access the data, add your api_key to the URL endpoint: following is an example of an API call to access live data:

Request Example:

JSON Response

Our API will respond with a JSON object. For more details see below.

Response Example:

The API will return timestamp and price object containing requested currency pairs' exchange rates and timestamp

Response Parameters:
Field Type Description
timestamp integer UNIX time of the price in seconds
price JSON object Contains all currency pair codes (string) and their respective exchange rates (float).

Available Currencies

A list of all the available currencies can be accessed through requesting the API or clicking the link stated here. In order to request data, add the currencies codes together to form a currency pair. For example EURNOK can be requested by adding EUR and NOK together. In order to get the inverse of the same pair, simly reverse the quote to NOKEUR. To access JSON object containing all available currency codes verus USD, Simply append your api_key to the fxmarketapi apicurrencies endpoint:

Request Example:

https://fxmarketapi.com/apicurrenciesSign Up
?api_key=api_key



Response Example:
{
    "currencies": {
      "USDAED": "United Arab Emirates Dirham",
      "USDARS": "Argentine Peso",
      "AUDUSD": "Australian Dollar",
      "USDBRL": "Brazilian Real",
      "BTCUSD": "Bitcoin",
      "USDCAD": "Canadian Dollar",
      "USDCHF": "Swiss Franc",
      "USDCLP": "Chilean Peso",
      "USDCNY": "Chinese Yuan",
      "USDCOP": "Colombian Peso",
      "USDCZK": "Czech Republic Koruna",
      "USDDKK": "Danish Krone",
      "EURUSD": "Euro",
      "GBPUSD": "British Pound Sterling",
        ...
   }
}

Response Parameters:
Field Type Description
currencies JSON Object Returns all currency pair codes and thier names in a (string) format that are available through the API

Endpoints

The FXMarketAPI has five API endpoints serving different sets of data. Below is a summary of these endpoints.

Available Endpoints:
API Endpoints
https://fxmarketapi.com/apilive?&api_key=api_key
https://fxmarketapi.com/apihistorical?date=YYYY-MM-DD&api_key=api_key
https://fxmarketapi.com/apiconvert?api_key=api_key&from=EUR&to=SEK&amount=100
https://fxmarketapi.com/apitimeseries?start_date=2015-01-01&end_date=2015-05-01&api_key=api_key
https://fxmarketapi.com/apichange?currency=EURUSD,EURGBP&api_key=api_key
https://fxmarketapi.com/apipandas?currency=EURUSD,EURGBP&start_date=2015-01-01&end_date=2015-05-01&api_key=api_key

API Endpoints

Live Rates

The FXMarketAPI API's live endpoint's provides a Real-Time exchange rates feed to the users.

Request Example:

https://fxmarketapi.com/apiliveSign Up
?api_key=api_key



Request Parameters:
Field Type Description
api_key string API Key.
currency string [Optional] A comma-separated list of currencies; default is EURUSD, GBPUSD, and USDJPY

Response Example:
{
  "timestamp": 1541521247,
  "price": {
    "AUDUSD": 0.7225,
    "EURUSD": 1.1412,
    "GBPUSD": 1.3079,
    "USDJPY": 113.3845
  }
}

Response Properties:
Field Type Description
timestamp integer Returns the exact date and time (UNIX) the exchange rates were collected.
price JSON object Contains all currency pair codes (string) and their respective exchange rates (float).

Historical Rates

The API provides daily exchange rate data for the past 10 years

Request Example:

https://fxmarketapi.com/apihistoricalSign Up
?api_key=api_key
&date=2018-05-02


Request Parameters:
Field Type Description
api_key string API Key.
date string Provide a date for which historical exchange rates are requested. yyyy-mm-dd
currency string [Optional] A comma-separated list of currencies; default is EURUSD, GBPUSD, and USDJPY

Response Example:
{
  "date": "2018-05-02",
  "price": {
    "EURUSD": 1.19509,
    "GBPUSD": 1.35748,
    "USDJPY": 109.8405
  }
}

Response Properties:
Field Type Description
date string Returns the date for which exchange rates were requested
price JSON object Contains all currency pair codes (string) and their respective exchange rates (float).

Convert

The FXMarketAPI API's convert endpoint's provides a Real-Time conversion of exchange rates from one currrency to other.

Request Example:

https://fxmarketapi.com/apiconvertSign Up
?api_key=api_key
& from=EUR
& to=SEK
& amount=1000



Request Parameters:
Field Type Description
api_key string API Key.
from string Three digit currency code (example EUR) of the base currency
to string Three digit currency code (example SEK) of the quoted currency
amount string Notional amount of the base currency to be converted

Response Example:
{
  "price": 10.2477,
  "timestamp": 1544112937,
  "total": 10247.7
}

Response Properties:
Field Type Description
timestamp integer Returns the exact date and time (UNIX) the exchange rates were collected.
price float Exchange Rate Price.
total float Total Converted Amount.

Time-Series

Time series api provides OHLC data for the currencies requested. It is recommended that you do not request more than one year of data at a time, or more than three currencies at a time. To request just close price just use &format = close (optional parameter)

Request Example:
  
  https://fxmarketapi.com/apitimeseriesSign Up
  ?api_key=api_key
  & currency=EURUSD,GBPUSD
  & start_date=2018-07-02
  & end_date=2018-09-02
  & format=ohlc

  
  

Request Parameters:
Field Type Description
api_key string API Key.
start_date string Provide the start date of your timeseries in yyyy-mm-dd format.
end_date string [Optional] Provide the end date of your timeseries in yyyy-mm-dd format. Default is current date.
currency string [Optional] A comma-separated list of currencies; default is EURUSD, GBPUSD, and USDJPY .
format string [Optional] Add "close" in the request to get single quote per period; default is OHLC.

Response Example:
{
  "start_date": "2018-07-02",
  "end_date": "2018-09-02",
  "price": {
      "2018-07-02": {
        "EURUSD": {
          "close": 1.1639,
          "high": 1.1692,
          "low": 1.1591,
          "open": 1.168
        },
        "GBPUSD": {
          "close": 1.3143,
          "high": 1.3212,
          "low": 1.3095,
          "open": 1.3194
        }
      },
      "2018-07-03": {
        "EURUSD": {
          "close": 1.1658,
          "high": 1.1673,
          "low": 1.162,
          "open": 1.1639
        },
        "GBPUSD": {
          "close": 1.3192,
          "high": 1.3208,
          "low": 1.3115,
          "open": 1.315
        }
      },
      ...
   }
}

Response Parameters:
Field Type Description
start_date string Returns the start date of the timeseries for which exchange rates were requested
end_date string Returns the end date of the timeseries for which exchange rates were requested
price JSON object The price contains all OHLC exchange rates (float) for the currencies requested that are date stamped (string) in yyyy-mm-dd format.

Exchange Rates Change

The Apichange endpoint enables the user to request the difference and percentage change for a given currency between two dates. The user will also be returned a start rate and an end rate for the date specified.

Request Example:

https://fxmarketapi.com/apichangeSign Up
?api_key=api_key
& currency=EURUSD,GBPUSD
& start_date=2018-07-02
& end_date=2018-09-02



Request Parameters:
Field Type Description
api_key string API Key.
start_date string Provide the start date of your timeseries in yyyy-mm-dd format.
end_date string [Optional] Provide the end date of your timeseries in yyyy-mm-dd format. Default is current date.
currency string [Optional] A comma-separated list of currencies; default is EURUSD, GBPUSD, and USDJPY .

Response Example:

{
  "start_date": "2018-07-02",
  "end_date": "2018-09-02",
  "price": {
    "EURUSD": {
      "change": 0.0038,
      "end_rate": 1.1601,
      "pct_change": -0.3299,
      "start_rate": 1.16394
    },
    "GBPUSD": {
      "change": 0.0183,
      "end_rate": 1.296,
      "pct_change": -1.3909,
      "start_rate": 1.31428
  }
}
}

Response Parameters:
Field Type Description
api_key string API Key.
start_date string Provide the start date of your timeseries in yyyy-mm-dd format.
end_date string [Optional] Provide the end date of your timeseries in yyyy-mm-dd format. Default is current date.
price JSON Object The price object will contain sub-objects [currency]
currency [start_rate] float Exchange rates at the open of the start_date.
currency [end_rate] float Exchange rates at the close of the end_date.
currency [change] float The difference between the currency's start_rate and end_rate.
currency [pct_change] float The percentage change between the currency's start_rate and end_rate.

Pandas

Pandas api returns currency data in a format that is easy to use in Jupyter Notebook/Python. If one currency is requested a dataframe is returned with OHLC data which is datetime indexed. If multiple currencies are requested dataframe is returned with close data for multiple currencies which are datetime indexed

Request Example:
  import pandas as pd

  df = pd.read_json("https://fxmarketapi.com/apipandas?api_key=api_key&currency=EURUSD,GBPUSD&start_date=2018-07-02&end_date=2018-09-02")

  

Request Parameters:
Field Type Description
api_key string API Key.
start_date string Provide the start date of your timeseries in yyyy-mm-dd format.
end_date string [Optional] Provide the end date of your timeseries in yyyy-mm-dd format. Default is current date.
currency string [Optional] A comma-separated list of currencies; default is EURUSD, GBPUSD, and USDJPY .

Response Example:
                
EURUSD GBPUSD
2018-11-30 1.13190 1.27506
2018-12-03 1.13548 1.27239
2018-12-04 1.13432 1.27183
.....

Examples

PHP (CURL)

Below is an example for live exchange rates data using PHP (CURL):

?php

$curl = curl_init();

curl_setopt_array( $curl, array(
  CURLOPT_PORT => "5000",
  CURLOPT_URL => "https://fxmarketapi.com/apilive?currency=USDJPY,AUDUSD,GBPUSD,EURUSD&api_key=api_key",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}


Python

Below is an example for live exchange rates data using Python:

import requests

url = "https://fxmarketapi.com/apilive"

querystring = {"currency":"USDJPY","api_key":"api_key"}

response = requests.get(url, params=querystring)

print(response.json())


JavaScript (jQuery.ajax)

Below is an example for live exchange rates data using jQuery:

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://fxmarketapi.com/apilive?currency=USDJPY,AUDUSD,GBPUSD,EURUSD&api_key=api_key",
  "method": "GET",
  "headers": {}
  }

$.ajax(settings).done(function (response) {
  console.log(response);
});