# #2: Get Historical Data

{% hint style="info" %}
Our historical data are queried using and will be returned in UNIX timestamp format.

**Tips:** if you’re not familiar with UNIX timestamp, you may use tool like [epochconverter.com](https://www.epochconverter.com/) to convert between UNIX timestamp and human readable date&#x20;
{% endhint %}

**There are 3 different endpoints to get historical data of a coin:**

<table><thead><tr><th width="297">Endpoint</th><th>Description</th></tr></thead><tbody><tr><td>/coins/{id}/history</td><td>To get the price &#x26; market data of a coin on a specific day in the past (00:00 UTC)</td></tr><tr><td>/coins/{id}/market_chart</td><td>To get list of historical price &#x26; market data of a coin for <em>X</em> days before today.</td></tr><tr><td>/coins/{id}/market_chart/range</td><td>To get list of historical price &#x26; market data of a coin for a date range, between 'from' and 'to'.</td></tr></tbody></table>

{% hint style="info" %}
The data granularity (<mark style="color:green;">interval</mark>) for **market\_chart** and **market\_chart/range** endpoints is automatic and based on the <mark style="color:yellow;">date range</mark>:

* <mark style="color:yellow;">**1 day**</mark> from current time = <mark style="color:green;">**5-minutely**</mark> data
* <mark style="color:yellow;">**1 day**</mark> from anytime (except from current time) = <mark style="color:green;">**hourly**</mark> data
* <mark style="color:yellow;">**2-90 days**</mark> from current time or anytime = <mark style="color:green;">**hourly**</mark> data
* <mark style="color:yellow;">**above 90 days**</mark> from current time or anytime = <mark style="color:green;">**daily**</mark> data (00:00 UTC)&#x20;
  {% endhint %}

Let’s try them out on <https://www.coingecko.com/en/api/documentation>

And yes, you may do so with contract address too:

* /coins/{id}/contract/{contract\_address}/market\_chart/
* /coins/{id}/contract/{contract\_address}/market\_chart/range


---

# 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://coingecko-api.gitbook.io/coingecko-api-guide/getting-started/10-min-tutorial-guide/2-get-historical-data.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.
