> For the complete documentation index, see [llms.txt](https://coingecko-api.gitbook.io/coingecko-api-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://coingecko-api.gitbook.io/coingecko-api-guide/getting-started/10-min-tutorial-guide/2-get-historical-data.md).

# #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
