Instruction:
  This is the coingecko MCP server.

  Available tools:
  - search_docs: Search SDK documentation to find the right methods and parameters.
  - execute: Run TypeScript code against a pre-authenticated SDK client. Define an async run(client) function.

  Workflow:
  - If unsure about the API, call search_docs first.
  - Write complete solutions in a single execute call when possible. For large datasets, use API filters to narrow results or paginate within a single execute block.
  - If execute returns an error, read the error and fix your code rather than retrying the same approach.
  - Variables do not persist between execute calls. Return or log all data you need.
  - Individual HTTP requests to the API have a 30-second timeout. If a request times out, try a smaller query or add filters.
  - Code execution has a total timeout of approximately 5 minutes. If your code times out, simplify it or break it into smaller steps.


Instruction:
  This is the coingecko MCP server.

  Available tools:
  - search_docs: Search SDK documentation to find the right methods and parameters.
  - execute: Run TypeScript code against a pre-authenticated SDK client. Define an async run(client) function.

  Workflow:
  - If unsure about the API, call search_docs first.
  - Write complete solutions in a single execute call when possible. For large datasets, use API filters to narrow results or paginate within a single execute block.
  - If execute returns an error, read the error and fix your code rather than retrying the same approach.
  - Variables do not persist between execute calls. Return or log all data you need.
  - Individual HTTP requests to the API have a 30-second timeout. If a request times out, try a smaller query or add filters.
  - Code execution has a total timeout of approximately 5 minutes. If your code times out, simplify it or break it into smaller steps.


execute

Runs JavaScript code to interact with the Coingecko API.

You are a skilled TypeScript programmer writing code to interface with the service.
Define an async function named "run" that takes a single parameter of an initialized SDK client and it will be run.
For example:

```
async function run(client) {
  const price = await client.simple.price.get({ vs_currencies: 'usd', ids: 'bitcoin' });
}
```

You will be returned anything that your function returns, plus the results of any console.log statements.
Do not add try-catch blocks for single API calls. The tool will handle errors for you.
Do not add comments unless necessary for generating better code.
Code will run in a container, and cannot interact with the network outside of the given SDK client.
Variables will not persist between calls, so make sure to return or log any data you might need later.
Remember that you are writing TypeScript code, so you need to be careful with your types.
Always type dynamic key-value stores explicitly as Record<string, YourValueType> instead of {}.

Code to execute.

Task you are trying to perform. Used for improving the service.

Search SDK documentation to find methods, parameters, and usage examples for interacting with the API. Use this before writing code when you need to discover the right approach.

The query to search for.

The language for the SDK to search for.

http python go typescript javascript terraform ruby java kotlin

The amount of detail to return.


Code to execute.

The query to search for.

The language for the SDK to search for.

The amount of detail to return.


The code is missing a top-level `run` function. Write code within this template:

```
async function run(client) {
  // Fill this out
}
```


async function run(client) {
  const res = await client.simple.price.get({
    ids: 'kaspa,monero',
    vs_currencies: 'sats,eth',
    include_24hr_change: true
  });
  return res;
}

Fetch current price of kaspa and monero in sats and eth with 24h change


async function run(client) {
  const page1 = await client.coins.markets.get({
    vs_currency: 'usd',
    order: 'market_cap_desc',
    per_page: 250,
    page: 1,
  });
  const coin = page1.find(c => c.market_cap_rank === 137);
  return coin;
}

Find the coin with market_cap_rank 137 in USD markets data


async function run(client) {
  const data = await client.coins.markets.get({
    vs_currency: 'usd',
    per_page: 250,
    page: 2,
    order: 'market_cap_desc'
  });
  const coin = data.find(c => c.market_cap_rank === 500);
  return coin ? { id: coin.id, total_volume: coin.total_volume, rank: coin.market_cap_rank } : data[data.length-1];
}


async function run(client) {
  const data = await client.coins.markets.get({
    vs_currency: 'usd',
    per_page: 250,
    page: 2,
    order: 'market_cap_desc'
  });
  const last = data[data.length - 1];
  return { length: data.length, last_id: last.id, last_rank: last.market_cap_rank, last_volume: last.total_volume };
}


Question: exchanges list trust_score_rank


Summary: Exchanges List

To query all the supported exchanges with ID and name

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const response = await client.exchanges.getList();

console.log(response);

Response: { id: string; name: string; }[]

Summary: Derivatives Exchanges List

To query all the supported derivatives exchanges with ID and name on CoinGecko

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const response = await client.derivatives.exchanges.getList();

console.log(response);

Response: { id: string; name: string; }[]

Summary: Exchanges List with Data

To query all the supported exchanges with exchanges' data (ID, name, country, etc.) that have active trading volumes on CoinGecko

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const exchanges = await client.exchanges.get();

console.log(exchanges);

Response: { id: string; country: string; description: string; has_trading_incentive: boolean; image: string; name: string; trade_volume_24h_btc: number; trust_score: number; trust_score_rank: number; url: string; year_established: number; }[]

Summary: Derivatives Exchanges List with Data

To query all the derivatives exchanges with related data (ID, name, open interest, ...) on CoinGecko

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const exchanges = await client.derivatives.exchanges.get();

console.log(exchanges);

order?: string;
page?: number;
per_page?: number;

Response: { id: string; country: string; description: string; image: string; name: string; number_of_futures_pairs: number; number_of_perpetual_pairs: number; open_interest_btc: number; trade_volume_24h_btc: string; url: string; year_established: number; }[]

Summary: Entities List

To query all the supported entities on CoinGecko with entity ID, name, symbol, and country

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const response = await client.entities.getList();

console.log(response);

entity_type?: 'company' | 'government';
page?: number;
per_page?: number;

Response: { id: string; country: string; name: string; symbol: string; }[]

Summary: NFTs List

To query all supported NFTs with ID, contract address, name, asset platform ID and symbol on CoinGecko

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const response = await client.nfts.getList();

console.log(response);

Response: { id: string; asset_platform_id: string; contract_address: string; name: string; symbol: string; }[]

Summary: Coins Categories List

To query all the supported coins categories on CoinGecko

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const response = await client.coins.categories.getList();

console.log(response);

Response: { category_id: string; name: string; }[]

Summary: Coins List

To query all the supported coins on CoinGecko with coin ID, name and symbol

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const lists = await client.coins.list.get();

console.log(lists);

include_platform?: boolean;
status?: 'active' | 'inactive';

Response: { id: string; name: string; symbol: string; platforms?: object; }[]

Summary: Recently Added Coins

To query the latest 200 coins that recently listed on CoinGecko

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const response = await client.coins.list.getNew();

console.log(response);

Response: { id: string; activated_at: number; name: string; symbol: string; }[]

Summary: Exchange Data by ID

To query exchange's data (name, year established, country, etc.), exchange volume in BTC and top 100 tickers based on exchange's ID

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const response = await client.exchanges.getID('id');

console.log(response.alert_notice);

dex_pair_format?: 'contract_address' | 'symbol';

Response: { alert_notice: string; centralized: boolean; coins: number; country: string; description: string; facebook_url: string; has_trading_incentive: boolean; image: string; name: string; other_url_1: string; other_url_2: string; pairs: number; public_notice: string; reddit_url: string; slack_url: string; status_updates: { category?: string; created_at?: string; description?: string; pin?: boolean; project?: object; user?: string; user_title?: string; }[]; telegram_url: string; tickers: { base?: string; bid_ask_spread_percentage?: number; coin_id?: string; coin_mcap_usd?: number; converted_last?: object; converted_volume?: object; is_anomaly?: boolean; is_stale?: boolean; last?: number; last_fetch_at?: string; last_traded_at?: string; market?: object; target?: string; target_coin_id?: string; timestamp?: string; token_info_url?: string; trade_url?: string; trust_score?: string; volume?: number; }[]; trade_volume_24h_btc: number; trust_score: number; trust_score_rank: number; twitter_handle: string; url: string; year_established: number; }


async function run(client) {
  const exchanges = await client.exchanges.get({ page: 1, per_page: 100 });
  const target = exchanges.find(e => e.trust_score_rank === 87);
  return target;
}


async function run(client) {
  const data = await client.coins.getId({
    id: 'vertcoin',
    tickers: false,
    market_data: false,
    community_data: false,
    developer_data: false,
    localization: false,
    sparkline: false
  });
  return {
    sentiment_votes_up_percentage: data.sentiment_votes_up_percentage,
    watchlist_portfolio_users: data.watchlist_portfolio_users
  };
}

Fetch vertcoin coin data and get sentiment and watchlist stats


The code contains TypeScript diagnostics:
- Property 'getId' does not exist on type 'Coins'. Did you mean 'getID'?
    const data = await client.coins.getId({


async function run(client) {
  const data = await client.coins.getID({
    id: 'vertcoin',
    tickers: false,
    market_data: false,
    community_data: false,
    developer_data: false,
    localization: false,
    sparkline: false
  });
  return {
    sentiment_votes_up_percentage: data.sentiment_votes_up_percentage,
    watchlist_portfolio_users: data.watchlist_portfolio_users
  };
}


The code contains TypeScript diagnostics:
- Argument of type '{ id: string; tickers: boolean; market_data: boolean; community_data: boolean; developer_data: boolean; localization: boolean; sparkline: boolean; }' is not assignable to parameter of type 'string'.
    const data = await client.coins.getID({


async function run(client) {
  const data = await client.coins.getID('vertcoin', {
    tickers: false,
    market_data: false,
    community_data: false,
    developer_data: false,
    localization: false,
    sparkline: false
  });
  return {
    sentiment_votes_up_percentage: data.sentiment_votes_up_percentage,
    watchlist_portfolio_users: data.watchlist_portfolio_users
  };
}


async function run(client) {
  const hist = await client.coins.history.get('peercoin', { date: '30-12-2023' });
  return {
    name: hist.name,
    symbol: hist.symbol,
    market_data: hist.market_data ? {
      market_cap: hist.market_data.market_cap?.usd,
      total_volume: hist.market_data.total_volume?.usd
    } : null
  };
}

Get Peercoin historical market cap and volume for 30-12-2023


Question: public companies treasury ethereum


Summary: Crypto Treasury Holdings by Entity ID

To query public companies' and governments' cryptocurrency holdings by entity ID

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const response = await client.publicTreasury.getEntityID('entity_id');

console.log(response.id);

entity_id: string;
holding_amount_change?: string;
holding_change_percentage?: string;

Response: { id: string; country: string; holdings: { amount: number; amount_per_share: number; average_entry_value_usd: number; coin_id: string; current_value_usd: number; entity_value_usd_percentage: number; percentage_of_total_supply: number; total_entry_value_usd: number; unrealized_pnl: number; holding_amount_change?: { 14d?: number; 1y?: number; 30d?: number; 7d?: number; 90d?: number; ytd?: number; }; holding_change_percentage?: { 14d?: number; 1y?: number; 30d?: number; 7d?: number; 90d?: number; ytd?: number; }; }[]; m_nav: number; name: string; symbol: string; total_asset_value_per_share_usd: number; total_treasury_value_usd: number; twitter_screen_name: string; type: string; unrealized_pnl: number; website_url: string; }

Summary: Crypto Treasury Holdings by Coin ID

To query public companies' and governments' cryptocurrency holdings by coin ID

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const response = await client.publicTreasury.getCoinID('coin_id', { entity: 'companies' });

console.log(response);

order?: 'total_holdings_usd_desc' | 'total_holdings_usd_asc';

Response: { companies: { country: string; name: string; percentage_of_total_supply: number; symbol: string; total_current_value_usd: number; total_entry_value_usd: number; total_holdings: number; }[]; market_cap_dominance: number; total_holdings: number; total_value_usd: number; } | { governments: { country: string; name: string; percentage_of_total_supply: number; symbol: string; total_current_value_usd: number; total_entry_value_usd: number; total_holdings: number; }[]; market_cap_dominance: number; total_holdings: number; total_value_usd: number; }

Summary: Crypto Treasury Transaction History by Entity ID

To query public companies' and governments' cryptocurrency transaction history by entity ID

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const response = await client.publicTreasury.getTransactionHistory('entity_id');

console.log(response.transactions);

entity_id: string;
coin_ids?: string;
order?: string;
page?: number;
per_page?: number;

Response: { transactions: { average_entry_value_usd: number; coin_id: string; date: number; holding_balance: number; holding_net_change: number; source_url: string; transaction_value_usd: number; type: 'buy' | 'sell'; }[]; }

Summary: Crypto Treasury Holdings Historical Chart Data by ID

To query historical cryptocurrency holdings chart of public companies and governments by entity ID and coin ID

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const response = await client.publicTreasury.getHoldingChart('coin_id', {
  entity_id: 'entity_id',
  days: 'days',
});

console.log(response.holding_value_in_usd);

entity_id: string;
coin_id: string;
days: string;
include_empty_intervals?: boolean;

Response: { holding_value_in_usd: number[][]; holdings: number[][]; }

Summary: Token Lists by Asset Platform ID

To get full list of tokens of a blockchain network (asset platform) that is supported by [Ethereum token list standard](https://tokenlists.org/)

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const response = await client.tokenLists.getAllJson('asset_platform_id');

console.log(response.keywords);

Response: { keywords: string[]; logoURI: string; name: string; timestamp: string; tokens: { address: string; chainId: number; decimals: number; logoURI: string; name: string; symbol: string; }[]; version: { major?: number; minor?: number; patch?: number; }; }

To make requests using undocumented parameters, you may use `// @ts-expect-error` on the undocumented parameter. This library doesn't validate at runtime that the request matches the type, so any extra values you send will be sent as-is. ```ts client.simple.price.get({ // ... // @ts-expect-error baz is not yet public baz: 'undocumented option', }); ``` For requests with the `GET` verb, any extra params will be in the query, all other requests will send the extra param in the body. If you want to explicitly send an extra argument, you can do so with the `query`, `body`, and `headers` request options.

This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions: 1. Changes that only affect static types, without breaking runtime behavior. 2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_ 3. Changes that we do not expect to impact the vast majority of users in practice. We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience. We are keen for your feedback; please open an [issue](https://www.github.com/coingecko/coingecko-typescript/issues) with questions, bugs, or suggestions.


async function run(client) {
  const response = await client.publicTreasury.getCoinID('ethereum', { entity: 'companies', order: 'total_holdings_usd_desc' });
  const top3 = response.companies.slice(0,3).map(c => c.name + ': ' + c.total_holdings);
  return {
    total_holdings: response.total_holdings,
    total_value_usd: response.total_value_usd,
    third: response.companies[2],
    top3
  };
}

Get ethereum public companies treasury holdings totals and third-largest holder


The code contains TypeScript diagnostics:
- Property 'companies' does not exist on type 'PublicTreasuryGetCoinIDResponse'.
  Property 'companies' does not exist on type 'GovernmentTreasury'.
    const top3 = response.companies.slice(0, 3).map(c => c.name + ': ' + c.total_holdings);
- Property 'companies' does not exist on type 'PublicTreasuryGetCoinIDResponse'.
  Property 'companies' does not exist on type 'GovernmentTreasury'.
    third: response.companies[2],


async function run(client) {
  const response: any = await client.publicTreasury.getCoinID('ethereum', { entity: 'companies', order: 'total_holdings_usd_desc' });
  const companies = response.companies;
  const top3 = companies.slice(0,3).map((c: any) => c.name + ': ' + c.total_holdings);
  return {
    total_holdings: response.total_holdings,
    total_value_usd: response.total_value_usd,
    third: companies[2],
    top3
  };
}


BitMine Immersion: 5815164
SharpLink: 868699
The Ether Machine: 496712


async function run(client) {
  const res = await client.global.defi.get();
  return res;
}


The code contains TypeScript diagnostics:
- Property 'defi' does not exist on type 'Global'.
    const res = await client.global.defi.get();


Question: global decentralized finance defi market cap


Summary: Global DeFi Market Data

To query top 100 cryptocurrency global decentralized finance (DeFi) data including DeFi market cap, trading volume

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const decentralizedFinanceDefi = await client.global.decentralizedFinanceDefi.get();

console.log(decentralizedFinanceDefi.data);

Response: { data: { defi_dominance: string; defi_market_cap: string; defi_to_eth_ratio: string; eth_market_cap: string; top_coin_defi_dominance: number; top_coin_name: string; trading_volume_24h: string; }; }

Summary: Global Market Cap Chart Data

To query historical global market cap and volume data by number of days away from now

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const marketCapChart = await client.global.marketCapChart.get({ days: '1' });

console.log(marketCapChart.market_cap_chart);

Response: { market_cap_chart: { market_cap: number[][]; volume: number[][]; }; }

Summary: Crypto Global Market Data

To query cryptocurrency global data including active cryptocurrencies, markets, total crypto market cap and etc

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const global = await client.global.get();

console.log(global.data);

Response: { data: { active_cryptocurrencies: number; ended_icos: number; market_cap_change_percentage_24h_usd: number; market_cap_percentage: object; markets: number; ongoing_icos: number; total_market_cap: object; total_volume: object; upcoming_icos: number; updated_at: number; volume_change_percentage_24h_usd: number; }; }

Summary: NFTs List with Market Data

To query all the supported NFT collections with floor price, market cap, volume and market related data on CoinGecko

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const response = await client.nfts.getMarkets();

console.log(response);

asset_platform_id?: string;
order?: string;
page?: number;
per_page?: number;

Response: { id: string; asset_platform_id: string; contract_address: string; description: string; floor_price: { native_currency?: number; usd?: number; }; floor_price_24h_percentage_change: { native_currency?: number; usd?: number; }; floor_price_in_usd_24h_percentage_change: number; image: { small?: string; small_2x?: string; }; market_cap: { native_currency?: number; usd?: number; }; market_cap_24h_percentage_change: { native_currency?: number; usd?: number; }; name: string; native_currency: string; native_currency_symbol: string; number_of_unique_addresses: number; number_of_unique_addresses_24h_percentage_change: number; one_day_average_sale_price: number; one_day_average_sale_price_24h_percentage_change: number; one_day_sales: number; one_day_sales_24h_percentage_change: number; symbol: string; total_supply: number; volume_24h: { native_currency?: number; usd?: number; }; volume_24h_percentage_change: { native_currency?: number; usd?: number; }; volume_in_usd_24h_percentage_change: number; }[]

Summary: Coins List with Market Data

To query all the supported coins with price, market cap, volume and market related data

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const markets = await client.coins.markets.get({ vs_currency: 'vs_currency' });

console.log(markets);

order?: 'market_cap_asc' | 'market_cap_desc' | 'volume_asc' | 'volume_desc' | 'id_asc' | 'id_desc';

Response: { id: string; ath: number; ath_change_percentage: number; ath_date: string; atl: number; atl_change_percentage: number; atl_date: string; circulating_supply: number; current_price: number; fully_diluted_valuation: number; high_24h: number; image: string; last_updated: string; low_24h: number; market_cap: number; market_cap_change_24h: number; market_cap_change_percentage_24h: number; market_cap_rank: number; max_supply: number; name: string; price_change_24h: number; price_change_percentage_24h: number; roi: { currency?: string; percentage?: number; times?: number; }; symbol: string; total_supply: number; total_volume: number; market_cap_rank_with_rehypothecated?: number; price_change_percentage_14d_in_currency?: number; price_change_percentage_1h_in_currency?: number; price_change_percentage_1y_in_currency?: number; price_change_percentage_200d_in_currency?: number; price_change_percentage_24h_in_currency?: number; price_change_percentage_30d_in_currency?: number; price_change_percentage_7d_in_currency?: number; sparkline_in_7d?: { price?: number[]; }; }[]

Summary: NFTs Collection Historical Chart Data by ID

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const marketChart = await client.nfts.marketChart.get('id', { days: 'days' });

console.log(marketChart.floor_price_native);

Response: { floor_price_native: number[][]; floor_price_usd: number[][]; h24_volume_native: number[][]; h24_volume_usd: number[][]; market_cap_native: number[][]; market_cap_usd: number[][]; }

Summary: Coin Historical Chart Data by ID

To get the historical chart data of a coin including time in UNIX, price, market cap and 24hrs volume based on particular coin ID

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const marketChart = await client.coins.marketChart.get('id', {
  days: 'days',
  vs_currency: 'vs_currency',
});

console.log(marketChart.market_caps);

id: string;
days: string;
vs_currency: string;
interval?: '5m' | 'hourly' | 'daily';
precision?: string;

Response: { market_caps: number[][]; prices: number[][]; total_volumes: number[][]; }

Summary: Coin Historical Chart Data within Time Range by ID

To get the historical chart data of a coin within certain time range in UNIX along with price, market cap and 24hrs volume based on particular coin ID

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const response = await client.coins.marketChart.getRange('id', {
  from: 'from',
  to: 'to',
  vs_currency: 'vs_currency',
});

console.log(response.market_caps);

id: string;
from: string;
to: string;
vs_currency: string;
interval?: '5m' | 'hourly' | 'daily';
precision?: string;

Response: { market_caps: number[][]; prices: number[][]; total_volumes: number[][]; }

Summary: Coin Historical Chart Data by Token Address

To get the historical chart data including time in UNIX, price, market cap and 24hrs volume based on asset platform and particular token contract address

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const marketChart = await client.coins.contract.marketChart.get('contract_address', {
  id: 'id',
  days: 'days',
  vs_currency: 'vs_currency',
});

console.log(marketChart.market_caps);

id: string;
contract_address: string;
days: string;
vs_currency: string;
interval?: '5m' | 'hourly' | 'daily';
precision?: string;

Response: { market_caps: number[][]; prices: number[][]; total_volumes: number[][]; }

Summary: NFTs Collection Historical Chart Data by Contract Address

To query historical market data of a NFT collection, including floor price, market cap, and 24hr volume, by number of days away from now based on the provided contract address

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const marketChart = await client.nfts.contract.marketChart.get('contract_address', {
  asset_platform_id: 'asset_platform_id',
  days: 'days',
});

console.log(marketChart.floor_price_native);

asset_platform_id: string;
contract_address: string;
days: string;

Response: { floor_price_native: number[][]; floor_price_usd: number[][]; h24_volume_native: number[][]; h24_volume_usd: number[][]; market_cap_native: number[][]; market_cap_usd: number[][]; }


async function run(client) {
  const res = await client.global.decentralizedFinanceDefi.get();
  return res.data;
}


async function run(client) {
  const res = await client.exchangeRates.get();
  const rates = res.rates;
  return { sats: rates.sats, xdr: rates.xdr };
}


Question: derivatives exchanges list order open interest btc


Summary: Derivatives Exchanges List with Data

To query all the derivatives exchanges with related data (ID, name, open interest, ...) on CoinGecko

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const exchanges = await client.derivatives.exchanges.get();

console.log(exchanges);

Response: { id: string; country: string; description: string; image: string; name: string; number_of_futures_pairs: number; number_of_perpetual_pairs: number; open_interest_btc: number; trade_volume_24h_btc: string; url: string; year_established: number; }[]

Summary: Derivatives Exchanges List

To query all the supported derivatives exchanges with ID and name on CoinGecko

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const response = await client.derivatives.exchanges.getList();

console.log(response);

Response: { id: string; name: string; }[]

Summary: Derivatives Exchange Data by ID

To query the derivatives exchange's related data (name, open interest, trade volume, ...) based on the exchange's ID

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const response = await client.derivatives.exchanges.getID('id');

console.log(response.country);

id: string;
include_tickers?: 'all' | 'unexpired';

Response: { country: string; description: string; image: string; name: string; number_of_futures_pairs: number; number_of_perpetual_pairs: number; open_interest_btc: number; trade_volume_24h_btc: string; url: string; year_established: number; tickers?: { base: string; bid_ask_spread: number; coin_id: string; contract_type: string; converted_last: { btc?: string; eth?: string; usd?: string; }; converted_volume: { btc?: string; eth?: string; usd?: string; }; expired_at: number; funding_rate: number; h24_percentage_change: number; h24_volume: number; index: number; index_basis_percentage: number; last: number; last_traded: number; open_interest_usd: number; symbol: string; target: string; target_coin_id: string; trade_url: string; }[]; }

Summary: Derivatives Tickers List

To query all the tickers from derivatives exchanges on CoinGecko

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const derivatives = await client.derivatives.get();

console.log(derivatives);

Response: { basis: number; contract_type: string; expired_at: number; funding_rate: number; index: number; index_id: string; last_traded_at: number; market: string; open_interest: number; price: string; price_percentage_change_24h: number; spread: number; symbol: string; volume_24h: number; }[]

Summary: Exchanges List

To query all the supported exchanges with ID and name

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const response = await client.exchanges.getList();

console.log(response);

Response: { id: string; name: string; }[]

Summary: Exchanges List with Data

To query all the supported exchanges with exchanges' data (ID, name, country, etc.) that have active trading volumes on CoinGecko

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const exchanges = await client.exchanges.get();

console.log(exchanges);

Response: { id: string; country: string; description: string; has_trading_incentive: boolean; image: string; name: string; trade_volume_24h_btc: number; trust_score: number; trust_score_rank: number; url: string; year_established: number; }[]

Summary: Exchange Data by ID

To query exchange's data (name, year established, country, etc.), exchange volume in BTC and top 100 tickers based on exchange's ID

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const response = await client.exchanges.getID('id');

console.log(response.alert_notice);

Response: { alert_notice: string; centralized: boolean; coins: number; country: string; description: string; facebook_url: string; has_trading_incentive: boolean; image: string; name: string; other_url_1: string; other_url_2: string; pairs: number; public_notice: string; reddit_url: string; slack_url: string; status_updates: { category?: string; created_at?: string; description?: string; pin?: boolean; project?: object; user?: string; user_title?: string; }[]; telegram_url: string; tickers: { base?: string; bid_ask_spread_percentage?: number; coin_id?: string; coin_mcap_usd?: number; converted_last?: object; converted_volume?: object; is_anomaly?: boolean; is_stale?: boolean; last?: number; last_fetch_at?: string; last_traded_at?: string; market?: object; target?: string; target_coin_id?: string; timestamp?: string; token_info_url?: string; trade_url?: string; trust_score?: string; volume?: number; }[]; trade_volume_24h_btc: number; trust_score: number; trust_score_rank: number; twitter_handle: string; url: string; year_established: number; }

Summary: Exchange Volume Chart by ID

To query the historical volume chart data with time in UNIX and trading volume data in BTC based on exchange's ID

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const volumeCharts = await client.exchanges.volumeChart.get('id', { days: '1' });

console.log(volumeCharts);

Response: number | string[][]

Summary: Exchange Volume Chart within Time Range by ID

To query the historical volume chart data in BTC by specifying date range in UNIX based on exchange's ID

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const response = await client.exchanges.volumeChart.getRange('id', { from: 0, to: 0 });

console.log(response);

Response: number | string[][]

Summary: BTC-to-Currency Exchange Rates

To query BTC exchange rates with other currencies

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const exchangeRate = await client.exchangeRates.get();

console.log(exchangeRate.rates);

Response: { rates: object; }


async function run(client) {
  const exchanges = await client.derivatives.exchanges.get({
    order: 'open_interest_btc_desc',
    per_page: 5,
    page: 1,
  });
  return exchanges.map(e => ({
    name: e.name,
    open_interest_btc: e.open_interest_btc,
    number_of_perpetual_pairs: e.number_of_perpetual_pairs,
  }));
}

List top 5 derivatives exchanges ordered by open interest in BTC descending


async function run(client) {
  const platforms = await client.asset_platforms.get({});
  const aurora = platforms.find((p) => p.id === 'aurora');
  return aurora;
}

Find asset platform with id 'aurora' and return its chain_identifier and native_coin_id


The code contains TypeScript diagnostics:
- Property 'asset_platforms' does not exist on type 'Coingecko'. Did you mean 'assetPlatforms'?
    const platforms = await client.asset_platforms.get({});


async function run(client) {
  const platforms = await client.assetPlatforms.get({});
  const aurora = platforms.find((p) => p.id === 'aurora');
  return aurora;
}


async function run(client) {
  try {
    const res = await client.simple.tokenPrice.getId({
      id: 'ethereum',
      contract_addresses: '0x6b175474e89094c44da98b954eedeac495271d0f',
      vs_currencies: 'usd,eth',
      include_market_cap: true,
      include_24hr_vol: true,
    });
    return res;
  } catch (e) {
    return { error: e.message };
  }
}

Get token price with market cap and 24h volume for a contract address on ethereum


The code contains TypeScript diagnostics:
- Property 'getId' does not exist on type 'TokenPrice'. Did you mean 'getID'?
    const res = await client.simple.tokenPrice.getId({


async function run(client) {
  try {
    const res = await client.simple.tokenPrice.getID({
      id: 'ethereum',
      contract_addresses: '0x6b175474e89094c44da98b954eedeac495271d0f',
      vs_currencies: 'usd,eth',
      include_market_cap: true,
      include_24hr_vol: true,
    });
    return res;
  } catch (e) {
    return { error: e.message };
  }
}


The code contains TypeScript diagnostics:
- Expected 2-3 arguments, but got 1.
    const res = await client.simple.tokenPrice.getID({


Question: simple tokenPrice getID contract_addresses


Summary: Token Price by Token Addresses

To get token price based on the provided token contract address on a network

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const response = await client.onchain.simple.networks.tokenPrice.getAddresses('addresses', {
  network: 'network',
});

console.log(response.data);

network: string;
addresses: string;
include_24hr_price_change?: boolean;
include_24hr_vol?: boolean;
include_inactive_source?: boolean;
include_market_cap?: boolean;
include_total_reserve_in_usd?: boolean;
mcap_fdv_fallback?: boolean;

Response: { data: { id: string; attributes: { token_prices: object; h24_price_change_percentage?: object; h24_volume_usd?: object; last_trade_timestamp?: object; market_cap_usd?: object; total_reserve_in_usd?: object; }; type: string; }; }

Summary: Coin Price by Token Addresses

To query one or more token prices by using their token contract addresses

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const response = await client.simple.tokenPrice.getID('id', {
  contract_addresses: 'contract_addresses',
  vs_currencies: 'vs_currencies',
});

console.log(response);

id: string;
contract_addresses: string;
vs_currencies: string;
include_24hr_change?: boolean;
include_24hr_vol?: boolean;
include_last_updated_at?: boolean;
include_market_cap?: boolean;
precision?: string;

Response: object

Summary: Tokens Data by Token Addresses

To query multiple tokens data based on the provided token contract addresses on a network

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const response = await client.onchain.networks.tokens.multi.getAddresses('addresses', {
  network: 'network',
});

console.log(response.data);

network: string;
addresses: string;
include?: 'top_pools';
include_composition?: boolean;
include_inactive_source?: boolean;

Response: { data: { id: string; attributes: object; relationships: object; type: string; }[]; included?: { id?: string; attributes?: { address?: string; base_token_price_native_currency?: string; base_token_price_quote_token?: string; base_token_price_usd?: string; fdv_usd?: string; market_cap_usd?: string; name?: string; pool_created_at?: string; price_change_percentage?: object; quote_token_price_base_token?: string; quote_token_price_native_currency?: string; quote_token_price_usd?: string; reserve_in_usd?: string; transactions?: object; volume_usd?: object; }; relationships?: { base_token?: object; dex?: object; quote_token?: object; }; type?: string; }[]; }

Summary: NFTs Collection Data by Contract Address

To query all the NFT data (name, floor price, 24hr volume, ...) based on the NFT collection contract address and respective asset platform

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const response = await client.nfts.contract.getContractAddress('contract_address', {
  asset_platform_id: 'asset_platform_id',
});

console.log(response.id);

asset_platform_id: string;
contract_address: string;

Response: { id: string; asset_platform_id: string; ath: object; ath_change_percentage: object; ath_date: object; banner_image: string; contract_address: string; description: string; explorers: object[]; floor_price: object; floor_price_14d_percentage_change: object; floor_price_1y_percentage_change: object; floor_price_24h_percentage_change: object; floor_price_30d_percentage_change: object; floor_price_60d_percentage_change: object; floor_price_7d_percentage_change: object; floor_price_in_usd_24h_percentage_change: number; image: object; links: object; market_cap: object; market_cap_24h_percentage_change: object; market_cap_rank: number; name: string; native_currency: string; native_currency_symbol: string; number_of_unique_addresses: number; number_of_unique_addresses_24h_percentage_change: number; one_day_average_sale_price: number; one_day_average_sale_price_24h_percentage_change: number; one_day_sales: number; one_day_sales_24h_percentage_change: number; symbol: string; total_supply: number; user_favorites_count: number; volume_24h: object; volume_24h_percentage_change: object; volume_in_usd_24h_percentage_change: number; web_slug: string; }

Summary: Multiple Pools Data by Pool Addresses

To query multiple pools based on the provided network and pool addresses

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const response = await client.onchain.networks.pools.multi.getAddresses('addresses', {
  network: 'network',
});

console.log(response.data);

network: string;
addresses: string;
include?: string;
include_composition?: boolean;
include_volume_breakdown?: boolean;

Response: { data: { id: string; attributes: object; relationships: object; type: string; }[]; included?: { id?: string; attributes?: { address?: string; coingecko_coin_id?: string; decimals?: number; image_url?: string; name?: string; symbol?: string; }; type?: string; }[]; }

Summary: NFTs Collection Historical Chart Data by Contract Address

To query historical market data of a NFT collection, including floor price, market cap, and 24hr volume, by number of days away from now based on the provided contract address

Response: { floor_price_native: number[][]; floor_price_usd: number[][]; h24_volume_native: number[][]; h24_volume_usd: number[][]; market_cap_native: number[][]; market_cap_usd: number[][]; }

Summary: Coin Data by Token Address

To query all the metadata (image, websites, socials, description, contract address, etc.) and market data (price, ATH, exchange tickers, etc.) of a coin based on an asset platform and a particular token contract address

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const contract = await client.coins.contract.get('contract_address', { id: 'id' });

console.log(contract.id);

Response: { id: string; additional_notices: string[]; asset_platform_id: string; block_time_in_minutes: number; categories: string[]; contract_address: string; country_origin: string; description: object; detail_platforms: object; genesis_date: string; has_supply_breakdown: boolean; hashing_algorithm: string; image: object; last_updated: string; links: object; market_cap_rank: number; market_cap_rank_with_rehypothecated: number; name: string; platforms: object; preview_listing: boolean; public_notice: string; sentiment_votes_down_percentage: number; sentiment_votes_up_percentage: number; status_updates: object[]; symbol: string; watchlist_portfolio_users: number; web_slug: string; community_data?: object; developer_data?: object; localization?: object; market_data?: object; tickers?: object[]; }

Summary: Coin Price by IDs, Symbols, or Names

To query the prices of one or more coins by using their unique Coin API IDs, symbols, or names

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const price = await client.simple.price.get({ vs_currencies: 'vs_currencies' });

console.log(price);

vs_currencies: string;
ids?: string;
include_24hr_change?: boolean;
include_24hr_vol?: boolean;
include_last_updated_at?: boolean;
include_market_cap?: boolean;
include_tokens?: 'top' | 'all';
names?: string;
precision?: string;
symbols?: string;

Response: object

Summary: Coin Historical Chart Data by Token Address

To get the historical chart data including time in UNIX, price, market cap and 24hrs volume based on asset platform and particular token contract address

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const marketChart = await client.coins.contract.marketChart.get('contract_address', {
  id: 'id',
  days: 'days',
  vs_currency: 'vs_currency',
});

console.log(marketChart.market_caps);

Response: { market_caps: number[][]; prices: number[][]; total_volumes: number[][]; }

Summary: Currencies List

To query all the supported currencies on CoinGecko

import Coingecko from '@coingecko/coingecko-typescript';

const client = new Coingecko({
  proAPIKey: [REDACTED]['COINGECKO_PRO_API_KEY'], // This is the default and can be omitted
});

const supportedVsCurrencies = await client.simple.supportedVsCurrencies.get();

console.log(supportedVsCurrencies);

Response: string[]


async function run(client) {
  const res = await client.simple.tokenPrice.getID('ethereum', {
    contract_addresses: '0x6b175474e89094c44da98b954eedeac495271d0f',
    vs_currencies: 'usd,eth',
    include_market_cap: true,
    include_24hr_vol: true,
  });
  return res;
}