Skip to main content

About Trading API

The Trading API lets you trade your own True Markets account from code. You create a key at app.truemarkets.co, and that key signs your requests and your orders. If you're building an app for your customers, read the Gateway documentation.

Real funds

Every trade moves real funds. A first trade costs a few dollars of USDC, and we pay the network fees.

How a trade works​

Your code mints a token from your key file and sends it on every call. Placing an order or transfer returns unsigned wallet transactions, called payloads. You sign each one with the same key and post the signatures to execute. Nothing moves until you do.

Place an order, sign the payloads, execute
const order = await post("/v1/gateway/orders", {
asset_id: assetId,
qty: "2",
qty_unit: "quote",
side: "buy",
type: "market",
});

const signatures = await Promise.all(
order.payloads.map((p) => stamp(p.payload)),
);

await post(`/v1/gateway/orders/${orderId}/execute`, {
signatures,
auth_type: "api_key",
});

post() sends your token. stamp() signs a payload with your key. Getting started defines both.

Your codeTrue Markets
Sign inwith your API key
Sign {key_id}.{timestamp}POST /v1/auth/api-key/token
Access and refresh tokensrefresh without signing again
Place the orderwith your token
Create the orderPOST /v1/gateway/orders
Unsigned payloadsone wallet transaction each
Sign and executewith the same API key
Stamp each payloadstays on your machine
Execute with the signaturesPOST /v1/gateway/orders/{id}/execute
Order statuscomplete, or pending until final

Trading API use cases​

  • A script or bot that trades your account on a schedule or on a signal.
  • A service that reads your balances and rebalances your holdings.

How it differs from Gateway​

The Trading API and Gateway share the same endpoints, documented in the Trading REST reference. What changes is whose account a request acts on.

  • Your token acts as you. A Gateway client adds a header to name which of its users a request is for. You never send it.
  • Your account already exists. You sign up at app.truemarkets.co, and the app creates your wallet when you set up a passkey, so there are no users to create.
  • One key does both jobs. The same key mints your tokens and signs your orders. A Gateway client holds two keys for those two jobs.
  • You can refresh tokens. Minting a token also returns a refresh token, so you can get a new access token without signing again.

Get started​

Trade​

Before you raise your amounts, work through the Go live checklist.