Use websockets

Receive Messages from the aleph server with WebSockets.


// Websocket URL:
// "wss://<TARGET SERVER>/api/ws0/messages?
// query_1=value&query_2=value"

// Example url:
// "wss://
// msgType=POST&contentTypes=chat"

const url = 'wss://'

const connection = new WebSocket(url) 

connection.onmessage = (e) => { 

Only one msgType can be queried at a time. All other query parameters are comma-separated strings if multiple values are passed.

If multiple values are passed for one query parameter, messages that match at least one of the values will be returned.

If multiple query parameters are passed, messages that match ALL conditions will be returned.

Query parameters

Query parametersDescription


Message type. Value: POST, AGGREGATE, or STORE


Addresses listed in the

  • content address (item_content.address)

  • or sender (sender) attribute of the Message.

If multiple addresses are passed, any message with one of the queried addresses in the content address or sender attribute will be returned.


Refs listed in content refs (item_content.ref)


Message content types (item_content.type)


Message channel.


Message content content tag. (item_content.content.tags).

If multiple tags are passed, messages with at least one of the tags present in the content content tags will be returned.


hashes listed in the item hash(item_hash) or transaction hash (tx_hash)

time.startDate & time.endDate

Filtering messages on the time attribute (time).

If only the start date is passed, messages with "time" being greater than the start date will be returned.

If only the end date is passed, messages with "time" being less than the end date will be returned.

If both start and end dates are passed, messages with "time" in between the start date and end date will be returned.


Default: 10

The number of Messages to retrieve.

The default number returned is 10 if none is passed. Minimum #: 0, Maximum #: 200. Values outside this range will be ignored.

Last updated