unsubscribe - Cosmos
Example code for the unsubscribe JSON-RPC method. Complete guide on how to use unsubscribe JSON-RPC in GetBlock Web3 documentation.
Parameters
Parameter
Type
Required
Description
Request Example
# WebSocket-only method. Use wscat (or similar) to connect first:
wscat -c 'wss://go.getblock.io/<ACCESS-TOKEN>/websocket'
# Then send:
{"jsonrpc": "2.0", "method": "unsubscribe", "params": {"query": "tm.event='NewBlock'"}, "id": "getblock.io"}import WebSocket from 'ws';
const ws = new WebSocket('wss://go.getblock.io/<ACCESS-TOKEN>/websocket');
ws.on('open', () => {
ws.send(JSON.stringify({
"jsonrpc": "2.0",
"method": "unsubscribe",
"params": {
"query": "tm.event='NewBlock'"
},
"id": "getblock.io"
}));
});
ws.on('message', (data) => {
console.log(JSON.parse(data.toString()));
});Response Example
{
"jsonrpc": "2.0",
"id": "getblock.io",
"result": {}
}Response Parameters
Field
Type
Description
Use Cases
Error Handling
Status Code
Error Message
Cause
SDK Integration
Last updated
Was this helpful?