> For the complete documentation index, see [llms.txt](https://docs.xpressprotocol.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.xpressprotocol.com/for-developers/api/websocket-api.md).

# Websocket API

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](#trades)
* [userOrders](#userorders)
* [orderbook](#orderbook)
* [userFills](#userfills)
* [candles](#candles)
* [market](#market)

## `trades`

### Subscription parameters

<table><thead><tr><th width="173">Parameter</th><th width="155">Type</th><th>Description</th></tr></thead><tbody><tr><td>channel</td><td>string "trades"</td><td>the channel name</td></tr><tr><td>market</td><td>string</td><td>a market contract address</td></tr></tbody></table>

### Event data

A [trade](/for-developers/api/common-objects.md#trade) object

## `userOrders`

### Subscription parameters

<table><thead><tr><th width="173">Parameter</th><th width="193">Type</th><th>Description</th></tr></thead><tbody><tr><td>channel</td><td>string "userOrders"</td><td>the channel name</td></tr><tr><td>market</td><td>string</td><td>a market contract address</td></tr><tr><td>user</td><td>string</td><td>a user address</td></tr></tbody></table>

### Event data

An [order](/for-developers/api/common-objects.md#order) object.

## `orderbook`

### Subscription parameters

<table><thead><tr><th width="173">Parameter</th><th width="193">Type</th><th>Description</th></tr></thead><tbody><tr><td>channel</td><td>string "orderbook"</td><td>the channel name</td></tr><tr><td>market</td><td>string</td><td>a market contract address</td></tr><tr><td>aggregation</td><td>number</td><td>an order book level of aggregation</td></tr></tbody></table>

### Event data

An object:

<table><thead><tr><th width="173">Property</th><th width="231">Type</th><th>Description</th></tr></thead><tbody><tr><td>aggregation</td><td>string represents an aggregation of the market</td><td>an order book aggregation level</td></tr><tr><td>levels</td><td>object with fields"asks" and "bids"</td><td>Each field is a sorted array of order book <a href="/pages/XzTq7I4ynKs738OPF8w2#orderbook-level">level</a> objects; asks are sorted in ascending order by price, and bids are sorted in descending order.</td></tr></tbody></table>

## `userFills`

### Subscription parameters

<table><thead><tr><th width="173">Parameter</th><th width="193">Type</th><th>Description</th></tr></thead><tbody><tr><td>channel</td><td>string "userFills"</td><td>the channel name</td></tr><tr><td>market</td><td>string</td><td>a market contract address</td></tr><tr><td>user</td><td>string</td><td>a user address</td></tr></tbody></table>

### Event data

An object with keys representing user addresses and values as arrays of [order fill](/for-developers/api/common-objects.md#order-fill) objects.

## `candles`

### Subscription parameters

<table><thead><tr><th width="173">Parameter</th><th width="193">Type</th><th>Description</th></tr></thead><tbody><tr><td>channel</td><td>string "candles"</td><td>the channel name</td></tr><tr><td>market</td><td>string</td><td>a market contract address</td></tr><tr><td>resolution</td><td>string</td><td>one of the candle object's resolutions</td></tr></tbody></table>

### Event data

An object with keys representing a resolution and  the values being [candle](/for-developers/api/common-objects.md#candle) objects.

## `market`

### Subscription parameters

<table><thead><tr><th width="173">Parameter</th><th width="193">Type</th><th>Description</th></tr></thead><tbody><tr><td>channel</td><td>string "market"</td><td>the channel name</td></tr><tr><td>market</td><td>string</td><td>a market contract address</td></tr></tbody></table>

### Event data

An array of [market](/for-developers/api/common-objects.md#market) objects.
