Skip to main content
Anthid provides Protocol Buffer definitions that can be used to generate Node.js clients for the Streaming API. This guide demonstrates connecting to the Streaming API and receiving real-time broker order and position updates.

Prerequisites

Install the required dependencies.

Download the Protobuf Definitions

Load the Proto Definitions

Authentication

Streaming requests are authenticated using the x-api-key metadata header.

Subscribe to Events

The SubscribeEvents endpoint provides a server-streaming interface suitable for most applications.

Bidirectional Streaming

Backend and long-running services can use StreamEvents to dynamically subscribe and unsubscribe from accounts over an existing connection.

Unsubscribe

To stop receiving events for an account, send an unsubscribe request on the same stream.

Handling Disconnects

Applications should automatically reconnect when a stream closes unexpectedly. After reconnecting:
  1. Create a new stream.
  2. Authenticate using the API key.
  3. Re-subscribe to required trading accounts.
  4. Resume event processing.

TypeScript

The same approach works in TypeScript. Many teams choose to generate strongly typed TypeScript definitions from the Anthid protobuf files during their build process rather than loading protobuf definitions dynamically at runtime.
  • Streaming Overview
  • Python Guide
  • Rust Guide
  • Trading Accounts
  • Orders
  • Positions
  • Ledger
  • Intents