Skip to main content
Read what the TypeScript SDK offers before you decide how your code calls the API. Use this page when your server or script is written in TypeScript or JavaScript.
The TypeScript SDK isn’t published: its package isn’t on npm and its repository isn’t public, so nothing on this page installs. Call the API with any HTTP client instead. Every guide shows each call with curl, and the OpenAPI document works with any client generator.
@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. The rest of this page describes the SDK as it’s built.

Create a client

Create one client when your server starts and reuse it. Pass the keys your server holds, from its secret environment.
Each call picks the right key from the contract, so a trading call sends the Trading API key and a pre-registration call sends the pre-registration key without you choosing.

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.
When you leave out 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.
Market streams paint a cached snapshot, apply live bars immediately, and send a repaired snapshot when history finishes. cached: true is display history, not a live price. Stream live data explains the events.

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.
A risk lock is a state to show, not an error to retry. Errors lists every refusal.

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

Put your own trading screens over the API, with your keys on your server.