View and retrieve FX trading rates via API

Learn how to view and retrieve the available FX tiers and trading rates using the FX services API.


Introduction

Foreign exchange, or FX, applies when you need to convert one currency into another. For payment flows, you can use the FX trading rates available to your merchant account when customers pay in one currency and the payment amount must be converted into another currency.

Foreign exchange rates are organised into FX tiers – an FX tier is a group of trading rates. Each tier contains one or more currency-pair rates, and each rate tells you how one currency converts into another, for example from EUR to USD. For example, a tier may contain separate rates for EUR to USD, GBP to EUR, and AUD to EUR.

The FX Services API is read-only, it does not create, update, delete, or negotiate FX rates. It only lets you retrieve the FX tiers and trading rates already available to your merchant account. You can use it to see which FX tiers are assigned to the account and which trading rates are available in each tier.

For the complete details, see the API Reference.


Prerequisites

Before you start, verify that you have:

  • FX Services enabled for your merchant account. Contact emerchantpay Support or your Account Manager for assistance.
  • API credentials for HTTP Basic Authentication. You can find them in the merchant account creation email from emerchantpay support, or in the Gateway Console by going to Configuration > Merchants > Select the merchant > Terminals > Select the terminal > copy the details from the API Access panel.
  • The correct environment URL:
    • Staging – https://staging.gate.emerchantpay.net
    • Production – https://gate.emerchantpay.net

API overview

The API works as follows:

  • HTTP Basic Authentication
  • JSON response format
  • Synchronous REST behaviour
  • Endpoints are read-only
  • Endpoints only return the FX tiers and trading rates available to your merchant account

The FX services API includes the following endpoints:

ENDPOINT METHOD PATH DESCRIPTION
Get tiers GET /v1/fx/tiers Get all FX tiers that are available to your account. Use this first if you do not know the tier ID.
Get tier GET /v1/fx/tiers/:tier_id Get a specific FX tier by tier ID. Use the numeric id value from the Get tiers response as the :tier_id.
Get rates GET /v1/fx/tiers/:tier_id/rates Get all rates for one FX tier. Use this when you need the full rate list for a tier.
Get rate GET /v1/fx/tiers/:tier_id/rates/:id Get a specific rate by rate ID.
Search rate POST /v1/fx/tiers/:tier_id/rates/search Search for a rate by currency pair.

Recommended flow

You can use the following flow to identify the appropriate FX tier and retrieve the rate data you need:

  1. Call GET /v1/fx/tiers to retrieve the FX tiers available to your account.
  2. Select the required tier and store its numeric id.
  3. To retrieve all rates in the tier, call GET /v1/fx/tiers/:tier_id/rates.
  4. To retrieve one specific currency pair, call POST /v1/fx/tiers/:tier_id/rates/search with source_currency and target_currency.
  5. If you already have the rate ID, call GET /v1/fx/tiers/:tier_id/rates/:id.

Get tiers

GET /v1/fx/tiers

Retrieve a list of all FX tiers available to your account.

  • Staging – https://staging.gate.emerchantpay.net/v1/fx/tiers
  • Production – https://gate.emerchantpay.net/v1/fx/tiers

Request example

curl -u USERNAME:PASSWORD \
  https://gate.emerchantpay.net/v1/fx/tiers \
  -X GET

Response example

[
  {
    “id”: 1,
    “name”: “Tier Name”,
    “description”: “Tier Description”,
    “tier_id”: “Tier Identifier”,
    “enabled”: true
  }
]

Response parameters

PARAMETER TYPE DESCRIPTION
id Number The tier ID. Use this value as the :id or :tier_id path parameters when you are specifying a tier by ID.
name String The tier name.
description String The tier description.
tier_id String The tier identifier.
enabled Boolean Indicates whether the tier is enabled.

Get tier

GET /v1/fx/tiers/:tier_id

Retrieve a specific FX tier by tier ID.

  • Staging – https://staging.gate.emerchantpay.net/v1/fx/tiers/:tier_id
  • Production – https://gate.emerchantpay.net/v1/fx/tiers/:tier_id

In your requests, use the tier ID (the tier’s id value from the Get tiers endpoint) as the :tier_id path parameter.

Request example

curl -u USERNAME:PASSWORD \
  https://gate.emerchantpay.net/v1/fx/tiers/1 \
  -X GET

Response example

{
  “id”: 1,
  “name”: “Tier Name”,
  “description”: “Tier Description”,
  “tier_id”: “Tier Identifier”,
  “enabled”: true
}

Response parameters

PARAMETER TYPE DESCRIPTION
id Number The tier ID. Use this value as the :id path parameter when you get a specific tier by ID.
name String The tier name.
description String The tier description.
tier_id String The tier identifier.
enabled Boolean Indicates whether the tier is enabled.

Get rates

GET /v1/fx/tiers/:tier_id/rates

Retrieve a list of all rates for one FX tier.

  • Staging – https://staging.gate.emerchantpay.net/v1/fx/tiers/:tier_id/rates
  • Production – https://gate.emerchantpay.net/v1/fx/tiers/:tier_id/rates

In your requests, use the tier ID (the tier’s id value from the Get tiers endpoint) as the :tier_id path parameter.

Request example

curl -u USERNAME:PASSWORD \
  https://staging.gate.emerchantpay.net/v1/fx/tiers/2/rates \
  -X GET

Response example

[
  {
    “id”: 2,
    “source_currency”: “AUD”,
    “target_currency”: “EUR”,
    “trading_rate”: 0.0763
  }
]

Response parameters

PARAMETER TYPE DESCRIPTION
id Number The rate ID. Use this value as the :id path parameter when you retrieve a rate.
source_currency String The source currency for the rate, in ISO 4217 format.
target_currency String The target currency for the rate, in ISO 4217 format.
trading_rate Float The trading rate for the currency pair.

Get rate

GET /v1/fx/tiers/:tier_id/rates/:id

Retrieve a specific rate by rate ID.

  • Staging – https://staging.gate.emerchantpay.net/v1/fx/tiers/:tier_id/rates/:id
  • Production – https://gate.emerchantpay.net/v1/fx/tiers/:tier_id/rates/:id

In your requests, replace the :tier_ID with the tier ID (the tier’s id value from the Get tiers endpoint) and the :id with the rate ID (the rate’s id value from Get rates endpoint).

Request example

curl -u USERNAME:PASSWORD \
  https://staging.gate.emerchantpay.net/v1/fx/tiers/1/rates/1 \
  -X GET

Response example

{
  “id”: 1,
  “source_currency”: “CHF”,
  “target_currency”: “USD”,
  “trading_rate”: 1.0763
}

Response parameters

PARAMETER TYPE DESCRIPTION
id Number The rate ID.
source_currency String The source currency for the rate, in ISO 4217 format.
target_currency String The target currency for the rate, in ISO 4217 format.
trading_rate Float The trading rate for the currency pair.

Search rate

POST /v1/fx/tiers/:tier_id/rates/search

Search for one rate by source currency and target currency.

  • Staging – https://staging.gate.emerchantpay.net/v1/fx/tiers/:tier_id/rates/search
  • Production – https://gate.emerchantpay.net/v1/fx/tiers/:tier_id/rates/search

In your requests, use the tier ID (the tier’s id value from the Get tiers endpoint) as the :tier_id path parameter.

Request parameters

PARAMETER REQUIRED TYPE DESCRIPTION
source_currency Yes String The source currency for the rate, in ISO 4217 format.
target_currency Yes String The target currency for the rate, in ISO 4217 format.

Request example

curl -u USERNAME:PASSWORD \
  https://staging.gate.emerchantpay.net/v1/fx/tiers/1/rates/search \
  -X POST \
  -H “Content-Type: application/json” \
  -d ‘{
    “source_currency”: “EUR”,
    “target_currency”: “USD”
  }’

Response example

{
  “id”: 1,
  “source_currency”: “EUR”,
  “target_currency”: “USD”,
  “trading_rate”: “1.0763”
}

Response parameters

PARAMETER TYPE DESCRIPTION
id Number The rate ID.
source_currency String The source currency for the rate, in ISO 4217 format.
target_currency String The target currency for the rate, in ISO 4217 format.
trading_rate String The trading rate for the currency pair.