Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

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-sdk

The equivalent commands for the other package managers are:

npm install txflow-typescript-sdk
yarn add txflow-typescript-sdk

Installing 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:

ClientPurposeSigner required
sdk.infoRead market and account state through POST /infoNo
sdk.exchangeSign and submit actions through POST /exchangeYes
sdk.subscriptionsStream real-time channels over /wsNo
sdk.apiSubscriptionsStream candles and Outcome order results over /api-wsNo

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