Reference
The Streaming API allows you to subscribe to the events related to the corresponding entities via the WebSocket interface. As we prioritize even delivery over redundancy, in some rare cases, the same event may arrive twice. Make sure to track the unique source of the event, like deploy hash and event id, where needed.
The update events are emitted only when the direct entity properties are changed. Changes in the optional fields will not trigger a WebSocket message.
Streaming API connection may close when a new version of the API is deployed; thus, make sure to include the reconnection logic in your code.
Format
The messages are sent as JSON objects with the following properties:
Property | Type | Description |
---|---|---|
|
| Action name |
|
| Affected entity |
|
| Timestamp of the network object, deploy or block, that triggered the action |
|
| Extra data provided with the message. This property is optional. |
Persistent sessions (beta)
Applications may experience failures on their end, resulting in closing the WebSocket connections. To ensure no messages are lost during the downtime, it's possible to declare the WebSocket connection as "persistent" by adding a Persistent-Session
header. Reconnecting with the same Persistent-Session
header value would connect the application to the same queue containing the messages received during the downtime.
Persistent Streaming API sessions not available for the "Free" tier
Streams
Below is a full list of the available CSPR.cloud Streaming API streams:
Stream | Actions | Description |
---|---|---|
| Notifies about newly created or updated Accounts | |
| Notifies about newly created Blocks | |
| Notifies about newly created Contracts | |
| Notifies about newly created or updated Contract packages | |
| Notifies about newly emitted contract-level events | |
| Notifies about newly created Deploys | |
| Notifies about newly created Fungible token actions | |
| Notifies about newly created or updated NFTs | |
| Notifies about newly created NFT actions | |
| Notifies about newly created Transfers |
Prerequisites
To follow Streaming API examples you'll need to install the wscat
NPM utility:
Last updated