Python (SDK)
from compass_api_sdk import CompassAPI, models
with CompassAPI(
api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api:
res = compass_api.perpetual_trading.perpetual_trading_candles(symbol="AAPL", interval=models.CandleInterval.ONEH, limit=200)
# Handle response
print(res)import { CompassApiSDK } from "@compass-labs/api-sdk";
const compassApiSDK = new CompassApiSDK({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await compassApiSDK.perpetualTrading.perpetualTradingCandles({
symbol: "AAPL",
interval: "1h",
limit: 200,
});
console.log(result);
}
run();curl --request GET \
--url https://api.compasslabs.ai/v2/perpetual_trading/candles \
--header 'x-api-key: <api-key>'const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.compasslabs.ai/v2/perpetual_trading/candles', 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.compasslabs.ai/v2/perpetual_trading/candles",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-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.compasslabs.ai/v2/perpetual_trading/candles"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-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.compasslabs.ai/v2/perpetual_trading/candles")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.compasslabs.ai/v2/perpetual_trading/candles")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"candles": [
{
"close": "213.88",
"high": "214.20",
"low": "213.10",
"open": "213.45",
"time": 1747008000,
"trades": 312,
"volume": "1842.5"
},
{
"close": "214.92",
"high": "215.05",
"low": "213.70",
"open": "213.88",
"time": 1747011600,
"trades": 388,
"volume": "2104.2"
}
],
"interval": "1h",
"symbol": "AAPL"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Perpetual Trading
Get OHLCV candles
Return OHLCV candles for a single asset and interval.
Wraps Hyperliquid’s candleSnapshot info type and adds the xyz: HIP-3 DEX
prefix server-side so the SDK only needs the bare ticker (e.g. AAPL).
Candle time is returned in unix seconds, ready for TradingView
lightweight-charts. Cached for 15 seconds per (symbol, interval, window).
GET
/
v2
/
perpetual_trading
/
candles
Python (SDK)
from compass_api_sdk import CompassAPI, models
with CompassAPI(
api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api:
res = compass_api.perpetual_trading.perpetual_trading_candles(symbol="AAPL", interval=models.CandleInterval.ONEH, limit=200)
# Handle response
print(res)import { CompassApiSDK } from "@compass-labs/api-sdk";
const compassApiSDK = new CompassApiSDK({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await compassApiSDK.perpetualTrading.perpetualTradingCandles({
symbol: "AAPL",
interval: "1h",
limit: 200,
});
console.log(result);
}
run();curl --request GET \
--url https://api.compasslabs.ai/v2/perpetual_trading/candles \
--header 'x-api-key: <api-key>'const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.compasslabs.ai/v2/perpetual_trading/candles', 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.compasslabs.ai/v2/perpetual_trading/candles",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-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.compasslabs.ai/v2/perpetual_trading/candles"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-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.compasslabs.ai/v2/perpetual_trading/candles")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.compasslabs.ai/v2/perpetual_trading/candles")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"candles": [
{
"close": "213.88",
"high": "214.20",
"low": "213.10",
"open": "213.45",
"time": 1747008000,
"trades": 312,
"volume": "1842.5"
},
{
"close": "214.92",
"high": "215.05",
"low": "213.70",
"open": "213.88",
"time": 1747011600,
"trades": 388,
"volume": "2104.2"
}
],
"interval": "1h",
"symbol": "AAPL"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Query Parameters
Asset ticker (e.g. AAPL, GOLD, EUR). The xyz: HIP-3 DEX prefix is added server-side if not already present.
Required string length:
1 - 64Candle interval: 1m, 5m, 15m, 1h, 4h, 1d, 1w
Available options:
1m, 5m, 15m, 1h, 4h, 1d, 1w Number of candles to return (max 5000, capped by Hyperliquid).
Required range:
1 <= x <= 5000Optional start of the candle window in unix milliseconds. If omitted, computed as end_time - limit * interval.
Optional end of the candle window in unix milliseconds. Defaults to now.
Was this page helpful?