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_withdraw(owner="0x06A9aF046187895AcFc7258450B15397CAc67400", amount="100.0")
# 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.perpetualTradingWithdraw({
owner: "0x06A9aF046187895AcFc7258450B15397CAc67400",
amount: "100.0",
});
console.log(result);
}
run();curl --request POST \
--url https://api.compasslabs.ai/v2/perpetual_trading/withdraw \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"owner": "0x06A9aF046187895AcFc7258450B15397CAc67400",
"amount": "100.0"
}
'const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({owner: '0x06A9aF046187895AcFc7258450B15397CAc67400', amount: '100.0'})
};
fetch('https://api.compasslabs.ai/v2/perpetual_trading/withdraw', 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/withdraw",
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([
'owner' => '0x06A9aF046187895AcFc7258450B15397CAc67400',
'amount' => '100.0'
]),
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/withdraw"
payload := strings.NewReader("{\n \"owner\": \"0x06A9aF046187895AcFc7258450B15397CAc67400\",\n \"amount\": \"100.0\"\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/withdraw")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"owner\": \"0x06A9aF046187895AcFc7258450B15397CAc67400\",\n \"amount\": \"100.0\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.compasslabs.ai/v2/perpetual_trading/withdraw")
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 \"owner\": \"0x06A9aF046187895AcFc7258450B15397CAc67400\",\n \"amount\": \"100.0\"\n}"
response = http.request(request)
puts response.read_body{
"action": {
"grouping": "na",
"orders": [
{
"a": 12,
"b": true,
"p": "213.50",
"r": false,
"s": "5.00",
"t": {
"limit": {
"tif": "Gtc"
}
}
}
],
"type": "order"
},
"nonce": 1747010983250,
"typed_data": {
"domain": {
"chainId": 1337,
"name": "Exchange",
"verifyingContract": "0x0000000000000000000000000000000000000000",
"version": "1"
},
"message": {
"connectionId": "0xc4e1f04d6b1bf2f2f7a6c0e8a5f3b1d2c9e0a4b7d1c3e5f7a9b1d3e5f7a9e9a2",
"source": "a"
},
"primaryType": "Agent",
"types": {
"Agent": [
{
"name": "source",
"type": "string"
},
{
"name": "connectionId",
"type": "bytes32"
}
],
"EIP712Domain": [
{
"name": "name",
"type": "string"
},
{
"name": "version",
"type": "string"
},
{
"name": "chainId",
"type": "uint256"
},
{
"name": "verifyingContract",
"type": "address"
}
]
}
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Perpetual Trading
Withdraw USDC from perpetual trading account
Prepare a USDC withdrawal from Hyperliquid to Arbitrum.
Returns EIP-712 typed data for the user to sign. After signing, submit the signature via the /execute endpoint. Withdrawal processing takes minutes to hours depending on bridge conditions.
POST
/
v2
/
perpetual_trading
/
withdraw
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_withdraw(owner="0x06A9aF046187895AcFc7258450B15397CAc67400", amount="100.0")
# 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.perpetualTradingWithdraw({
owner: "0x06A9aF046187895AcFc7258450B15397CAc67400",
amount: "100.0",
});
console.log(result);
}
run();curl --request POST \
--url https://api.compasslabs.ai/v2/perpetual_trading/withdraw \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"owner": "0x06A9aF046187895AcFc7258450B15397CAc67400",
"amount": "100.0"
}
'const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({owner: '0x06A9aF046187895AcFc7258450B15397CAc67400', amount: '100.0'})
};
fetch('https://api.compasslabs.ai/v2/perpetual_trading/withdraw', 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/withdraw",
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([
'owner' => '0x06A9aF046187895AcFc7258450B15397CAc67400',
'amount' => '100.0'
]),
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/withdraw"
payload := strings.NewReader("{\n \"owner\": \"0x06A9aF046187895AcFc7258450B15397CAc67400\",\n \"amount\": \"100.0\"\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/withdraw")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"owner\": \"0x06A9aF046187895AcFc7258450B15397CAc67400\",\n \"amount\": \"100.0\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.compasslabs.ai/v2/perpetual_trading/withdraw")
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 \"owner\": \"0x06A9aF046187895AcFc7258450B15397CAc67400\",\n \"amount\": \"100.0\"\n}"
response = http.request(request)
puts response.read_body{
"action": {
"grouping": "na",
"orders": [
{
"a": 12,
"b": true,
"p": "213.50",
"r": false,
"s": "5.00",
"t": {
"limit": {
"tif": "Gtc"
}
}
}
],
"type": "order"
},
"nonce": 1747010983250,
"typed_data": {
"domain": {
"chainId": 1337,
"name": "Exchange",
"verifyingContract": "0x0000000000000000000000000000000000000000",
"version": "1"
},
"message": {
"connectionId": "0xc4e1f04d6b1bf2f2f7a6c0e8a5f3b1d2c9e0a4b7d1c3e5f7a9b1d3e5f7a9e9a2",
"source": "a"
},
"primaryType": "Agent",
"types": {
"Agent": [
{
"name": "source",
"type": "string"
},
{
"name": "connectionId",
"type": "bytes32"
}
],
"EIP712Domain": [
{
"name": "name",
"type": "string"
},
{
"name": "version",
"type": "string"
},
{
"name": "chainId",
"type": "uint256"
},
{
"name": "verifyingContract",
"type": "address"
}
]
}
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Body
application/json
Request to withdraw USDC from HyperEVM perpetual trading account to Arbitrum.
The user's EOA address (owner of the perpetual trading account)
Example:
"0x06A9aF046187895AcFc7258450B15397CAc67400"
USDC amount to withdraw (human-readable, e.g. '500.0')
Example:
"100.0"
Arbitrum destination address (defaults to owner if not specified)
Response
Successful Response
Returned by prepare endpoints — contains EIP-712 typed data for the user to sign.
Was this page helpful?
⌘I