For the complete documentation index, see llms.txt. This page is also available as Markdown.

Subscriptions

TokenBot exposes real-time subscriptions over graphql-ws. The bot engines publish events to Redis, and the GraphQL server fans them out to WebSocket subscribers.

Available Subscriptions

Subscription
Source
Arguments

tradeSignal

Trading engine (Redis channel tokenbot.trading.signals)

strategyId

orderbookUpdate

Market-maker engine (Redis channel tokenbot.mm.orderbook)

exchangeId, symbol

Connecting

Connect to the /graphql WebSocket endpoint:

wss://gql-api.tokenbot.com/graphql

The handshake is authenticated with the CLI signed-request scheme: the four x-tb-* values are sent in the graphql-ws connectionParams, signed over the canonical string CONNECT\n/graphql\n<timestamp>\n<nonce>\n<sha256("")>. A rejected handshake closes with code 4403. See Authentication for details. The tokenbot CLI does this for you.

subscription {
  tradeSignal(strategyId: "str_123") {
    id
    symbol
    action
    price
    timestamp
  }
}

Note: GraphQL previously ran on AWS AppSync, which exposed a different set of on* subscriptions (e.g. onTradeCreated). AppSync has been retired (PR #148); the subscriptions above are the current ones.

Last updated

Was this helpful?