> 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-rest/market-orderbooks.md).

# Market orderbooks

Returns orderbooks for specified markets.\
Results are ordered by tuple `(market, time)`.\
To fetch the next page of results use `next_page_url` JSON response field.

```json
{"openapi":"3.0.2","info":{"title":"Coin Metrics API v4","version":"4.0.0"},"tags":[{"name":"Timeseries REST","description":"Endpoints for fetching metrics, market data, indexes and other time series data.\n\n**Endpoints on this page:**\n- `GET /timeseries/asset-alerts` — Asset alerts (deprecated)\n- `GET /timeseries/asset-chains` — Asset chains (experimental)\n- `GET /timeseries/asset-metrics` — Asset metrics\n- `GET /timeseries/defi-balance-sheets` — DeFi balance sheets (experimental)\n- `GET /timeseries/exchange-asset-metrics` — Exchange-asset metrics\n- `GET /timeseries/exchange-metrics` — Exchange metrics\n- `GET /timeseries/exchange-pair-metrics` — Exchange-pair metrics\n- `GET /timeseries/index-candles` — Index candles\n- `GET /timeseries/index-constituents` — Index constituents\n- `GET /timeseries/index-levels` — Index levels\n- `GET /timeseries/institution-metrics` — Institution metrics\n- `GET /timeseries/market-candles` — Market candles\n- `GET /timeseries/market-contract-prices` — Market contract prices\n- `GET /timeseries/market-funding-rates` — Market funding rates\n- `GET /timeseries/market-funding-rates-predicted` — Predicted Market funding rates\n- `GET /timeseries/market-greeks` — Market greeks\n- `GET /timeseries/market-implied-volatility` — Market implied volatility\n- `GET /timeseries/market-liquidations` — Market liquidations\n- `GET /timeseries/market-metrics` — Market metrics\n- `GET /timeseries/market-openinterest` — Market open interest\n- `GET /timeseries/market-orderbooks` — Market orderbooks\n- `GET /timeseries/market-quotes` — Market quotes\n- `GET /timeseries/market-trades` — Market trades\n- `GET /timeseries/mempool-feerates` — Mempool feerates (deprecated)\n- `GET /timeseries/mining-pool-tips-summary` — Mining pool tips summary (experimental)\n- `GET /timeseries/pair-candles` — Pair candles\n- `GET /timeseries/pair-metrics` — Pair metrics\n- `GET /timeseries/protocol-metrics` — Protocol metrics"}],"servers":[{"url":"https://api.coinmetrics.io/v4"},{"url":"wss://api.coinmetrics.io/v4"},{"url":"https://community-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},"MarketOrderBooksAndQuotesGranularity":{"description":"Downsampling granularity of market order books and quotes. Supported values are `raw`, `1m`, `1h`, and `1d`.","in":"query","name":"granularity","schema":{"default":"raw","type":"string","enum":["raw","1m","1h","1d"]}},"StartTime":{"description":"Start of the time interval.<br/> This field refers to the `time` field in the response.<br/> Multiple formats of ISO 8601 are supported: `2006-01-20T00:00:00Z`, `2006-01-20T00:00:00.000Z`, `2006-01-20T00:00:00.123456Z`, `2006-01-20T00:00:00.123456789Z`, `2006-01-20`, `20060120`.<br/> Inclusive by default.<br/> UTC timezone by default. `Z` suffix is optional and `timezone` parameter has a priority over it.<br/> If `start_time` is omitted, response will include time series from the **earliest** time available.","in":"query","name":"start_time","schema":{"type":"string"}},"EndTime":{"description":"End of the time interval.<br/> This field refers to the `time` field in the response.<br/> Multiple formats of ISO 8601 are supported: `2006-01-20T00:00:00Z`, `2006-01-20T00:00:00.000Z`, `2006-01-20T00:00:00.123456Z`, `2006-01-20T00:00:00.123456789Z`, `2006-01-20`, `20060120`.<br/> Inclusive by default.<br/> UTC timezone by default. `Z` suffix is optional and `timezone` parameter has a priority over it.<br/> If `end_time` is omitted, response will include time series up to the **latest** time available.","in":"query","name":"end_time","schema":{"type":"string"}},"StartInclusive":{"description":"Inclusive or exclusive corresponding `start_*` parameters.","in":"query","name":"start_inclusive","schema":{"default":true,"type":"boolean"}},"EndInclusive":{"description":"Inclusive or exclusive corresponding `end_*` parameters.","in":"query","name":"end_inclusive","schema":{"default":true,"type":"boolean"}},"Timezone":{"description":"Timezone name for `start_time` and `end_time` timestamps.<br/> This parameter does not modify the output times, which are always `UTC`.<br/> Format is defined by [TZ database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).","in":"query","name":"timezone","schema":{"default":"UTC","type":"string"}},"BookPageSize":{"description":"Number of items per single page of results. Maximum value for unlimited order books is 100.<br/> The value of this parameter is ignored if the endpoint supports the `format` parameter and its value is set to `json_stream`.","in":"query","name":"page_size","schema":{"default":100,"type":"integer","format":"int32","minimum":1,"maximum":10000}},"BookDepth":{"description":"Book depth limit. Supported values are between 1 and 30000, `10pct_mid_price` or `full_book`.","in":"query","name":"depth_limit","schema":{"default":100,"type":"string"}},"CatalogResponseFormat":{"description":"Format of the response. Supported values are `json`, `json_stream`.","in":"query","name":"format","schema":{"type":"string","default":"json"}},"PagingFrom":{"description":"Where does the first page start, at the start of the interval or at the end.<br/> The value of this parameter is ignored if the endpoint supports the `format` parameter and its value is set to `json_stream`.","in":"query","name":"paging_from","schema":{"default":"end","enum":["start","end"],"type":"string","format":"PagingFrom"}},"LimitPerMarket":{"description":"How many entries per market result should contain. It is useful when multiple markets are requested.","in":"query","name":"limit_per_market","schema":{"type":"integer","format":"int32"}},"Pretty":{"description":"Human-readable formatting of JSON responses.","in":"query","name":"pretty","schema":{"type":"boolean","default":false}},"NextPageToken":{"description":"Token for receiving the results from the next page of a query.<br/> Should not be used directly. To iterate through pages just use `next_page_url` response field.","in":"query","name":"next_page_token","schema":{"type":"string"}},"OrderBookDataset":{"description":"Logical order book dataset to return.<br/><br/> `snapshots` (default) returns snapshot rows only.<br/><br/> `updates` returns Book Streams snapshot/update rows for migrated exchanges.<br/><br/> Caveats:<br/> <ul>\n    <li>`dataset=updates` is currently supported for `full_book` and `30000` depths, `raw` granularity, `json_stream` format, `paging_from=start`, and migrated exchanges only.</li>\n    <li>When the `updates` dataset is requested, there are no guarantees on how snapshots are placed inside the data. Snapshots can appear at arbitrary timestamps and at irregular intervals.</li>\n    <li>Clients should reset their order book state on every snapshot row, not only on the first one. Snapshots may be emitted mid-stream, for example when the upstream feed is switched, and can carry book state that differs from prior updates. Treating every snapshot as a full state replacement is always safe while skipping snapshots is not.</li>\n    <li>When the `updates` dataset is requested, the response may contain redundant snapshots that do not change order book state and are there for state synchronization. Such redundant snapshots have the same timestamp and `coin_metrics_id` as the previous row. Clients may use this to detect redundant snapshots, but the safe default is still to reset state on every snapshot.</li>\n</ul>","in":"query","name":"dataset","schema":{"type":"string","enum":["snapshots","updates"],"default":"snapshots"}},"OrderBookStartWithSnapshot":{"description":"Applies only when `dataset=updates`.<br/><br/> When `false` (default), rows are returned from the exact readable range. This is useful when the order book state is already initialized so the timestamp of the last row received can be used to resume downloading order book data.<br/><br/> When `true`, the response starts with a snapshot row when one is available at or before the effective dataset start. This is useful for order book state initialization. The API may include a snapshot from before `start_time` so client state can be initialized before the first update row is applied.<br/><br/> This parameter is ignored when `dataset=snapshots`.","in":"query","name":"start_with_snapshot","schema":{"type":"boolean","default":false}}},"responses":{"MarketOrderBooks":{"description":"Time series of market order books.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MarketOrderbookResponse"}}}},"MarketNotFound":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"Market not found."},"Unauthorized":{"description":"Requested resource requires authorization.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"Forbidden":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"Requested resource is not available with supplied credentials."},"UriTooLong":{"description":"Provided URI is too long. It must not be greater than 10000 symbols."}},"schemas":{"MarketOrderbookResponse":{"properties":{"data":{"items":{"$ref":"#/components/schemas/MarketOrderBook"},"type":"array"},"next_page_token":{"$ref":"#/components/schemas/NextPageToken"},"next_page_url":{"$ref":"#/components/schemas/NextPageUrl"}},"required":["data"],"type":"object"},"MarketOrderBook":{"description":"Information about order book.","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"},"database_time":{"$ref":"#/components/schemas/DatabaseTime"},"collect_time":{"$ref":"#/components/schemas/OrderBookCollectTime"}},"type":"object","required":["market","time","coin_metrics_id","asks","bids","database_time"]},"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"},"DatabaseTime":{"description":"A time when we saved the data in the database. The time is in ISO 8601 date-time format. Always with nanoseconds precision.","type":"string","format":"date-time"},"OrderBookCollectTime":{"description":"Time of when the order book was received from the exchange.","type":"string","format":"date-time"},"NextPageToken":{"description":"Token of the next page results for a given request.","type":"string"},"NextPageUrl":{"description":"URL of the next page results for a given request.","type":"string"},"ErrorResponse":{"properties":{"error":{"$ref":"#/components/schemas/ErrorObject"}},"required":["error"],"type":"object"},"ErrorObject":{"properties":{"type":{"description":"Error type string. Can be used for error identification.","type":"string"},"message":{"description":"Human-friendly error description. Can be amended without prior notification. Do not use for error identification in your code.","type":"string"}},"required":["type","description"],"type":"object"}}},"paths":{"/timeseries/market-orderbooks":{"get":{"summary":"Market orderbooks","description":"Returns orderbooks for specified markets.<br/> Results are ordered by tuple `(market, time)`.<br/> To fetch the next page of results use `next_page_url` JSON response field.","operationId":"getTimeseriesMarketOrderbooks","tags":["Timeseries REST"],"parameters":[{"$ref":"#/components/parameters/MarketId"},{"$ref":"#/components/parameters/MarketOrderBooksAndQuotesGranularity"},{"$ref":"#/components/parameters/StartTime"},{"$ref":"#/components/parameters/EndTime"},{"$ref":"#/components/parameters/StartInclusive"},{"$ref":"#/components/parameters/EndInclusive"},{"$ref":"#/components/parameters/Timezone"},{"$ref":"#/components/parameters/BookPageSize"},{"$ref":"#/components/parameters/BookDepth"},{"$ref":"#/components/parameters/CatalogResponseFormat"},{"$ref":"#/components/parameters/PagingFrom"},{"$ref":"#/components/parameters/LimitPerMarket"},{"$ref":"#/components/parameters/Pretty"},{"$ref":"#/components/parameters/NextPageToken"},{"$ref":"#/components/parameters/OrderBookDataset"},{"$ref":"#/components/parameters/OrderBookStartWithSnapshot"}],"responses":{"200":{"$ref":"#/components/responses/MarketOrderBooks"},"400":{"$ref":"#/components/responses/MarketNotFound"},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"},"414":{"$ref":"#/components/responses/UriTooLong"}}}}}}
```


---

# 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-rest/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.
