Streams

API to manage subscriptions to available streams via websocket.

Available Streams

See below the available streams you can subscribe to:

pub enum StreamSubscription {
    OrderUpdate { product_id: u32, subaccount: H256 },
    Trade { product_id: u32 },
    BestBidOffer { product_id: u32 },
    Fill { product_id: u32, subaccount: H256 },
    PositionChange { product_id: u32, subaccount: H256},
    BookDepth { product_id: u32 },
}

Subscribing to a stream

Connect

WEBSOCKET [SUBSCRIPTIONS_ENDPOINT]

Message

Requires Authentication: Yes.

{
  "method": "subscribe",
  "stream": {
    "type": "order_update",
    "subaccount": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
    "product_id": 1
  },
  "id": 10
}

Connect

WEBSOCKET [SUBSCRIPTIONS_ENDPOINT]

Message

Requires Authentication: No.

{
  "method": "subscribe",
  "stream": {
    "type": "fill",
    "product_id": 0,
    "subaccount": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000"
  },
  "id": 10
}

Response

{
  "result": null,
  "id": 10
}

Unsubscribing

Connect

WEBSOCKET [SUBSCRIPTIONS_ENDPOINT]

Message

{
  "method": "unsubscribe",
  "stream": {
    "type": "order_update",
    "subaccount": "0x7a5ec2748e9065794491a8d29dcf3f9edb8d7c43746573743000000000000000",
    "product_id": 1
  },
  "id": 10
}

Response

{
  "result": null,
  "id": 10
}

Listing subscribed streams

{
  "method": "list",
  "id": 10
}

Response

{
  "result": [
    {
      "type": "default"
    },
    {
      "type": "trade",
      "product_id": 0
    }
  ],
  "id": 10
}

Last updated