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

string

Action name

data

Entity

Affected entity

timestamp

datetime

Timestamp of the network object, deploy or block, that triggered the action

extra

mixed

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

updated

Notifies about newly created or updated Accounts

created

Notifies about newly created Blocks

created

Notifies about newly created Contracts

created, updated

Notifies about newly created or updated Contract packages

emitted

Notifies about newly emitted contract-level events

created

Notifies about newly created Deploys

created

Notifies about newly created Fungible token actions

created, updated

Notifies about newly created or updated NFTs

created

Notifies about newly created NFT actions

created

Notifies about newly created Transfers

Prerequisites

To follow Streaming API examples you'll need to install the wscat NPM utility:

npm install -g wscat

Last updated