unsubscribeFromChannel
Stop receiving real-time market data updates for a specific trading pair and channel on Bitget exchange. Specify channel type and symbol to end WebSocket subscriptions.
Instructions
Unsubscribe from a WebSocket channel
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| channel | Yes | Channel name (ticker, books, etc.) | |
| symbol | Yes | Trading pair symbol | |
| instType | No | Instrument type (default: SPOT) |
Implementation Reference
- src/server.ts:531-542 (handler)Handler for unsubscribeFromChannel tool: parses arguments, calls wsClient.unsubscribe, and returns success message.case 'unsubscribeFromChannel': { const { channel, symbol, instType = 'SPOT' } = args as any; this.wsClient.unsubscribe(channel, symbol, instType); return { content: [ { type: 'text', text: `Unsubscribed from ${channel} for ${symbol} (${instType})`, }, ], } as CallToolResult; }
- src/server.ts:281-293 (registration)Tool registration including name, description, and input schema definition in the listTools handler.{ name: 'unsubscribeFromChannel', description: 'Unsubscribe from a WebSocket channel', inputSchema: { type: 'object', properties: { channel: { type: 'string', description: 'Channel name (ticker, books, etc.)' }, symbol: { type: 'string', description: 'Trading pair symbol' }, instType: { type: 'string', enum: ['SPOT', 'UMCBL'], description: 'Instrument type (default: SPOT)' } }, required: ['channel', 'symbol'] }, },
- src/api/websocket-client.ts:134-151 (helper)Core unsubscribe implementation in BitgetWebSocketClient: constructs unsubscribe message, removes local subscription tracking, sends to WS if connected.unsubscribe(channel: string, symbol: string, instType: 'SPOT' | 'UMCBL' | 'DMCBL' = 'SPOT'): void { const subscription: WSSubscription = { op: 'unsubscribe', args: [{ instType, channel, instId: symbol }] }; const subKey = `${instType}:${channel}:${symbol}`; this.subscriptions.delete(subKey); if (this.isConnected && this.ws) { logger.debug('Unsubscribing from channel', { channel, symbol, instType }); this.ws.send(JSON.stringify(subscription)); } }