Historical rates
curl --request GET \
--url https://api.xchangeapi.com/historical/{date} \
--header 'api-key: <api-key>'import requests
url = "https://api.xchangeapi.com/historical/{date}"
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/historical/{date}', 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/historical/{date}",
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/historical/{date}"
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/historical/{date}")
.header("api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.xchangeapi.com/historical/{date}")
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{
"timestamp": "<string>",
"base": "<string>",
"rates": {}
}Historical Data
Historical rates
GET
historical
/
{date}
Historical rates
curl --request GET \
--url https://api.xchangeapi.com/historical/{date} \
--header 'api-key: <api-key>'import requests
url = "https://api.xchangeapi.com/historical/{date}"
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/historical/{date}', 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/historical/{date}",
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/historical/{date}"
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/historical/{date}")
.header("api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.xchangeapi.com/historical/{date}")
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{
"timestamp": "<string>",
"base": "<string>",
"rates": {}
}Retrieve historical exchange rates for a specific date. This endpoint allows you to access past market data for all available currencies, which is essential for auditing, backtesting trading strategies, or historical analysis.
The returned data reflects the market state at the close of the requested day.
Query parameters
string
required
The requested date in
YYYY-MM-DD format (e.g., 2023-12-25).string
The currency code of the base currency to quote rates against (e.g.,
USD). If not provided, defaults to the system base currency.string
A comma-separated list of currency codes to limit the response to (e.g.,
EUR,GBP,JPY). If omitted, all available currencies are returned.Response
string
required
The Unix timestamp (epoch) for the returned data.
string
required
The base currency used for the exchange rates.
object
required
An object containing key-value pairs of currency codes and their corresponding exchange rates.
Was this page helpful?
