Get Started
A seven-step walkthrough from a cold start to an open position on the Nexus Exchange: sign in with your wallet, mint an HMAC API key, sign requests, fund the account, browse markets, place an order, and monitor positions.
Every step is shown in five clients — cURL, Rust, Python, TypeScript, and the Exchange CLI. Pick a tab per step.
This page began as the Getting Started tab of the interactive API docs the Exchange app once served at /api-docs. That route no longer resolves — this page is now the guide.
Before you start
You need an Ethereum wallet to sign the login message. Nothing else is required to begin.
Base URL. The API is served at the Exchange deployment's origin plus
/api/exchange— the gateway. Examples below usehttps://exchange.nexus.xyz/api/exchange. Running locally, the base ishttp://localhost:9090. Substitute the base for the deployment you are actually calling. Paths are shown with the/api/v1prefix where a versioned route exists, since that is the canonical surface — so a full URL readshttps://exchange.nexus.xyz/api/exchange/api/v1/…. See Base URLs for why the contract's ownserversoverride is not usable directly.Authentication. Two schemes: a session token (Bearer) used only to create and manage API keys, and HMAC-SHA256 API-key signing used for everything else, including all trading.
Two surfaces. The Exchange app is deployed twice from one codebase: a testnet surface, which is live and funds accounts from a synthetic-credit faucet, and a mainnet real-funds surface, which will be funded by bridging USDX from Ethereum Mainnet. Mainnet is 2026-05-20. Step 4 below differs between the two — both variants are documented.
Placeholders. Values such as
0xSIGNATURE_HEX,nx_7f3a1b...,sess_abc123..., and0x<wallet-private-key>are placeholders. Substitute your own; never commit a secret.
Language coverage
cURL is the canonical, always-populated baseline. The four SDK/CLI clients do not yet cover every step. Where a client has no example for a step, the tab says so and the cURL example above it is the one to follow — the interactive docs behave the same way, falling back to cURL with a note.
Machine-readable entry points
Everything an agent needs in order to start without reading this page:
llms.txt— https://exchange.nexus.xyz/llms.txtopenapi.json— the OpenAPI contract, athttps://exchange.nexus.xyz/api/exchange/openapi.json/metadata— the Exchange app's machine-readable metadata routeMCP server — published to npm, so adding it is one line. It runs locally over stdio, which means your API key stays on your machine:
Its public market-data and demo tools need no credentials, so the command is useful before you have a key. A hosted MCP endpoint is planned; its DNS is not live yet, so there is no remote URL to add today.
The OpenAPI spec and changelog are versioned at nexus-xyz/nexus-exchange-api; releases are tracked on GitHub Releases.
Authentication
Steps 1–3 get you from a wallet to a signed request.
1. Sign in
POST /auth/login — no authentication required.
Authenticate with an EIP-191 personal signature. The message to sign is always the fixed string “Sign in to Nexus Exchange” — your wallet address is recovered from the signature.
Notes
Session token expires in 24 hours.
You only need the session to create and manage API keys — not for trading.
Not available in TypeScript yet — use the cURL example.
Request body
Response
2. Create API key
POST /keys — Session token required.
Use the session token to create an HMAC key pair. The secret is shown once — save it immediately.
Notes
You cannot retrieve the secret after this response.
Keys inherit your account’s tier; per-tier rate limits are reported in the
X-RateLimit-*response headers.
Not available in Python yet — use the cURL example.
Not available in TypeScript yet — use the cURL example.
Request body
Response
3. Sign requests
GET /markets — HMAC API key required.
Every authenticated request needs three headers. Build a canonical string, HMAC-SHA256 it with your secret, and attach the result.
Required headers
X-API-Key
yes
Your key ID (nx_...)
X-Timestamp
yes
Current time in ms since epoch
X-Signature
yes
HMAC-SHA256 hex of the canonical string
Notes
Canonical format:
timestamp\nMETHOD\npath\nquery\nsha256(body)pathis the path as written in the contract — include the/api/v1prefix when the route has one, but not the/api/exchangegateway mount, which is stripped before your signature is verified. Calling…/api/exchange/marketsmeans signing/markets; calling…/api/exchange/api/v1/tickersmeans signing/api/v1/tickers.Timestamp must be within ±30 seconds of server time (milliseconds since epoch).
For GET requests with no body, hash the empty string.
Response
Trading
Steps 4–7 fund the account and put a position on.
4. Fund account
POST /account/credit — HMAC API key required. Testnet surface.
Credit synthetic USDX to start trading. Each API key can claim up to 500 USDX per day — omit "amount" to claim the full remaining daily allowance.
The credit faucet is a testnet affordance. On the mainnet real-funds surface this endpoint returns 403 and funding is bridge-only — see the mainnet variant below.
Notes
Amounts are decimal strings, like all monetary values in the API.
Returns 429 once the daily allowance is used up; it resets the next UTC day.
Request body
Response
Mainnet surface variant — step 4: Fund via bridge
On the mainnet real-funds surface (mainnet: 2026-05-20), step 4 is replaced by a bridge deposit. Funding differs fundamentally per surface: the testnet play surface has a synthetic-credit faucet; the mainnet real-funds surface will be bridge-only.
POST /bridge/deposit-addresses — HMAC API key required.
Real funds: there is no synthetic credit on mainnet. Get your per-account deposit address, bridge USDX from Ethereum Mainnet to it, and your exchange account is credited once the deposit confirms.
Notes
POST /account/creditis testnet-only — it returns 403 on mainnet; the bridge is the sole funding path.Idempotent per (account, chain): repeated calls return the same address.
GET /bridge/assetslists depositable assets per chain with minimum amounts, required confirmations, and fees — check it before sending.Track crediting with
GET /bridge/deposits(or/bridge/deposits/{id}): status moves tocreditedonce required confirmations are reached.On-chain transfers are irreversible — send only supported assets to this address, from a wallet you control.
Round trip: fund here → trade (next steps) → withdrawals:
GET /withdrawalslists your records; withdrawal initiation is not yet exposed through the public API.
Not available in Rust yet — use the cURL example. The white-glove client wrap for the bridge step is still in progress.
Not available in Python yet — use the cURL example.
Not available in TypeScript yet — use the cURL example.
Not available in the CLI yet — use the cURL example.
Request body
Response
5. Browse markets
GET /markets/{market_id}/ticker — HMAC API key required.
List available perpetual futures markets and check current prices.
Response
Price and size precision
Round before you submit. Every market declares three quantisation rules, and an order that misses them is rejected rather than rounded for you.
Field on GET /markets
Rule
tick_size
The limit price must be an exact multiple of it.
lot_size
The order size must be an exact multiple of it.
min_order_size
The order size must be at least this.
For BTC-USDX-PERP those are 0.5, 0.001 and 0.001. So a price of 83000.25 is invalid — it is not a multiple of 0.5 — and so is a size of 0.0005, which is below both the lot and the minimum. 83000.00 and 0.001 are valid.
Read the values per market rather than hardcoding them: they differ by market (ETH-USDX-PERP is 0.10 and 0.01, SOL-USDX-PERP is 0.01 and 0.1) and they are listing-time configuration. Market Specifications publishes the current table for every listed market.
Round toward the safe side. Round a buy price down and a sell price up to the tick, and floor sizes to the lot grid: rounding a size up can push the order past the margin your equity supports and turn a precision problem into a rejected order for a different reason.
6. Place an order
POST /orders — HMAC API key required.
Submit a limit or market order. The response confirms acceptance.
Notes
Use
"type": "market"to fill immediately at best available price.Batch multiple orders in a single
POST /orders/batchcall — processed sequentially, results preserve request order.
Request body
Response
7. Cancel or amend
DELETE /orders/{order_id} · DELETE /orders · PATCH /orders/{order_id} — HMAC API key required.
Three separate operations, and the distinction matters:
DELETE /orders/{order_id}
Cancels one resting order.
DELETE /orders
Cancels every resting order, or every order on one market with ?market_id=.
PATCH /orders/{order_id}
Atomic cancel-replace: changes price and/or size in one call.
Notes
An amend returns a replacement with a fresh id. The
200body is the new order; the id you amended no longer exists. Track the id you get back, not the one you sent.At least one of
priceorsizemust be supplied on an amend.The amend's pre-trade margin check excludes the reservation still held by the order being replaced, so it is sized on the margin the replacement actually adds: repricing at the same size needs no additional margin, and shrinking frees margin rather than requiring more.
Liquidation orders are not amendable.
A
409on an amend means the order changed underneath you — it filled or was cancelled between your read and your write.Cancels draw on a separate rate-limit budget from submissions. Exhausting your order budget never blocks a cancel; a
429withbucket: cancelis the only refusal that means your cancel channel itself is saturated. See Rate limits.
8. Monitor positions
GET /positions — HMAC API key required.
Check open positions, unrealized PnL, and account health.
Response
WebSockets
Polling is fine to get started; a live book or a fill feed should use the stream.
GET /stream mints a connection token, and the WebSocket carries channel subscriptions from there. The full model — token minting and lifetime, the channel list, message envelopes, sequence numbers and reconnection — is on GET /stream and the WebSocket pages in the Reference sidebar.
Two things worth knowing before you build against it:
Cancel-on-disconnect is opt-in, per account, and off by default. Set it with
PUT /account/cancel-on-disconnect; read it with theGET. It is a dead-man's switch: when your last authenticated connection drops and does not reconnect inside the grace window, your resting orders are cancelled. Without it, a dropped connection leaves your orders working.Check
active, not justenabled.enabledis your own opt-in;activeadditionally requires the exchange-side feature switch, soactiveis what tells you cancel-on-disconnect will actually fire. An account can read backenabled: trueand still not be protected.The stream is not the authority for position state. Reconcile against
GET /positionsandGET /accountafter any reconnect rather than replaying from where you left off.
Clients
The snippets above use these packages:
Rust
nexus_exchange
Python
nexus_exchange
TypeScript
@nexus-xyz/exchange-ts
CLI
the nexus command
The CLI and the language SDKs are distributed outside the Exchange monorepo. The guided walkthrough does not state their repositories, so install instructions are not reproduced here.
Next steps
Overview — what the Exchange API covers and how it is organised
Authentication — session tokens, HMAC canonicalisation, and API-key management in full
Order Types — the requirement matrix for all eight order types, and the Trading pages in the Reference sidebar
GET /streamand the WebSocket pages in the Reference sidebar — token minting, channels, message envelopes, and reconnection
Last updated

