For AI agents: the documentation index is at /llms.txt, and this page is available as Markdown at /institutional/trade-over-rest.md.
Trade over REST
Exchange REST covers the same trading actions as FIX, over HTTPS. It's reachable over the internet, so you don't need the private network connection that FIX uses.
Authenticate a request
Mint a JWT from your API key, then send it with every request. To mint one, sign the string {key_id}.{timestamp} with your private key and post it to POST https://api.truemarkets.co/v1/auth/api-key/token. The timestamp is Unix seconds within 30 seconds of our clock. The signature is ES256, the raw 64-byte r || s, base64url-encoded without padding.
The response has an access token, which lasts an hour, and a refresh token. Before the access token expires, post the refresh token to POST /v1/auth/token/refresh for a new pair. Create your API key shows the refresh call.
Send these headers on every CeFi request:
| Header | Value |
|---|---|
Authorization | Bearer and your access token |
x-truex-auth-timestamp | the current Unix time in seconds |
X-Truex-Version | v2026_01_23 |
The JWT carries your client id, so you never send one. The timestamp guards against replayed requests: the exchange rejects one that is more than 15 seconds old or more than 1 second in the future, so keep your clock in sync.
X-Truex-Version picks the response format. v2026_01_23 is the default and the only supported version, so the header is optional, but pinning it keeps a future default change from reshaping your responses. Any other value, including the withdrawn v2024_01_01, is rejected with 400 Bad Request. List responses come wrapped in data and pagination.
Send every CeFi request to https://api.truex.co.
import { createPrivateKey, sign } from "node:crypto";
import { readFileSync } from "node:fs";
const { key_id, private_key } = JSON.parse(
readFileSync(process.env.TM_KEY_FILE!, "utf8"),
);
const timestamp = Math.floor(Date.now() / 1000);
const signature = sign(
"sha256",
Buffer.from(`${key_id}.${timestamp}`),
{
key: createPrivateKey({ key: private_key, format: "jwk" }),
dsaEncoding: "ieee-p1363",
},
).toString("base64url");
const res = await fetch(
"https://api.truemarkets.co/v1/auth/api-key/token",
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ key_id, timestamp, signature }),
},
);
console.log((await res.json()).access_token);TOKEN="$(npx tsx token.ts)"
curl -s "https://api.truex.co/v1/cefi/balances" \
-H "Authorization: Bearer $TOKEN" \
-H "x-truex-auth-timestamp: $(date +%s)" \
-H "X-Truex-Version: v2026_01_23"Change an order instead of replacing it
To move a resting order's price or size, modify it with PATCH /v1/cefi/orders rather than canceling it and placing a new one. A modify is one request instead of two, so it uses less of your rate limit. It also avoids a race: a new order sent right after a cancel can reach the exchange before the cancel has released your balance, and get rejected. That happens most when you're trading close to 100% of your balance. Over FIX, the same change is an OrderCancelReplaceRequest (35=G).
Endpoints
Orders
Balances
Next: Exchange REST reference
- Need help? Ask us on Discord, or email [email protected].
- See what changed in the changelog