Websocket API

If you connect to the WebSocket endpoint, you can subscribe to some channels and receive updates about objects.

Updates come in the form of a full object and can substitute existing objects by their object identifier.

The common form of messages received is

{
    "channel": // channel name
    "data": // depends on the channel
}

In several subscriptions, specifically market, trades, userOrders, orderbook, userFills (in other words, except candles), the client receives history objects as events, which are similar to those from calling the corresponding HTTP API with the default limit parameter.

Subscriptions

trades

Subscription parameters

Parameter
Type
Description

channel

string "trades"

the channel name

market

string

a market contract address

Event data

A trade object

userOrders

Subscription parameters

Parameter
Type
Description

channel

string "userOrders"

the channel name

market

string

a market contract address

user

string

a user address

Event data

An order object.

orderbook

Subscription parameters

Parameter
Type
Description

channel

string "orderbook"

the channel name

market

string

a market contract address

aggregation

number

an order book level of aggregation

Event data

An object:

Property
Type
Description

aggregation

string represents an aggregation of the market

an order book aggregation level

levels

object with fields"asks" and "bids"

Each field is a sorted array of order book level objects; asks are sorted in ascending order by price, and bids are sorted in descending order.

userFills

Subscription parameters

Parameter
Type
Description

channel

string "userFills"

the channel name

market

string

a market contract address

user

string

a user address

Event data

An object with keys representing user addresses and values as arrays of order fill objects.

candles

Subscription parameters

Parameter
Type
Description

channel

string "candles"

the channel name

market

string

a market contract address

resolution

string

one of the candle object's resolutions

Event data

An object with keys representing a resolution and the values being candle objects.

market

Subscription parameters

Parameter
Type
Description

channel

string "market"

the channel name

market

string

a market contract address

Event data

An array of market objects.

Last updated