subscribeNewBlock - Dash
Subscribes to new block notifications over WebSocket. After subscribing, the server pushes a message with the height and hash of each new block as it is indexed.
This is a WebSocket subscription. After the initial acknowledgement, the server pushes notifications until you unsubscribe or disconnect.
Parameters
This method takes no parameters.
Message
bashwscat -c wss://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>
# then send:
{
"id": "getblock.io",
"method": "subscribeNewBlock",
"params": {}
}Response
json{
"id": "getblock.io",
"data": {
"subscribed": true
}
}Notifications
While subscribed, the server pushes messages of the form:
json{
"id": "getblock.io",
"data": {
"height": 2100001,
"hash": "000000000000000344a8914b400c4d5e572ba8e1c25388f012104ec7d9b81b99"
}
}Response Fields
| Field | Type | Description |
|---|---|---|
| subscribed | boolean | Confirms the subscription is active |
| height | number | Height of the new block (in notifications) |
| hash | string | Hash of the new block (in notifications) |
Use Cases
- Chain Following: React to each new block live
- Indexers: Trigger ingestion on new blocks
- Dashboards: Live height display
Error Handling
| Error | Message | Description |
|---|---|---|
| error | Subscription error | The subscription could not be established |
| 403 / RBAC: access denied | Access denied | The GetBlock access token is missing or incorrect |