unsubscribeFromChannel
Stop receiving real-time updates from a specific WebSocket channel on the Bitget crypto exchange. Specify the channel name, trading pair, and instrument type to unsubscribe.
Instructions
Unsubscribe from a WebSocket channel
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| channel | Yes | Channel name (ticker, books, etc.) | |
| instType | No | Instrument type (default: SPOT) | |
| symbol | Yes | Trading pair symbol |
Input Schema (JSON Schema)
{
"properties": {
"channel": {
"description": "Channel name (ticker, books, etc.)",
"type": "string"
},
"instType": {
"description": "Instrument type (default: SPOT)",
"enum": [
"SPOT",
"UMCBL"
],
"type": "string"
},
"symbol": {
"description": "Trading pair symbol",
"type": "string"
}
},
"required": [
"channel",
"symbol"
],
"type": "object"
}
Implementation Reference
- src/server.ts:531-542 (handler)Handler for the unsubscribeFromChannel tool. Extracts parameters from args and calls this.wsClient.unsubscribe(channel, symbol, instType), then 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)Registration of the unsubscribeFromChannel tool in the listTools response, including name, description, and input schema.{ 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)The core unsubscribe method in BitgetWebSocketClient that constructs and sends the unsubscribe message to the WebSocket server, and removes from local subscriptions.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)); } }