Python (SDK)
from compass_api_sdk import CompassAPI
with CompassAPI(
api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api:
res = compass_api.perpetual_trading.perpetual_trading_execute(action={
"key": "<value>",
"key1": "<value>",
}, nonce=449590, signature="<value>")
# 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.perpetualTradingExecute({
action: {
"key": "<value>",
"key1": "<value>",
},
nonce: 449590,
signature: "<value>",
});
console.log(result);
}
run();curl --request POST \
--url https://api.compasslabs.ai/v2/perpetual_trading/execute \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"action": {},
"nonce": 123,
"signature": "<string>",
"vault_address": "<string>"
}
'const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({action: {}, nonce: 123, signature: '<string>', vault_address: '<string>'})
};
fetch('https://api.compasslabs.ai/v2/perpetual_trading/execute', 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/execute",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'action' => [
],
'nonce' => 123,
'signature' => '<string>',
'vault_address' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"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"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.compasslabs.ai/v2/perpetual_trading/execute"
payload := strings.NewReader("{\n \"action\": {},\n \"nonce\": 123,\n \"signature\": \"<string>\",\n \"vault_address\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.compasslabs.ai/v2/perpetual_trading/execute")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"action\": {},\n \"nonce\": 123,\n \"signature\": \"<string>\",\n \"vault_address\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.compasslabs.ai/v2/perpetual_trading/execute")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"action\": {},\n \"nonce\": 123,\n \"signature\": \"<string>\",\n \"vault_address\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"response": {
"data": {
"statuses": [
{
"resting": {
"oid": 9182734201
}
}
]
},
"type": "order"
},
"status": "ok"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Perpetual Trading
Execute signed action
Submit a signed Hyperliquid action for execution.
Accepts the signature from any prepare endpoint (market_order, limit_order, cancel_order, withdraw, approve_builder_fee) and POSTs it to the Hyperliquid exchange API.
The caller must have already hit a prepare endpoint, so no compass_account registration is performed here.
POST
/
v2
/
perpetual_trading
/
execute
Python (SDK)
from compass_api_sdk import CompassAPI
with CompassAPI(
api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api:
res = compass_api.perpetual_trading.perpetual_trading_execute(action={
"key": "<value>",
"key1": "<value>",
}, nonce=449590, signature="<value>")
# 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.perpetualTradingExecute({
action: {
"key": "<value>",
"key1": "<value>",
},
nonce: 449590,
signature: "<value>",
});
console.log(result);
}
run();curl --request POST \
--url https://api.compasslabs.ai/v2/perpetual_trading/execute \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"action": {},
"nonce": 123,
"signature": "<string>",
"vault_address": "<string>"
}
'const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({action: {}, nonce: 123, signature: '<string>', vault_address: '<string>'})
};
fetch('https://api.compasslabs.ai/v2/perpetual_trading/execute', 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/execute",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'action' => [
],
'nonce' => 123,
'signature' => '<string>',
'vault_address' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"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"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.compasslabs.ai/v2/perpetual_trading/execute"
payload := strings.NewReader("{\n \"action\": {},\n \"nonce\": 123,\n \"signature\": \"<string>\",\n \"vault_address\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.compasslabs.ai/v2/perpetual_trading/execute")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"action\": {},\n \"nonce\": 123,\n \"signature\": \"<string>\",\n \"vault_address\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.compasslabs.ai/v2/perpetual_trading/execute")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"action\": {},\n \"nonce\": 123,\n \"signature\": \"<string>\",\n \"vault_address\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"response": {
"data": {
"statuses": [
{
"resting": {
"oid": 9182734201
}
}
]
},
"type": "order"
},
"status": "ok"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Body
application/json
Was this page helpful?
⌘I