# DataCollection

```python
class coinmetrics._data_collection.DataCollection(
    data_retrieval_function,
    endpoint,
    url_params,
    csv_export_supported=True,
    client=None,
    paginated=True,
    **kwargs,
)
```

Bases: [`object`](https://docs.python.org/3/library/functions.html#object)

Lazy wrapper around a Coin Metrics REST endpoint response.

Every REST method on [`CoinMetricsClient`](https://gitbook-docs.coinmetrics.io/python-api-client/reference/pages/1MQgB4ZdN4XhwS0frkJK#coinmetrics.api_client.CoinMetricsClient) returns a `DataCollection`. It iterates over rows on demand (with transparent paging) and exposes helpers for converting the response into common Python data structures:

* [`to_dataframe()`](https://gitbook-docs.coinmetrics.io/python-api-client/reference/pages/jGrDH5JaWpvotMblCMHs#coinmetrics._data_collection.DataCollection.to_dataframe) -- materialize into a pandas or polars dataframe.
* [`to_list()`](https://gitbook-docs.coinmetrics.io/python-api-client/reference/pages/E36GlrFGzDQIWVNyjSde#coinmetrics._data_collection.DataCollection.to_list) -- materialize into `List[Dict[str, Any]]`.
* [`export_to_csv()`](https://gitbook-docs.coinmetrics.io/python-api-client/reference/pages/dblxEhbbZEYyuQ4ISwTy#coinmetrics._data_collection.DataCollection.export_to_csv) -- stream the response into a CSV file or buffer.
* [`export_to_json()`](https://gitbook-docs.coinmetrics.io/python-api-client/reference/pages/qzwE7iheljADRY7bRvns#coinmetrics._data_collection.DataCollection.export_to_json) -- stream the response into a JSON file or buffer.
* [`export_to_parquet()`](https://gitbook-docs.coinmetrics.io/python-api-client/reference/pages/bBcnm9NWRw5g0vhPne7u#coinmetrics._data_collection.DataCollection.export_to_parquet) -- stream the response into a Parquet file.
* [`parallel()`](https://gitbook-docs.coinmetrics.io/python-api-client/reference/pages/hviDNipdzNiWKvqvZTO3#coinmetrics._data_collection.DataCollection.parallel) -- return a [`ParallelDataCollection`](https://gitbook-docs.coinmetrics.io/python-api-client/reference/pages/eQIronmREyzwFm5VAeq6#coinmetrics._data_collection.ParallelDataCollection) that splits the request across worker threads. The result can be chained with [`to_dataframe()`](https://gitbook-docs.coinmetrics.io/python-api-client/reference/pages/jGrDH5JaWpvotMblCMHs#coinmetrics._data_collection.DataCollection.to_dataframe), [`to_list()`](https://gitbook-docs.coinmetrics.io/python-api-client/reference/pages/E36GlrFGzDQIWVNyjSde#coinmetrics._data_collection.DataCollection.to_list), [`export_to_csv_files()`](https://gitbook-docs.coinmetrics.io/python-api-client/reference/pages/mpWKMwBhI1J9LP92Dibv#coinmetrics._data_collection.ParallelDataCollection.export_to_csv_files), [`export_to_json_files()`](https://gitbook-docs.coinmetrics.io/python-api-client/reference/pages/YVD4T1nPHg9pO8VK9Hc8#coinmetrics._data_collection.ParallelDataCollection.export_to_json_files), and so on.
* **Parameters:**
  * **data\_retrieval\_function** (*DataRetrievalFuncType*)
  * **endpoint** ([*str*](https://docs.python.org/3/library/stdtypes.html#str))
  * **url\_params** (*Dict* *\[*[*str*](https://docs.python.org/3/library/stdtypes.html#str) *,* *UrlParamTypes* *]*)
  * **csv\_export\_supported** ([*bool*](https://docs.python.org/3/library/functions.html#bool))
  * **client** (*Optional* *\[*[*CoinMetricsClient*](https://gitbook-docs.coinmetrics.io/python-api-client/reference/pages/1MQgB4ZdN4XhwS0frkJK#coinmetrics.api_client.CoinMetricsClient) *]*)
  * **paginated** ([*bool*](https://docs.python.org/3/library/functions.html#bool))
  * **kwargs** (*Any*)

### Methods

* [`DataCollection.get_schema_field_names`](/python-api-client/reference/data-collection/get_schema_field_names.md)
* [`DataCollection.first_page`](/python-api-client/reference/data-collection/first_page.md)
* [`DataCollection.to_list`](/python-api-client/reference/data-collection/to_list.md)
* [`DataCollection.export_to_csv`](/python-api-client/reference/data-collection/export_to_csv.md)
* [`DataCollection.export_to_json`](/python-api-client/reference/data-collection/export_to_json.md)
* [`DataCollection.export_to_parquet`](/python-api-client/reference/data-collection/export_to_parquet.md)
* [`DataCollection.to_dataframe`](/python-api-client/reference/data-collection/to_dataframe.md)
* [`DataCollection.to_lazyframe`](/python-api-client/reference/data-collection/to_lazyframe.md)
* [`DataCollection.parallel`](/python-api-client/reference/data-collection/parallel.md)


---

# Agent Instructions: 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:

```
GET https://gitbook-docs.coinmetrics.io/python-api-client/reference/data-collection.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
