WS Channels
The Coinbase Advanced Trade Market Data WebSocket feed provides the following channels:
| Channel | Description |
|---|---|
status | Sends all products and currencies on a preset interval |
ticker | Real-time price updates every time a match happens |
ticker_batch | Real-time price updates every 5000 milli-seconds |
level2 | All updates and easiest way to keep order book snapshot |
user | Only sends messages that include the authenticated user |
Refer to the documentation on subscribing to a WebSocket channel.
Status Channel
The status channel sends all products and currencies on a preset interval.
// Request
{
"type": "subscribe",
"channel": "status"
}
// Status Message
{
"type": "status",
"products": [
{
"id": "BTC-USD",
"base_currency": "BTC",
"quote_currency": "USD",
"base_min_size": "0.001",
"base_max_size": "70",
"base_increment": "0.00000001",
"quote_increment": "0.01",
"display_name": "BTC/USD",
"status": "online",
"status_message": null,
"min_market_funds": "10",
"max_market_funds": "1000000"
}
]
}
Ticker Channel
The ticker channel provides real-time price updates every time a match happens. It batches updates in case of cascading matches, greatly reducing bandwidth requirements.
// Request
{
"type": "subscribe",
"product_ids": [
"ETH-USD",
"BTC-USD"
],
"channel": "ticker"
}
// Ticker messsage
{
"type":"ticker",
"sequence":29912240,
"product_id":"BTC-USD",
"price":"40552.26",
"volume_24h":"0.43526841",
"low_24h":"40552.26",
"high_24h":"40662.06"
}
Ticker Batch Channel
The ticker_batch channel provides latest price updates every 5000 milliseconds (5 seconds) if there is a change. It has the same JSON message schema as the ticker channel.
// Request
{
"type": "subscribe",
"product_ids": [
"ETH-USD",
"BTC-USD"
],
"channel": "ticker_batch"
}
Level2 Channel
The level2 channel guarantees delivery of all updates and is the easiest way to keep a snapshot of the order book.
// Request
{
"type": "subscribe",
"product_ids": [
"ETH-USD",
"BTC-USD"
],
"channel": "level2"
}
Subscribe to the level2 channel to guarantee that messages are delivered and your order book is in sync.
The level2 channel sends a message with fields, type ("snapshot" or "update"), product_id, and updates. The field updates is an array of objects of {price_level, new_quantity, event_time, side} to represent the entire order book. Theevent_time property is the time of the event as recorded by our trading engine.
The new_quantity property is the updated size at that price level, not a delta. A new_quantity of "0" indicates the price level can be removed.
// Example:
{
"type": "update", // or "snapshot"
"product_id": "BTC-USD",
"updates": [
{
"side": "bid",
"new_quantity": "10101.80000000",
"price_level": "0.162567",
"event_time": "2019-08-14T20:42:27.265Z",
}
]
}
User Channel
The user channel only sends messages for an authenticated user. Consequently, you need to be authenticated to receive any messages.
The user channel sends updates on all of a user's open orders, including all subsequent updates of those orders.
Subscribing to the User channel returns all OPEN orders, batched by 50, in the first few messages of the stream. For example, if you have 109 orders, you will get a snapshot containing 50 orders, followed by a patch of 50 orders, followed by a patch of 9 orders. To know when all of your open orders are returned, look for the first message with less than 50 orders.
// Request must contain user_id
{
"type": "subscribe",
"channel": "user",
"product_ids" :["BTC-USD"]
}
// User message
{
"type": "Update", // Or "Snapshot"
"updates": [
{
"order_id": "kfhdhj3-3mf845jdl3-dj4",
"client_order_id": "jd93jd8dj-dje73hj-djdr74",
"cumulative_quantity": "0.162567",
"leaves_quantity": "45042",
"avg_price":"10101.80000000",
"total_fees": "10.20",
"status": "OPEN",
}
]
}
| Field | Description |
|---|---|
order_id | Unique identifier of order |
client_order_id | Unique identifier of order specified by client |
cumulative_quantity | Amount the order is filled, in base currency |
leaves_quantity | Amount remaining, in same currency as order was placed in (quote or base) |
avg_price | Average filled price of the order so far |
total_fees | Commission paid for the order |
status | Can be one of: |
|
See Also:
Was this helpful?