GraphQL 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
Section titled “Available Subscriptions”| Subscription | Source | Arguments |
|---|---|---|
tradeSignal | Trading engine (Redis channel tokenbot.trading.signals) | strategyId (optional filter) |
orderbookUpdate | Market-maker engine (Redis channel tokenbot.mm.orderbook) | exchangeId!, symbol! |
ping | Timer only (not Redis) — an unauthenticated smoke-test of the WebSocket transport | intervalMs (default 5000, 50–60000) |
Both tradeSignal and orderbookUpdate are backed by Redis pub/sub: the bot
engines publish to the channels above and the GraphQL server fans out to
WebSocket subscribers. ping is a transport health check only.
Connecting
Section titled “Connecting”Connect to the /graphql WebSocket endpoint:
wss://gql-api.tokenbot.com/graphqlThe 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.

