Single currency rate
curl --request GET \
--url https://api.xchangeapi.com/{format}/currencies/{currency-pair} \
--header 'api-key: <api-key>'import requests
url = "https://api.xchangeapi.com/{format}/currencies/{currency-pair}"
headers = {"api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'api-key': '<api-key>'}};
fetch('https://api.xchangeapi.com/{format}/currencies/{currency-pair}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.xchangeapi.com/{format}/currencies/{currency-pair}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.xchangeapi.com/{format}/currencies/{currency-pair}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.xchangeapi.com/{format}/currencies/{currency-pair}")
.header("api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.xchangeapi.com/{format}/currencies/{currency-pair}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"ask": "1.06742",
"bid": "1.06727",
"name": "EURUSD",
"time": "1584640370.007"
}
<result>
<currency>
<ask>1.06742</ask>
<bid>1.06727</bid>
<name>EURUSD</name>
<time>1584640370.007</time>
</currency>
</result>
ask,bid,name,time
1.06742,1.06727,EURUSD,1584640370.007
Live Data
Single currency rate
GET
{format}
/
currencies
/
{currency-pair}
Single currency rate
curl --request GET \
--url https://api.xchangeapi.com/{format}/currencies/{currency-pair} \
--header 'api-key: <api-key>'import requests
url = "https://api.xchangeapi.com/{format}/currencies/{currency-pair}"
headers = {"api-key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'api-key': '<api-key>'}};
fetch('https://api.xchangeapi.com/{format}/currencies/{currency-pair}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.xchangeapi.com/{format}/currencies/{currency-pair}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.xchangeapi.com/{format}/currencies/{currency-pair}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.xchangeapi.com/{format}/currencies/{currency-pair}")
.header("api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.xchangeapi.com/{format}/currencies/{currency-pair}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"ask": "1.06742",
"bid": "1.06727",
"name": "EURUSD",
"time": "1584640370.007"
}
<result>
<currency>
<ask>1.06742</ask>
<bid>1.06727</bid>
<name>EURUSD</name>
<time>1584640370.007</time>
</currency>
</result>
ask,bid,name,time
1.06742,1.06727,EURUSD,1584640370.007
Get the latest exchange rate for a single, specific currency pair. This endpoint is optimized for retrieving precise, up-to-the-millisecond data for individual market instruments.
Path parameters
string
default:"json"
The desired output format. Options:
json, xml, csv.If you choose
xml, you must use the POST method. GET requests for XML will fail.Query parameters
string
The currency pair symbol to retrieve (e.g.,
EURUSD). See the list of available currencies.Response
Note on Precision: Some currency pairs are returned with a multiplier (e.g., 100 or 1000) to ensure high precision.
string
The current ask price.
string
The current bid price.
string
The currency pair symbol.
string
The Unix timestamp (epoch) of the rate.
{
"ask": "1.06742",
"bid": "1.06727",
"name": "EURUSD",
"time": "1584640370.007"
}
<result>
<currency>
<ask>1.06742</ask>
<bid>1.06727</bid>
<name>EURUSD</name>
<time>1584640370.007</time>
</currency>
</result>
ask,bid,name,time
1.06742,1.06727,EURUSD,1584640370.007
Was this page helpful?
⌘I
