> 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/1-get-data-by-id-or-address.md).

# #1: Get Data by ID or Address

> Do you know that by knowing how to use ‘id’ and ‘contract address’, you’re already able to use about half of the 30+ endpoints offered by CoinGecko API?

## 1. **There are 2 main ways to query price & market data of specific Coins:**

### **a) Coin ID**

This is one of the most widely used endpoint to get the latest price of Bitcoin:

e.g. try to click on this link below:

```
https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd
```

You will see **ids=bitcoin** and **vs\_currencies=usd** on the link above, it means we’re trying to get the price of bitcoin in USD.

**How do we get the ids of specific coins? There are 3 options:**

1. Use [/coins/list](https://api.coingecko.com/api/v3/coins/list) API endpoint, it will return the full list of Coins available on CoinGecko. You may then search for coin in the list using “name” and “symbol”, then obtain the “id” of specific coins.
   1. Reminder: “name” and “symbol” might change in the future, they are not unique. ”id” is the main unique identifier for different coins for you to use with CoinGecko API.
2. You may also view the full list using this [Google Sheet](https://docs.google.com/spreadsheets/d/1wTTuxXt8n9q7C4NDXqQpI3wpKu1_5bGVmP9Xz0XGSyU/edit?usp=sharing).
3. You can also look for the **“id”** by visiting the info section of [a Coin page](https://www.coingecko.com/en/coins/bitcoin) on CoinGecko. (look for ‘API id’)

<figure><img src="/files/RFXISwWv1joz2SFmJaF7" alt=""><figcaption></figcaption></figure>

### **b) Coin Contract Address**

Other than using Coin ID, you may also query price & market data of a coin using contract address:

e.g.

{% code overflow="wrap" %}

```
https://api.coingecko.com/api/v3/simple/token_price/ethereum?contract_addresses=0x1f9840a85d5af5bf1d1762f925bdaddc4201f984&vs_currencies=usd
```

{% endcode %}

In the query above, there are 3 values that we need to input:

* <mark style="color:yellow;">`ethereum`</mark> ← asset\_platform\_id
* <mark style="color:yellow;">`0x1f9840a85d5af5bf1d1762f925bdaddc4201f984`</mark> ← contract\_address
* <mark style="color:yellow;">`usd`</mark> ← vs\_currencies (more on this in the next section)

While trying to query an endpoint using contract address, you must also specify the asset platform, which is equivalent to ‘blockchain network’. You may use the following endpoint to find the ids of all asset platforms supported by CoinGecko:

```
https://api.coingecko.com/api/v3/asset_platforms
```

**How do we get the contract address of specific coins? There are 2 options:**

1. You may visit the info section of a [Coin page](https://www.coingecko.com/en/coins/uniswap), and look for ‘Contract’

{% hint style="info" %}
Not all coins will have contract address on CoinGecko site.

If an address is not shown on CoinGecko page, you will not be able to query the coin by contract address via API
{% endhint %}

<figure><img src="/files/dBkJ4WgQxkDGCjowIXZQ" alt=""><figcaption><p>If a address is not shown on CoinGecko page, you will not be able to query the coin by contract address via API</p></figcaption></figure>

1. You might get it from project wesbsite, whitepaper, documentation, or block explorer site like [Etherscan](https://etherscan.io/token/0x1f9840a85d5af5bf1d1762f925bdaddc4201f984). e.g. for Uniswap:
   * <https://docs.uniswap.org/protocol/concepts/governance/overview#uni-address>
   * <https://etherscan.io/token/0x1f9840a85d5af5bf1d1762f925bdaddc4201f984>

## 2. In most cases, you will have to specify in which currency that you want the API data return.

In the 2 examples above, both queries for Coin ID and Contract Address contain `vs_currencies=usd` . Most CoinGecko API endpoints require you to specify the currency.

CoinGecko API data supports all major fiat currencies and some famous crypto currencies like the following:

| Type           | Currency     | vs\_currencies (API value) |
| -------------- | ------------ | -------------------------- |
| Fiat           | US Dollar    | usd                        |
| Fiat           | Japanese Yen | jpy                        |
| Fiat           | Euro         | eur                        |
| Cryptocurrency | Bitcoin      | btc                        |
| Cryptocurrency | Ether        | eth                        |
| Cryptocurrency | Binance Coin | bnb                        |

You can view the full list of supported currencies here:

```
https://api.coingecko.com/api/v3/simple/supported_vs_currencies
```

##

## 3. Here’s another way to obtain coin prices & market data in bulk, by using ‘per\_page’

The /coins/market endpoint will allow you to query Coins data in bulk. e.g.

```
https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=100&page=1
```

The query above will return the top 100 Coins on CoinGecko, ranked by Market Cap, which is similar to what you see at the homepage of CoinGecko: <https://www.coingecko.com/?page=1>

Let’s deep dive a little bit on the parameters included above:

* **vs\_currency: usd**
* **order: market\_cap\_desc** ← the data will be ranked from the largest to smallest Market Cap.
* **per\_page: 100** ← here it specifies that the page should contain 100 coins (max is 250 coins per page)
* **page: 1** ←here it specifies the page number. if you input ‘2’ here and per\_page=100 , then you will get the 101st-200th coin on CoinGecko, ranked by Market Cap, which is similar as the result of <https://www.coingecko.com/?page=2>


---

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

```
GET https://coingecko-api.gitbook.io/coingecko-api-guide/getting-started/10-min-tutorial-guide/1-get-data-by-id-or-address.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.
