Skip to main content
Two services, each serving its own live, interactive API reference:

OMS API

The Order Management System’s REST + WebSocket surface: orders, positions, margin, account management, withdrawals, settlements.

Market Data Service API

Public klines, depth, trades, and tickers over REST and WebSocket.
Each reference is served by the running service, so it always matches the live API. This page covers the cross-cutting conventions: authentication, signing, accounts, and finalized fills.

Programmatic access

The /api-reference pages are client-rendered Scalar apps: the returned HTML is a shell that loads the API spec via JavaScript; fetching it without a browser yields no endpoints. Fetch the machine-readable API spec (an OpenAPI document) instead: Use HTTPS; take exact paths from the API spec. Endpoints are served at the service root with no prefix: GET https://oms.tplus.cx/markets, not /api/markets.

Quickstart

The Python SDK tpluspy handles the auth handshake, Ed25519 signing, and per-field amount encoding.
Prices and quantities are Decimal whole units, scaled by the market’s book decimals. To send raw book units, build the request and pass it to send_order, or to replace_multiple_orders or amend_multiple_orders for a replace or an amend. To drive the REST/WS API directly, do the Authentication handshake for a bearer token, sign each order/withdrawal/settlement per Request signatures, and follow the per-field amount encoding. Finalized fills covers how state-changing calls report clearing-engine rejections and when a fill is finalized. After authenticating, the safest first state-read call is the trade simulation, POST /account/simulate/{user_id}. It is non-mutating: OMS validates the request, reads inventory, books, registry, prices, protocol values, and fee state, then returns a projected margin result without forwarding a state change to the orderbook or clearing engine.

Authentication

User IDs are hex-encoded Ed25519 public keys. Session auth is a three-step flow:
  1. GET /nonce/{user_id} - returns a random nonce bound to the user, valid 5 minutes.
  2. Sign the nonce’s value as raw UTF-8 bytes with the Ed25519 private key.
  3. POST /auth - exchange the signed nonce for a bearer token, valid 24 hours.
Nonce behavior is replay-safe. A successful POST /auth consumes the nonce, so the same signed nonce cannot be exchanged again. A second GET /nonce/{user_id} returns the existing valid nonce when it has more than 10 seconds of viability left; otherwise OMS generates a replacement. A user has one nonce, shared by all of that user’s clients: if two clients fetch the same nonce and one authenticates first, the other is rejected with NONCE_NOT_FOUND (or INVALID_NONCE if a newer nonce was issued meanwhile) and must fetch a new nonce, sign it and authenticate again. Each service keeps at most 25 live tokens per user. Every successful POST /auth mints a new token, and when a user exceeds 25, the oldest tokens are evicted before their expiry_ns. Clients that run several processes for one account, or that re-authenticate without logging out, should reuse a token until it fails rather than authenticate on every start or retry. The cap is per user per service: OMS and MDS each count separately. Send Authorization: Bearer <token> and User-Id: <hex public key> on REST requests. On WebSocket, you may send those same headers or use Sec-WebSocket-Protocol. For v1 envelopes in browser clients, add tplus.ws.v1 to the protocol list, for example ["Bearer-<token>", "User-<id>", "tplus.ws.v1"]. The auth parser accepts Bearer- and User- in any comma-separated position, tplus.ws.v1 opts the stream into the v1 envelope, and the server echoes it as the selected subprotocol wherever it appears. There is no refresh endpoint today. To refresh a session, request a nonce and authenticate again. POST /logout revokes all bearer tokens for the authenticated user; after revocation, requests that reuse those tokens fail auth before reaching the handler. Tokens are keyed by user public key and token value, and token validation checks only that stored token and its expiry; account multisig config changes do not revoke existing tokens in the current OMS code path. REST auth failures use the normal error envelope. Missing or invalid bearer credentials return 401 UNAUTHORIZED, except that a token evicted by the 25-token cap returns 401 TOKEN_EVICTED (with details.max_tokens_per_user) and an expired token returns 401 TOKEN_EXPIRED; both mean “authenticate again”. The server remembers why a token stopped working only for a while (an expired token until the hourly cleanup, an evicted one for up to an hour or until 25 newer evictions), after which it answers UNAUTHORIZED. Tokens revoked by POST /logout always answer UNAUTHORIZED. A User-Id header that is not a valid public key returns 400 INVALID_USER_ID. Invalid signatures return 401 INVALID_SIGNATURE. An order that fails the account multisig policy returns 401 with SIGNER_NOT_AUTHORIZED, SIGNER_EXPIRED, INVALID_SIGNATURE or INSUFFICIENT_SIGNATURE_WEIGHT. Nonce failures return 400 with NONCE_NOT_FOUND, NONCE_EXPIRED or INVALID_NONCE. Auth rate limits return 429 RATE_LIMITED. WebSocket upgrade auth failures take the same REST path. After upgrade, a user/path mismatch on a user stream sends a channel error (v0 unauthorized, v1 UNAUTHORIZED) and ends the stream without an auth-specific close code. On the control channel, a request for another user or an order that fails the account multisig policy gets an error frame with the matching code on v1 and the INVALID AUTH payload on v0; the connection stays open. Close code 1013 signals lag/resync, not auth. There is no public master-key rotation flow today, so post-rotation bearer-token semantics do not apply.

Request signatures

Independent of session auth, signed actions such as orders, withdrawals, settlements, and transfers carry an Ed25519 signature from the account’s master key. The OMS checks that the authenticated user matches the signer; the clearing engine re-verifies clearing-engine actions before finalizing. Replacing an order requires a new signature. The signed payload is the action-specific signable object serialized to compact JSON: whitespace stripped, fields in struct-declaration order, signed as raw UTF-8 bytes, not a hash. For example, withdrawal, settlement, transfer, and multisig-add flows sign their inner payload, while order create/replace use the order action’s own signable object. Cancels are not signed. The exact byte layout (including how optional fields are serialized) must match or verification fails; use an SDK unless you are reproducing it deliberately. Optional account multisig registers weighted co-signers (Ed25519 / secp256k1 / P-256 / WebAuthn) with per-permission-level thresholds; manage them via the /multisig/* endpoints. See Account multisig.

Accounts

Balances and positions live in sub-accounts (the Funding account, cross-margin accounts, and isolated-margin accounts; see account types). Orders target a sub-account index plus a spot-vs-margin flag. GET endpoints return data across all of the caller’s sub-accounts and accept an optional sub-account filter.

Identifying assets and markets

Markets and assets are identified by asset_id, not by a ticker symbol. An asset_id is either a protocol index ("18") or, for chain-specific tokens, "<token address>@<chain id>". The reserved index 0 is USD: the wire value is "0"/Index(0), and client symbol resolution should display it as USD.
  • GET /markets - a paginated markets array sorted by asset_id (price/quantity decimals, leverage, tick and min size, fees, and the is_spot_enabled / is_margin_enabled flags). Filter with market_type=spot|margin.
  • GET /registry/assets - returns the cached CE asset config map for index assets. It returns 503 until the first CE snapshot; the JSON is nested by asset index and chain-address key, and each row includes the token address and admission caps.
To attach a human-readable symbol, resolve the token onchain: take the token address and chain id from GET /registry/assets (the chain-address key encodes the chain id; the row address is the token address), or use the address@chain already inside a chain-specific asset_id. Then read the token contract’s symbol/name onchain, for example ERC-20 symbol() / name() on EVM chains. An index asset absent from /registry/assets has no onchain token to read and cannot be mapped to a symbol from the API alone; do not infer one.

Identifiers by API surface

Field and schema names that contain canonical, such as spot_canonical_balances, canonical_amount and CanonicalAmount, refer to native assets, which were formerly called canonical assets.

Amounts

Internally, all balances are normalized to 18 decimals. On the wire, request amounts are decimal strings. Encode them yourself, or use an SDK, which encodes for you:
  • Settlement, withdrawal, and transfer request amounts (amount, amount_in, amount_out, transfer_amount, max_fee) are canonical base-10 integer strings with no 0x and no leading zeros (e.g. "1000000000000000000"). Hexadecimal letters are rejected.
  • Simulate amounts (trade.size, trade.limit_price, pending_transfers[].amount) are decimal strings in human units (e.g. "50.0"); the server scales them to 18 decimals.

Conventions

  • Server time: public GET /time returns the OMS clock as server_time_ns and server_time_ms, both from one reading since the Unix epoch. Milliseconds are nanoseconds divided by 1,000,000, rounded down. Preserve integer precision when parsing server_time_ns; JavaScript clients can use server_time_ms for clock comparisons. This route shares the public request budget with /markets.
  • Pagination: zero-based page plus limit. Defaults and caps vary per endpoint; see the endpoint reference. User orders are sorted newest first by timestamp_ns, then order_id descending; user trades are sorted newest first by timestamp_ns, then trade_id descending; positions are sorted by sub_account_index, then asset_id; funding history is sorted by timestamp_ns descending with no secondary tie-breaker defined today.
  • Rate limits return HTTP 429 with code RATE_LIMITED and retryable: true. See Rate limits for the cost model. Timed request-budget and sign-in refusals include Retry-After (whole seconds, rounded up, at least 1) and error.details.retry_after_ms (milliseconds, rounded up). A request too costly for its bucket and a stream-cap refusal carry neither hint.
  • Client deadlines: use more than 5 seconds for orderbook/clearing-engine proxy writes such as orders, withdrawals, and settlements; use more than 15 seconds for GET /withdrawal/status/{user_id}. For pure OMS reads, pick a shorter deadline that fits your latency budget and retry policy.
  • Per-asset risk parameters: GET /registry/risk-parameters; deposit contract addresses: GET /registry/vaults.
  • Four independent nonce families, never interchangeable: session-auth - the value from GET /nonce/{user_id}, signed and exchanged at POST /auth; chain actions (deposits, withdrawals, settlements) - independent per user, per chain, and per action type, read from the onchain deposit contract counters; a settlement signs its nonce in inner; account actions (transfers, clear-position, token liability repayment, withdrawal resume) - chosen by the client, signed in inner, and strictly increasing per user and per action type; transfers are counted per source account and clear-position per trading account; account multisig config - config_nonce, returned as ce_nonce by GET /nonce/{user_id} and bumped on each successful /multisig/* change.
  • Order-level rules (ID format, batch limits, cancel semantics) are in Orders.
  • Deprecation/versioning: GET /solvency/user/{user_id} returns Deprecation: true. Tplus does not currently publish a formal API versioning or deprecation policy.

Rate limits

See Rate limits for the budgets, request costs, connection caps and retry behavior. With rate limiting enabled, an OMS or MDS REST request that reaches its per-user bucket returns X-RateLimit-Cost and X-RateLimit-Remaining, including on errors after charging and on 429. Cost is the request’s attempted cost in units. Remaining is the whole capacity left in that user’s bucket when the reply is prepared, including refill, using the policy and tier that checked the request. It never reveals a global budget. An ordinary request costs 2 units; a batch of 10 items costs 15. A user-bucket refusal spends no units. A global refusal happens after the user charge, so its Remaining includes that charge. Public routes, operator-signed routes, requests refused before the user check (such as a missing token), unpriced routes, and requests with limiting disabled carry neither header. Both headers are exposed to browsers by OMS, MDS and the gateway. Response bodies and Control WebSocket replies do not gain usage fields. Use error.details.retry_after_ms for precise pacing after a timed 429. Retry-After rounds that value up to seconds. Request-budget waits come from the refusing bucket; sign-in limits report the time left in the IP window, and a block after a reverted match the time left in the block. A batch that cannot fit its bucket must be split, and a stream-cap refusal needs a slot to close: neither has a retry time. A match the clearing engine reverts because your order was at fault also rate limits you for a while. See Reverted matches. Rate-limit budgets are measured in limiter units replenished per second, not raw request counts. Each OMS and MDS instance has independent authenticated and unauthenticated global budgets, plus per-user default and market_maker tiers. Authenticated user requests debit their per-user bucket first and then the authenticated global bucket, so a request rejected by its per-user limit does not consume shared capacity. Public requests and charged authentication failures debit only the unauthenticated bucket. Exhausting either global bucket does not consume the other one’s allowance. The OMS assigns the market_maker tier to designated market makers (DMMs), from the account’s live is_mm state; authenticated MDS reads use the default tier. In [rate_limit], max_queries_per_second sets the authenticated global budget and preserves the existing configured value (default: 5,000). max_unauthenticated_queries_per_second sets the public budget and defaults to 1,000 when omitted. At the ordinary cost of 2 units, this public allowance supports 500 requests per second across all public callers of that instance. These are initial tuning values, not measured service capacity; the default combined allowance is 6,000 units per second. Existing enabled settings and per-user budgets are unchanged. The public bucket also covers OMS GET /market/{id}, GET /asset/{id}, GET /funding-rate/{id}, and GET /funding-rate/history. The default costs are 2 units for an ordinary action, 1 for a single cancel, 50 for cancel-all, and 1.5 per bulk item rounded up (never below the ordinary-action cost). For example, a 10-order batch costs ceil(10 × 1.5) = 15 units. MDS position-basis and sub-account snapshot reads default to 2 units; paginated user trade and order history reads default to 25 units. Public MDS reads use the ordinary-action cost and only the unauthenticated global bucket. OMS WebSocket control messages use the same action costs and authenticated budgets as REST. Concurrent OMS WebSocket streams are capped per user (defaults: 10 for the default tier and 20 for DMMs); an upgrade past the cap is refused with 429 RATE_LIMITED, a message stating the limit that applies to the user, and that limit in details.max_ws_streams. Budgets, costs and stream caps can change without a restart; a change starts fresh limiter buckets. Lowering a WebSocket cap affects new stream acquisitions and does not close existing streams.

Errors

REST errors share one envelope:
code is a stable SCREAMING_SNAKE_CASE string, message is human-readable, retryable says whether the same request might succeed later, and details is present on some codes. Common codes: INVALID_REQUEST, UNAUTHORIZED, TOKEN_EXPIRED, TOKEN_EVICTED, INSUFFICIENT_MARGIN, INSUFFICIENT_INVENTORY, REDUCE_ONLY_WOULD_INCREASE, WOULD_CROSS, ORDER_EXPIRED, ORDER_NOT_FOUND, MARKET_NOT_FOUND, ALREADY_CANCELLED, REQUEST_TOO_OLD; the full set is in the API spec. A malformed body is rejected with 400 before auth runs; rate-limited requests return 429. When the OMS sheds load it returns 503 with code SERVER_BUSY (retryable: true) and the suggested delay in details.retry_after_ms. The global overload gate covers every route except the health probes and also sends a Retry-After header in whole seconds; order create and replace can additionally reject one overloaded market, without the header. While the OMS is still bootstrapping, most mutating routes return 503 with code WARMING_UP (retryable: true). MDS history reads return 503 with code SERVICE_UNAVAILABLE (retryable: true) when persisted history cannot be read.

Finalized fills

Positive acknowledgments are optimistic: accepted for processing does not mean finalized. A CE-proxy endpoint reports a clearing-engine rejection as an error status, never as a 200: 400 CE_REJECTED, except settlement init, which gives each rejection kind its own code. An accepted order or matched fill is not final until the clearing engine finalizes it, and may still be reverted. The WebSocket streams carry the Confirmed, Finalized and Rollbacked (reverted) statuses, with the revert reason in rollback_reason (the at-fault party sees its own reason; counterparties see CounterpartyAtFault). Authenticated MDS user history can include Confirmed and Rollbacked trades.

SDKs

Python: tpluspy on PyPI. Async REST/WS clients, typed models, Ed25519 signing; optional [evm] extra for onchain workflows.