> For the complete documentation index, see [llms.txt](https://gitbook-docs.coinmetrics.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook-docs.coinmetrics.io/cm-api-spec/timeseries/timeseries-stream/market-orderbooks.md).

# Market orderbooks

Returns a WebSocket stream of orderbooks for specified markets.\
Orderbooks are delivered using a sequence of `snapshot` and `update` messages.\
Zero value of the `size` response field for `asks` or `bids` means negative `update`.\
If you are falling behind (slow client) you will get `warning` message first, then `error` message and disconnection will happen.

```json
{"openapi":"3.0.2","info":{"title":"Coin Metrics API v4","version":"4.0.0"},"tags":[{"name":"Timeseries stream","description":"WebSocket endpoints for getting a real-time stream of metrics, market data, indexes and other time series data.\n\n**Endpoints on this page:**\n- `GET /timeseries-stream/asset-metrics` — Asset metrics\n- `GET /timeseries-stream/asset-quotes` — Asset quotes\n- `GET /timeseries-stream/index-levels` — Index levels\n- `GET /timeseries-stream/market-candles` — Market candles\n- `GET /timeseries-stream/market-contract-prices` — Market contract prices\n- `GET /timeseries-stream/market-liquidations` — Market liquidations\n- `GET /timeseries-stream/market-openinterest` — Market open interest\n- `GET /timeseries-stream/market-orderbooks` — Market orderbooks\n- `GET /timeseries-stream/market-quotes` — Market quotes\n- `GET /timeseries-stream/market-trades` — Market trades\n- `GET /timeseries-stream/pair-quotes` — Pair quotes"}],"servers":[{"url":"wss://api.coinmetrics.io/v4"}],"security":[{"api_key":[]}],"components":{"securitySchemes":{"api_key":{"description":"Coin Metrics API key can be specified as `?api_key=` query parameter.","in":"query","name":"api_key","type":"apiKey"}},"parameters":{"MarketId":{"description":"Comma separated list of markets or market patterns like `exchange-*` or `exchange-*-spot` or `*USDT-future`.<br/> Use a corresponding `/catalog-all-v2/market-{dataType}` endpoint for the full list of supported markets for a given data type.","in":"query","name":"markets","required":true,"schema":{"type":"array","items":{"type":"string"}},"explode":false},"StreamingBookDepth":{"description":"Book depth limit.","in":"query","name":"depth_limit","schema":{"default":100,"enum":[100,"full_book"],"type":"string"}},"Backfill":{"description":"What data should be sent upon a connection.<br/> By default the latest values are sent just before real-time data.","in":"query","name":"backfill","schema":{"type":"string","default":"latest","enum":["latest","none"]}},"Pretty":{"description":"Human-readable formatting of JSON responses.","in":"query","name":"pretty","schema":{"type":"boolean","default":false}}},"responses":{"StreamingMarketOrderbooks":{"description":"Orderbook WebSocket message.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StreamingMarketOrderbook"}}}}},"schemas":{"StreamingMarketOrderbook":{"allOf":[{"type":"object","properties":{"market":{"$ref":"#/components/schemas/MarketId"},"time":{"$ref":"#/components/schemas/Time"},"coin_metrics_id":{"$ref":"#/components/schemas/OrderBookAndQuoteCoinMetricsId"},"asks":{"$ref":"#/components/schemas/OrderBookAsks"},"bids":{"$ref":"#/components/schemas/OrderBookBids"},"type":{"$ref":"#/components/schemas/OrderBookType"},"collect_time":{"$ref":"#/components/schemas/OrderBookCollectTime"},"cm_sequence_id":{"$ref":"#/components/schemas/cmSequenceId"}},"required":["market","time","coin_metrics_id","asks","bids","type","collect_time","cm_sequence_id"]}]},"MarketId":{"description":"Unique name of the market.","type":"string"},"Time":{"description":"The time in ISO 8601 date-time format. Always with nanoseconds precision.","type":"string","format":"date-time"},"OrderBookAndQuoteCoinMetricsId":{"description":"ID of an order book or quote. It can be generated by Coin Metrics or provided by an exchange. If it is generated by Coin Metrics it is unique. If it is generated by exchange we can't guarantee its uniqueness.","type":"string"},"OrderBookAsks":{"description":"The ask orders on the order book.","items":{"$ref":"#/components/schemas/BookEntry"},"type":"array"},"BookEntry":{"properties":{"price":{"$ref":"#/components/schemas/OrderBookPrice"},"size":{"$ref":"#/components/schemas/OrderBookSize"}},"required":["price","size"],"type":"object"},"OrderBookPrice":{"description":"The limit price of the order on the order book.","type":"string","format":"decimal"},"OrderBookSize":{"description":"The size of the limit order on the order book in units of the base asset.","type":"string","format":"decimal"},"OrderBookBids":{"description":"The bids orders on the order book.","items":{"$ref":"#/components/schemas/BookEntry"},"type":"array"},"OrderBookType":{"description":"Type of the order book.","enum":["snapshot","update"],"type":"string"},"OrderBookCollectTime":{"description":"Time of when the order book was received from the exchange.","type":"string","format":"date-time"},"cmSequenceId":{"description":"The monotonically increasing message number, resets on disconnection.","type":"string"}}},"paths":{"/timeseries-stream/market-orderbooks":{"get":{"summary":"Market orderbooks","description":"Returns a WebSocket stream of orderbooks for specified markets.<br/> Orderbooks are delivered using a sequence of `snapshot` and `update` messages.<br/> Zero value of the `size` response field for `asks` or `bids` means negative `update`.<br/> If you are falling behind (slow client) you will get `warning` message first, then `error` message and disconnection will happen.","operationId":"getTimeseriesStreamMarketOrderbooks","tags":["Timeseries stream"],"parameters":[{"$ref":"#/components/parameters/MarketId"},{"$ref":"#/components/parameters/StreamingBookDepth"},{"$ref":"#/components/parameters/Backfill"},{"$ref":"#/components/parameters/Pretty"}],"responses":{"default":{"$ref":"#/components/responses/StreamingMarketOrderbooks"}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://gitbook-docs.coinmetrics.io/cm-api-spec/timeseries/timeseries-stream/market-orderbooks.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
