The Trading API is in preview. It is currently available in Sandbox only, and not yet in Production. In Sandbox, orders are simulated against a fixed order book: no balance moves, no transaction is created and the orders you create are not stored. Reads are served from six sample orders instead.
Available endpoints
The Trading API uses the same OAuth 2.0 token endpoint and credentials as the Core API, with its own scopes:
trading.prices:create, trading.orders:create and trading.orders:read.
Assets and pairs
An order trades one asset for another, and the pair is what says how to read its amounts. The base asset is the one bought or sold, and the quote asset is the one prices are expressed in. ForBTC and USD, BTC is the base asset and USD the quote asset.
All amounts are decimal strings and carry no asset. A quantity is in the base asset, a price is in the quote asset per one unit of the base asset, and a notional is a gross traded amount in the quote asset.
Not every pair can be traded. The API does not list the pairs yet: a request for one that cannot be traded is refused with a 409 asset_pair_not_supported.
The bounds an order must respect, such as the smallest quantity it accepts or the decimals it allows, are not published yet. An order that breaks one is refused with a
409 whose details name the rule and its limit, so build against those errors for now. The bounds are published once the venue reports them.Price estimates
A price estimate is the volume-weighted price at which aquantity of the base asset would trade on a side, in the quote asset, calculated by walking the order book. It is nonbinding: nothing is created, nothing is reserved, and two requests a moment apart can differ.
The response has only the price and the snapshotAt time of the order book snapshot it was calculated from. It is not the time of the request.
If the order book cannot cover the quantity, the request fails with the depth that is available, so you can retry with a smaller quantity. The estimate does not include fees.
Orders
An order trades between two accounts of the same user. Theorigin account is debited and the destination account is credited with the proceeds. The origin is the base asset account on a sell and the quote asset account on a buy, and the destination is the other one. The assets of the two accounts are the pair the order trades, so a sell whose origin account does not hold the base asset, or a buy whose destination does not, is refused with asset_pair_not_supported.
Type and side
typeismarket, which trades at the price the book offers within a protective cap, orlimit, which trades only at itspriceor better.priceis required on a limit order and not allowed on a market order.sideisbuyorsellof the base asset.- The order is sized by its
quantity, a decimal string in the base asset.
Fill or kill
Orders are fill-or-kill:timeInForce is fok, and either the whole quantity trades or nothing does. A fill-or-kill order is finished when the create returns, so there is no cancel.
Retrying safely
TheclientOrderId is an idempotency key chosen by you, up to 64 characters:
- Replaying a
clientOrderIdwith the same payload returns the existing order with a200, instead of the201of the first request. - Reusing a
clientOrderIdwith a different payload is refused with a409. - After a
5xxor a timeout, replay the sameclientOrderIdbefore anything else: the replay returns the order if it was placed and places it if it was not.
Order lifecycle
The contract also defines an
open status for orders that stay active. A fill-or-kill order is never open.
Timeline
Thetimeline lists what happened to the order, oldest first.
Execution and trades
execution holds what traded: quantity, notional and averagePrice, which are zeros and null when nothing traded. The notional is the gross executed amount, before fees. A filled order has one trade, returned by List order trades, and it is a view of the transaction that booked it.
Testing in Sandbox
Sandbox simulates one pair,BTC and USD, against a fixed order book with 5 BTC on each side. A seller meets a best bid of 61950.12 and a buyer a best ask of 62010.30, and the average price gets 0.1% worse for each BTC traded. Every order type and side is simulated.
You need a test user with a BTC account and a USD account. Send a new clientOrderId with every order, and a quantity the venue accepts.
Some quantities force an outcome the book cannot produce by itself:
A limit that the book does not reach is
canceled with limit-price-not-met, and a quantity deeper than the book is refused with insufficient-book-depth.