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

FieldTypeDescription
subscribedbooleanConfirms the subscription is active
heightnumberHeight of the new block (in notifications)
hashstringHash 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

ErrorMessageDescription
errorSubscription errorThe subscription could not be established
403 / RBAC: access deniedAccess deniedThe GetBlock access token is missing or incorrect