Installation
The package name is txflow-typescript-sdk. It supports Node.js 18 or later and publishes ESM, CommonJS, and TypeScript declarations from the same entry point.
Install the package
pnpm add txflow-typescript-sdkThe equivalent commands for the other package managers are:
npm install txflow-typescript-sdk
yarn add txflow-typescript-sdkInstalling from the registry is the only supported distribution. The published package ships prebuilt ESM and CommonJS bundles with their declaration files, so no build step is needed on your side.
Initialize a client
import { TxFlow } from 'txflow-typescript-sdk'
const sdk = new TxFlow('testnet')TxFlow exposes four clients:
| Client | Purpose | Signer required |
|---|---|---|
sdk.info | Read market and account state through POST /info | No |
sdk.exchange | Sign and submit actions through POST /exchange | Yes |
sdk.subscriptions | Stream real-time channels over /ws | No |
sdk.apiSubscriptions | Stream candles and Outcome order results over /api-ws | No |
The two subscription clients connect lazily on first access, so an HTTP-only integration never opens a WebSocket. Streaming additionally requires a global WebSocket, which browsers and Node.js 22 or later provide — on Node.js 18–21 inject one, as described under Subscriptions.
Always select the network explicitly. Public integrations use only testnet and mainnet:
const testnetSdk = new TxFlow('testnet')
const mainnetSdk = new TxFlow('mainnet')Use testnet while developing and validating signed flows. Switch to mainnet only after the complete integration has been tested.
Override the endpoint
Pass a configuration object when using a local proxy or a dedicated RPC endpoint:
const sdk = new TxFlow({
network: 'testnet',
baseUrl: 'http://localhost:8080',
timeout: 30_000,
})network still selects the signing domain. baseUrl only replaces the HTTP endpoint, so it must point to a node on the same network. The WebSocket endpoints have their own overrides, wsUrl and wsApiUrl.
Verify the installation
const meta = await sdk.info.perpMeta()
console.log(
meta.universe.map(({ index, name }) => ({ index, name })),
)Info calls return the response body directly. HTTP and transport failures are thrown as typed SDK errors; signed exchange actions additionally return a business-level status that must be checked.
perpMeta queries the platform's default perpetual exchange. Pass dex only to scope the universe to a specific exchange.
Next steps
- Quickstart — submit a testnet order
- Authentication — configure an owner wallet or agent key
- Subscriptions — stream real-time channels
- Advanced usage — inject a custom HTTP transport