OHLC chart data for selected period
curl --request GET \
--url https://api.xchangeapi.com/{format}/chart/{currency-pair}/{period} \
--header 'api-key: <api-key>'import requests
url = "https://api.xchangeapi.com/{format}/chart/{currency-pair}/{period}"
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}/chart/{currency-pair}/{period}', 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}/chart/{currency-pair}/{period}",
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}/chart/{currency-pair}/{period}"
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}/chart/{currency-pair}/{period}")
.header("api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.xchangeapi.com/{format}/chart/{currency-pair}/{period}")
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{
"1584714240": [
1.07217,
1.07372,
1.07329,
1.07233,
1.07205,
1.07358,
1.07315,
1.07217
],
[...]
"1584728880": [
1.0641,
1.06594,
1.06543,
1.06542,
1.06396,
1.06583,
1.06531,
1.06529
]
}
<result>
<item>
<time>1584709680</time>
<min_ask>1.07</min_ask>
<max_ask>1.07129</max_ask>
<open_ask>1.0703</open_ask>
<close_ask>1.0711</close_ask>
<min_bid>1.06988</min_bid>
<max_bid>1.07115</max_bid>
<open_bid>1.07019</open_bid>
<close_bid>1.07097</close_bid>
</item>
[...]
<item>
<time>1584737520</time>
<min_ask>1.06966</min_ask>
<max_ask>1.07034</max_ask>
<open_ask>1.0699</open_ask>
<close_ask>1.06996</close_ask>
<min_bid>1.0692</min_bid>
<max_bid>1.06987</max_bid>
<open_bid>1.06927</open_bid>
<close_bid>1.06966</close_bid>
</item>
</result>
time,min_ask,max_ask,open_ask,close_ask,min_bid,max_bid,open_bid,close_bid
1584709680,1.07024,1.07129,1.0703,1.0711,1.07014,1.07115,1.07019,1.07097
[...]
1584737520,1.06966,1.07034,1.0699,1.06996,1.0692,1.06987,1.06927,1.06966
Historical Data
OHLC chart data for selected period
GET
{format}
/
chart
/
{currency-pair}
/
{period}
OHLC chart data for selected period
curl --request GET \
--url https://api.xchangeapi.com/{format}/chart/{currency-pair}/{period} \
--header 'api-key: <api-key>'import requests
url = "https://api.xchangeapi.com/{format}/chart/{currency-pair}/{period}"
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}/chart/{currency-pair}/{period}', 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}/chart/{currency-pair}/{period}",
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}/chart/{currency-pair}/{period}"
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}/chart/{currency-pair}/{period}")
.header("api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.xchangeapi.com/{format}/chart/{currency-pair}/{period}")
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{
"1584714240": [
1.07217,
1.07372,
1.07329,
1.07233,
1.07205,
1.07358,
1.07315,
1.07217
],
[...]
"1584728880": [
1.0641,
1.06594,
1.06543,
1.06542,
1.06396,
1.06583,
1.06531,
1.06529
]
}
<result>
<item>
<time>1584709680</time>
<min_ask>1.07</min_ask>
<max_ask>1.07129</max_ask>
<open_ask>1.0703</open_ask>
<close_ask>1.0711</close_ask>
<min_bid>1.06988</min_bid>
<max_bid>1.07115</max_bid>
<open_bid>1.07019</open_bid>
<close_bid>1.07097</close_bid>
</item>
[...]
<item>
<time>1584737520</time>
<min_ask>1.06966</min_ask>
<max_ask>1.07034</max_ask>
<open_ask>1.0699</open_ask>
<close_ask>1.06996</close_ask>
<min_bid>1.0692</min_bid>
<max_bid>1.06987</max_bid>
<open_bid>1.06927</open_bid>
<close_bid>1.06966</close_bid>
</item>
</result>
time,min_ask,max_ask,open_ask,close_ask,min_bid,max_bid,open_bid,close_bid
1584709680,1.07024,1.07129,1.0703,1.0711,1.07014,1.07115,1.07019,1.07097
[...]
1584737520,1.06966,1.07034,1.0699,1.06996,1.0692,1.06987,1.06927,1.06966
Retrieve aggregated chart data for a predefined time period. Unlike the date range endpoint, this method automatically calculates the data resolution based on the selected period, simplifying the request for common timeframes.
Note on Precision: Some currency pairs are returned with a multiplier (e.g., 100 or 1000) to ensure high precision.
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.string
required
The currency pair symbol (e.g.,
EURUSD). See the list of available currencies.string
required
The time period to retrieve data for. Available options:
30m- Last 30 minutes1h- Last 1 hour6h- Last 6 hours12h- Last 12 hours1d- Last 1 day2d- Last 2 days7d- Last 7 days1M- Last 1 month3M- Last 3 months6M- Last 6 months1Y- Last 1 year
Response
Response Structure: For a detailed explanation of the array indices (for JSON) and property definitions, please refer to the Response Structures guide.
{
"1584714240": [
1.07217,
1.07372,
1.07329,
1.07233,
1.07205,
1.07358,
1.07315,
1.07217
],
[...]
"1584728880": [
1.0641,
1.06594,
1.06543,
1.06542,
1.06396,
1.06583,
1.06531,
1.06529
]
}
<result>
<item>
<time>1584709680</time>
<min_ask>1.07</min_ask>
<max_ask>1.07129</max_ask>
<open_ask>1.0703</open_ask>
<close_ask>1.0711</close_ask>
<min_bid>1.06988</min_bid>
<max_bid>1.07115</max_bid>
<open_bid>1.07019</open_bid>
<close_bid>1.07097</close_bid>
</item>
[...]
<item>
<time>1584737520</time>
<min_ask>1.06966</min_ask>
<max_ask>1.07034</max_ask>
<open_ask>1.0699</open_ask>
<close_ask>1.06996</close_ask>
<min_bid>1.0692</min_bid>
<max_bid>1.06987</max_bid>
<open_bid>1.06927</open_bid>
<close_bid>1.06966</close_bid>
</item>
</result>
time,min_ask,max_ask,open_ask,close_ask,min_bid,max_bid,open_bid,close_bid
1584709680,1.07024,1.07129,1.0703,1.0711,1.07014,1.07115,1.07019,1.07097
[...]
1584737520,1.06966,1.07034,1.0699,1.06996,1.0692,1.06987,1.06927,1.06966
Was this page helpful?
⌘I
