Retrieve forex rates
Fetches the current foreign exchange rate for a specified currency pair. Returns the real-time exchange rate used for multi-currency transactions. This endpoint is only accessible if multi-currency transactions are enabled on your account.
API Credentials
Request Parametersโ
Required - 1 fieldRequired Parameters
`currency`STRING(required)
Base currency as three-letter ISO 4217 code in lowercase. The rate will show conversion from this currency to your account funding currency.
Responsesโ
200
Successful requestReturns the forex object with current exchange rate information.
Forex object contains:
object- String value "forex"location- API endpoint path (e.g., "/forex/usd")livemode- Boolean indicating test or live modebase- Source currency code (ISO 4217)quote- Target currency code (typically account funding currency)rate- Numeric exchange rate (approximately 2-4% above mid-market daily rates)
- Rate represents how much of the quote currency equals one unit of base currency
- Example: If base=USD, quote=THB, rate=30.4847, then 1 USD = 30.4847 THB
- Rates include Omise's margin (2-4% above mid-market rates)
401
UnauthorizedAuthentication failed. Invalid or missing API key.
Common causes:
- Missing Authorization header
- Invalid secret key
- Incorrect HTTP Basic Auth format
404
Not foundCurrency not found or multi-currency not enabled.
Common causes:
- Invalid currency code
- Multi-currency transactions not enabled on account
- Currency not supported for your account
Code samplesโ
- cURL
- Ruby
- Python
- Node.js
- PHP
- Java
- C#
- Go
curl https://api.omise.co/forex/usd \
-u skey_test_5xuy4w91xqz7d1w9u0t:
require 'omise'
Omise.api_key = 'skey_test_5xuy4w91xqz7d1w9u0t'
forex = Omise::Forex.retrieve('usd')
import omise
omise.api_secret = 'skey_test_5xuy4w91xqz7d1w9u0t'
forex = omise.Forex.retrieve('usd')
const omise = require('omise')({
secretKey: 'skey_test_5xuy4w91xqz7d1w9u0t'
});
const forex = await omise.forex.retrieve('usd');
<?php
define('OMISE_SECRET_KEY', 'skey_test_5xuy4w91xqz7d1w9u0t');
$forex = OmiseForex::retrieve('usd');
Client client = new Client.Builder()
.secretKey("skey_test_5xuy4w91xqz7d1w9u0t")
.build();
ForexRate forex = client.forex("usd").get();
var client = new Client("skey_test_5xuy4w91xqz7d1w9u0t");
var forex = await client.Forex.Retrieve("usd");
client, _ := omise.NewClient(
"pkey_test_5xuy4w91xqz7d1w9u0t",
"skey_test_5xuy4w91xqz7d1w9u0t",
)
forex, _ := client.Forex().Get("usd")
Try it outโ
Required - 1 fields