# View Live Order and Market Data Updates

Source: https://developers.bitgo.com/docs/trade-funded-websocket

## Overview

You can use the Trade WebSocket API to get real-time status updates for market data and trigger messages for:

* **Order books** - Subscribe to a live feed of all outstanding buy and sell orders on the market for specific coins and tokens. Send messages when specific market conditions occur.
* **Trade orders** - Subscribe to live status updates for your trade orders, including individual fills for an order. Send messages when statuses update.

## Prerequisites

* [Get Started](/docs/get-started-intro)
* [Deposit Assets](/docs/deposit-assets)
* [Place Trade Orders](/docs/trade-funded-place-orders)
* Enterprise user with the Trade role
* Access token with the `trade_view` scope

## Cookbook

Need just the steps? Expand the cookbook below to get started:

<Cookbook slug="view-live-order-and-market-data-updates" title="View Live Order and Market Data Updates" />

## Steps

### 1. Subscribe to Order Books

>Endpoint: [Get WebSocket Connection](/reference/tradewebsocketlevel2)

```json API
GET /api/prime/trading/v1/ws

{
  "type": "subscribe",
  "accountId": "f230fdebfa084ffebc7e00515f54603f",
  "channel": "level2",
  "productId": "TBTC-TUSD*"
}
```

#### Step Result

```json
{
  "channel": "level2",
  "type": "snapshot",
  "product": "TBTC-TUSD*",
  "time": "2020-01-01T09:35:26.465Z",
  "bids": [["7001.10", "1.5084"]],
  "asks": [["7002.55", "2.7524"]],
}
```

### 2. Subscribe to Trade Orders

>Endpoint: [Get WebSocket Connection](/reference/tradewebsocketorders)

```json API
GET /api/prime/trading/v1/ws

{
  "type": "subscribe",
  "channel": "orders",
  "accountId": "f230fdebfa084ffebc7e00515f54603f",
}
```

#### Step Result

```json Created
{
  "channel": "order",
  "time": "2019-04-25T01:02:03.045678Z",
  "accountId": "f230fdebfa084ffebc7e00515f54603f",
  "orderId": "14db12f5-4d3d-4fd8-8ced-062aa81bb4bc",
  "clientOrderId": "my-order-1",
  "product": "TBTC-TUSD*",
  "status": "opened",
  "type": "market",
  "side": "buy",
  "quantity": "1.01",
}
```
```json Fill Updated
{
  "channel": "order",
  "time": "2019-04-25T01:02:04.045678Z",
  "accountId": "f230fdebfa084ffebc7e00515f54603f",
  "orderId": "14db12f5-4d3d-4fd8-8ced-062aa81bb4bc",
  "clientOrderId": "my-order-1",
  "product": "TBTC-TUSD*",
  "status": "opened",
  "type": "market",
  "side": "buy",
  "quantity": "1.01",
  "cumulativeQuantity": "0.50",
  "averagePrice": "7090.1",
  "tradeId": "a6a9ab1b-2947-41b7-b44d-4ce61fca8b92",
  "fillQuantity": "0.50",
  "fillPrice": "7090.1",
}
```
```json Order Completed
{
  "channel": "order",
  "time": "2019-04-25T01:02:03.045678Z",
  "accountId": "f230fdebfa084ffebc7e00515f54603f",
  "orderId": "14db12f5-4d3d-4fd8-8ced-062aa81bb4bc",
  "clientOrderId": "my-order-1",
  "product": "TBTC-TUSD*",
  "status": "completed",
  "type": "market",
  "side": "buy",
  "quantity": "1.01",
  "cumulativeQuantity": "1.01",
  "averagePrice": "7090.1",
}
```
```json Order Canceled
{
  "channel": "order",
  "time": "2019-04-25T01:02:03.045678Z",
  "accountId": "f230fdebfa084ffebc7e00515f54603f",
  "orderId": "14db12f5-4d3d-4fd8-8ced-062aa81bb4bc",
  "clientOrderId": "my-order-1",
  "product": "TBTC-TUSD*",
  "status": "canceled",
  "type": "market",
  "side": "buy",
  "quantity": "1.01",
  "cumulativeQuantity": "0.50",
  "averagePrice": "7090.1",
}
```
```json Order Error
{
  "channel": "order",
  "time": "2019-04-25T01:02:03.045678Z",
  "accountId": "f230fdebfa084ffebc7e00515f54603f",
  "orderId": "14db12f5-4d3d-4fd8-8ced-062aa81bb4bc",
  "clientOrderId": "my-order-1",
  "product": "TBTC-TUSD*",
  "status": "error",
  "message": "insufficient fund",
  "type": "market",
  "side": "buy",
  "quantity": "1.01",
  "cumulativeQuantity": "0.50",
  "averagePrice": "7090.1",
}
```

## See Also

[API Reference: Get WebSocket Connection](/reference/tradewebsocketlevel2)
