@trdrs/sdk is generated from the same OpenAPI document this site documents, so it has a method
for every route and can’t describe a route the engine doesn’t serve. It has no dependencies and
runs in Node and in the browser, though a key never belongs in browser code. By the end you have
a client, a first call, a stream and refusals handled by name.
Install it
The SDK isn’t on npm yet, so build it from its repository:Create a client
Create one client when your server starts and reuse it. Pass the keys your server holds, from its secret environment.Make a call
Methods are grouped the way the API reference groups routes, and named after each route’s title. Parameters and the request body go in one object.clientOrderId, the SDK makes one, so a retry of the same call can’t place a
second order. When your app retries on its own, mint the id yourself and pass it every time.
Each method carries the route’s description in its documentation comment, so your editor shows
the rules while you write the call.
Read a stream
A stream is an async iterator. It starts with the whole current picture on every connect, then sends changes.Handle refusals by name
A refusal throws an error class named after it, so your code tells a locked account from a failure without reading status codes.Stay in step with the API
The generated methods and types are committed to the repository, so nothing is downloaded when you build. When the engine adds a route,npm run generate writes the new methods from the served
contract, and the SDK’s own test fails if the committed code ever differs from the contract.
Next steps
Place your first order
Follow a whole order from risk check to flatten, with curl and the SDK side by side.
Build a front end
Use the SDK on your server behind your own trading screens.