Skip to main content

Quick Start

Buy BTC through the True Markets Retail API.

Prerequisites

Complete Onboarding to create an account, fund it, and download an API key bundle. With TM_KEY_FILE set in your environment, you're ready to continue.

Safety first

Step 4 ("Place the order") sends a real market order that spends real funds. Stop after step 3 (the quote) on the first run to confirm everything works.

Stuck? Ask on Discord

The fastest way to unblock is the True Markets Discord — community and team hang out there for integration help. For account or network access issues, email [email protected].

1. Sign your request and get a JWT

Sign {key_id}.{timestamp} with ES256, then POST to /v1/auth/api-key/token to receive a short-lived access_token.

Signing is language-specific cryptography. See the Auth Service API reference.

import { readFileSync } from "node:fs";
import { createPrivateKey, sign } from "node:crypto";

async function getToken() {
const { key_id, private_key: jwk } = JSON.parse(
readFileSync(process.env.TM_KEY_FILE, "utf8"),
);
const key = createPrivateKey({ key: jwk, format: "jwk" });

const timestamp = Math.floor(Date.now() / 1000);
const signature = sign(
"SHA256",
Buffer.from(`${key_id}.${timestamp}`),
{ key, dsaEncoding: "ieee-p1363" },
).toString("base64url");

const { access_token } = await (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 }),
},
)).json();

return access_token;
}

const token = await getToken();

The token is short-lived. For a production app, see Refresh access token. The remaining steps assume TOKEN is set in your environment.

2. Get tradable assets

Fetch the catalog of assets available across CeFi and DeFi venues. This endpoint is public, so no token is required.

Limit orders and DeFi

Limit orders are supported only on the CeFi assets returned by this endpoint. Pass venue=cefi to filter to that subset, venue=defi for the DeFi catalog, or omit venue to get both.

curl "https://api.truemarkets.co/v1/conductor/assets?venue=cefi"

3. Get a trade quote

Fetch a quote without committing. qty_unit: "quote" means "$5 of BTC"; use "base" to specify a BTC amount instead.

curl -X POST https://api.truemarkets.co/v1/conductor/quotes \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"base_asset": "BTC",
"quote_asset": "USDC",
"qty": "5",
"qty_unit": "quote",
"side": "buy"
}'

4. Place the order

Same shape as the quote, plus type: "market". Returns an order_id to track status.

This sends a real order

Steps 1–3 only read. The request below moves real funds.

# capture the order_id from the response with jq
ORDER_ID=$(curl -s -X POST https://api.truemarkets.co/v1/conductor/orders \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"base_asset": "BTC",
"quote_asset": "USDC",
"qty": "5",
"qty_unit": "quote",
"side": "buy",
"type": "market"
}' | jq -r '.order_id')

Each snippet above captures the order_id from the response into a variable (order_id / orderId / $ORDER_ID) so the next step can track the order.

5. Verify the trade

Track the order with the order_id captured in step 4.

curl https://api.truemarkets.co/v1/conductor/orders/$ORDER_ID/status \
-H "Authorization: Bearer $TOKEN"

Next steps