> 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/python-api-client/reference/coinmetricsclient/timeseries/get_market_orderbooks.md).

# CoinMetricsClient.get\_market\_orderbooks

```python
coinmetrics.api_client.CoinMetricsClient.get_market_orderbooks(
    markets,
    granularity=None,
    page_size=None,
    paging_from='start',
    start_time=None,
    end_time=None,
    start_inclusive=None,
    end_inclusive=None,
    depth_limit='100',
    timezone=None,
    limit_per_market=None,
    format='json_stream',
    dataset=None,
    start_with_snapshot=None,
)
```

Returns market order books for specified markets and date range. For more information on order books, see: <https://docs.coinmetrics.io/info/markets/orderbook>

* **Parameters:**
  * **markets** ([*list*](https://docs.python.org/3/library/stdtypes.html#list) *(*[*str*](https://docs.python.org/3/library/stdtypes.html#str) *)* *,* [*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- list of market ids. Market ids use the following naming convention: exchangeName-baseAsset-quoteAsset-spot for spot markets, exchangeName-futuresSymbol-future for futures markets, and exchangeName-optionsSymbol-option for options markets. e.g., 'coinbase-btc-usd-spot', 'bitmex-XBTUSD-future'
  * **granularity** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- Downsampling granularity of market order books and quotes. Supported values are raw, 1m, 1h, and 1d.
  * **page\_size** ([*int*](https://docs.python.org/3/library/functions.html#int)) -- number of items returned per page when calling the API. If the request times out, try using a smaller number.
  * **paging\_from** (*PagingFrom* *,* [*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- Defines where you want to start receiving items from, 'start' or 'end' of the timeseries.
  * **start\_time** (*datetime* *,* *date* *,* [*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- Start time of the timeseries (string or datetime). Datetime object may be timezone naive or aware. 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.123456789, 2006-01-20, 20060120
  * **end\_time** (*datetime* *,* *date* *,* [*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- End time of the timeseries (string or datetime). Datetime object may be timezone naive or aware. 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.123456789, 2006-01-20, 20060120
  * **start\_inclusive** ([*bool*](https://docs.python.org/3/library/functions.html#bool)) -- Flag to define if start timestamp must be included in the timeseries if present. True by default.
  * **end\_inclusive** ([*bool*](https://docs.python.org/3/library/functions.html#bool)) -- Flag to define if end timestamp must be included in the timeseries if present. True by default.
  * **depth\_limit** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- book depth limit, 100 levels max or full book that is not limited and provided as is from the exchange. Full book snapshots are collected once per hour
  * **timezone** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- timezone of the start/end times in db format for example: "America/Chicago". Default value is "UTC". For more details check out API documentation page.
  * **limit\_per\_market** ([*int*](https://docs.python.org/3/library/functions.html#int)) -- How many entries *per market* the result should contain.
  * **format** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- Format of the response. Supported values are json, json\_stream, csv. Default is json\_stream. Setting format='json\_stream' is generally more performant. page\_size and paging\_from is ignored when format='json\_stream'.
  * **dataset** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- Logical order book dataset to return. `snapshots` (default) returns snapshot rows only. `updates` returns snapshot and incremental update rows for migrated exchanges.
  * **start\_with\_snapshot** ([*bool*](https://docs.python.org/3/library/functions.html#bool)) -- Applies only when `dataset=updates`. When `true`, the response may include a snapshot from before `start_time` for order book state initialization. Ignored when `dataset=snapshots`.

**Returns:**

* [DataCollection](https://gitbook-docs.coinmetrics.io/python-api-client/reference/coinmetricsclient/timeseries/pages/4SxAThvJEKszVwNAKU88#coinmetrics._data_collection.DataCollection)
  * Market Order Books timeseries.


---

# 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/python-api-client/reference/coinmetricsclient/timeseries/get_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.
