coingecko by sendaifun/skills
npx skills add https://github.com/sendaifun/skills --skill coingecko一份关于集成 CoinGecko Solana 链上 API 的全面指南。可访问 1700 多个去中心化交易所的实时代币价格、DEX 池数据、OHLCV 图表、交易历史和市场分析。
CoinGecko 的 Solana API 提供:
| 特性 | 描述 |
|---|---|
| 250+ 网络 | 包括 Solana 在内的多链支持 |
| 1,700+ DEXes | Raydium、Orca、Jupiter、Meteora、Pump.fun 等 |
| 15M+ 代币 | 全面的代币覆盖 |
| 实时数据 | 每 10-30 秒更新 |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| OHLCV 图表和交易历史 |
# .env 文件
COINGECKO_API_KEY=your_api_key_here
COINGECKO_API_TYPE=demo # 或 'pro'
// 演示和专业 API 的配置
const CONFIG = {
demo: {
baseUrl: 'https://api.coingecko.com/api/v3/onchain',
headerKey: 'x-cg-demo-api-key',
rateLimit: 30, // 每分钟调用次数
},
pro: {
baseUrl: 'https://pro-api.coingecko.com/api/v3/onchain',
headerKey: 'x-cg-pro-api-key',
rateLimit: 500, // 每分钟调用次数(因套餐而异)
},
};
const apiType = process.env.COINGECKO_API_TYPE || 'demo';
const apiKey = process.env.COINGECKO_API_KEY;
const BASE_URL = CONFIG[apiType].baseUrl;
const HEADER_KEY = CONFIG[apiType].headerKey;
// Solana 网络标识符
const NETWORK = 'solana';
async function getTokenPrice(tokenAddress: string): Promise<number | null> {
const url = `${BASE_URL}/simple/networks/${NETWORK}/token_price/${tokenAddress}`;
const response = await fetch(url, {
headers: {
[HEADER_KEY]: apiKey,
'Accept': 'application/json',
},
});
if (!response.ok) {
throw new Error(`API 错误: ${response.status}`);
}
const data = await response.json();
return data.data?.attributes?.token_prices?.[tokenAddress] ?? null;
}
// 用法
const USDC = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v';
const price = await getTokenPrice(USDC);
console.log(`USDC 价格: $${price}`);
按合约地址获取代币价格。
端点 : GET /simple/networks/{network}/token_price/{addresses}
参数 :
| 参数 | 类型 | 必需 | 描述 |
|---|---|---|---|
network | string | 是 | 网络 ID (solana) |
addresses | string | 是 | 逗号分隔的代币地址(演示版最多 30 个,专业版最多 100 个) |
include_market_cap | boolean | 否 | 包含市值数据 |
include_24hr_vol | boolean | 否 | 包含 24 小时交易量 |
include_24hr_price_change | boolean | 否 | 包含 24 小时价格变化百分比 |
async function getTokenPrices(addresses: string[]): Promise<Record<string, TokenPriceData>> {
const addressList = addresses.join(',');
const url = `${BASE_URL}/simple/networks/${NETWORK}/token_price/${addressList}`;
const params = new URLSearchParams({
include_market_cap: 'true',
include_24hr_vol: 'true',
include_24hr_price_change: 'true',
});
const response = await fetch(`${url}?${params}`, {
headers: { [HEADER_KEY]: apiKey },
});
const data = await response.json();
return data.data?.attributes || {};
}
获取详细的代币信息。
端点 : GET /networks/{network}/tokens/{address}
参数 :
| 参数 | 类型 | 必需 | 描述 |
|---|---|---|---|
network | string | 是 | 网络 ID |
address | string | 是 | 代币合约地址 |
include | string | 否 | 包含 top_pools 以获取流动性数据 |
interface TokenData {
address: string;
name: string;
symbol: string;
decimals: number;
image_url: string;
price_usd: string;
fdv_usd: string;
market_cap_usd: string;
total_supply: string;
volume_usd: {
h24: string;
};
price_change_percentage: {
h24: string;
};
}
async function getTokenData(address: string): Promise<TokenData> {
const url = `${BASE_URL}/networks/${NETWORK}/tokens/${address}?include=top_pools`;
const response = await fetch(url, {
headers: { [HEADER_KEY]: apiKey },
});
const data = await response.json();
return data.data?.attributes;
}
批量获取多个代币。
端点 : GET /networks/{network}/tokens/multi/{addresses}
async function getMultipleTokens(addresses: string[]): Promise<TokenData[]> {
const addressList = addresses.join(',');
const url = `${BASE_URL}/networks/${NETWORK}/tokens/multi/${addressList}`;
const response = await fetch(url, {
headers: { [HEADER_KEY]: apiKey },
});
const data = await response.json();
return data.data?.map((item: any) => item.attributes) || [];
}
获取详细的池信息。
端点 : GET /networks/{network}/pools/{address}
参数 :
| 参数 | 类型 | 必需 | 描述 |
|---|---|---|---|
include | string | 否 | base_token, quote_token, dex |
include_volume_breakdown | boolean | 否 | 按时间范围细分交易量 |
interface PoolData {
address: string;
name: string;
pool_created_at: string;
base_token_price_usd: string;
quote_token_price_usd: string;
base_token_price_native_currency: string;
fdv_usd: string;
market_cap_usd: string;
reserve_in_usd: string;
price_change_percentage: {
m5: string;
h1: string;
h6: string;
h24: string;
};
transactions: {
m5: { buys: number; sells: number };
h1: { buys: number; sells: number };
h24: { buys: number; sells: number };
};
volume_usd: {
m5: string;
h1: string;
h6: string;
h24: string;
};
}
async function getPoolData(poolAddress: string): Promise<PoolData> {
const url = `${BASE_URL}/networks/${NETWORK}/pools/${poolAddress}`;
const params = new URLSearchParams({
include: 'base_token,quote_token,dex',
});
const response = await fetch(`${url}?${params}`, {
headers: { [HEADER_KEY]: apiKey },
});
const data = await response.json();
return data.data?.attributes;
}
获取所有网络或按网络筛选的热门池。
端点 : GET /networks/trending_pools
参数 :
| 参数 | 类型 | 默认值 | 描述 |
|---|---|---|---|
include | string | base_token | 要包含的属性 |
page | integer | 1 | 页码 |
duration | string | 24h | 5m, 1h, 6h, 24h |
async function getTrendingPools(duration: '5m' | '1h' | '6h' | '24h' = '24h'): Promise<PoolData[]> {
const url = `${BASE_URL}/networks/trending_pools`;
const params = new URLSearchParams({
include: 'base_token,quote_token,dex,network',
duration,
page: '1',
});
const response = await fetch(`${url}?${params}`, {
headers: { [HEADER_KEY]: apiKey },
});
const data = await response.json();
return data.data?.map((item: any) => item.attributes) || [];
}
// 筛选 Solana 池
async function getSolanaTrendingPools(): Promise<PoolData[]> {
const allPools = await getTrendingPools();
return allPools.filter(pool => pool.network === 'solana');
}
获取 Solana 上按交易量排名的顶级池。
端点 : GET /networks/{network}/pools
async function getTopPools(page: number = 1): Promise<PoolData[]> {
const url = `${BASE_URL}/networks/${NETWORK}/pools`;
const params = new URLSearchParams({
include: 'base_token,quote_token,dex',
page: page.toString(),
});
const response = await fetch(`${url}?${params}`, {
headers: { [HEADER_KEY]: apiKey },
});
const data = await response.json();
return data.data?.map((item: any) => item.attributes) || [];
}
通过代币名称、符号或地址搜索池。
端点 : GET /search/pools
参数 :
| 参数 | 类型 | 描述 |
|---|---|---|
query | string | 搜索词(名称、符号、地址) |
network | string | 按网络筛选 |
page | integer | 页码 |
async function searchPools(query: string): Promise<PoolData[]> {
const url = `${BASE_URL}/search/pools`;
const params = new URLSearchParams({
query,
network: NETWORK,
include: 'base_token,quote_token,dex',
});
const response = await fetch(`${url}?${params}`, {
headers: { [HEADER_KEY]: apiKey },
});
const data = await response.json();
return data.data?.map((item: any) => item.attributes) || [];
}
// 搜索 SOL 池
const solPools = await searchPools('SOL');
获取用于技术分析的 K 线数据。
端点 : GET /networks/{network}/pools/{pool_address}/ohlcv/{timeframe}
时间范围 : day, hour, minute
参数 :
| 参数 | 类型 | 描述 |
|---|---|---|
aggregate | integer | K 线聚合(分钟:1、5、15;小时:1、4、12) |
before_timestamp | integer | 用于分页的 Unix 时间戳 |
limit | integer | K 线数量(最多 1000) |
currency | string | usd 或 token |
interface OHLCVData {
timestamp: number;
open: number;
high: number;
low: number;
close: number;
volume: number;
}
async function getPoolOHLCV(
poolAddress: string,
timeframe: 'day' | 'hour' | 'minute' = 'hour',
aggregate: number = 1,
limit: number = 100
): Promise<OHLCVData[]> {
const url = `${BASE_URL}/networks/${NETWORK}/pools/${poolAddress}/ohlcv/${timeframe}`;
const params = new URLSearchParams({
aggregate: aggregate.toString(),
limit: limit.toString(),
currency: 'usd',
});
const response = await fetch(`${url}?${params}`, {
headers: { [HEADER_KEY]: apiKey },
});
const data = await response.json();
return data.data?.attributes?.ohlcv_list?.map((candle: number[]) => ({
timestamp: candle[0],
open: candle[1],
high: candle[2],
low: candle[3],
close: candle[4],
volume: candle[5],
})) || [];
}
// 获取小时 K 线
const hourlyCandles = await getPoolOHLCV(poolAddress, 'hour', 1, 24);
// 获取 5 分钟 K 线
const fiveMinCandles = await getPoolOHLCV(poolAddress, 'minute', 5, 100);
获取池的近期交易。
端点 : GET /networks/{network}/pools/{pool_address}/trades
interface TradeData {
block_number: number;
block_timestamp: string;
tx_hash: string;
tx_from_address: string;
from_token_amount: string;
to_token_amount: string;
price_from_in_currency_token: string;
price_to_in_currency_token: string;
price_from_in_usd: string;
price_to_in_usd: string;
kind: 'buy' | 'sell';
volume_in_usd: string;
}
async function getRecentTrades(poolAddress: string): Promise<TradeData[]> {
const url = `${BASE_URL}/networks/${NETWORK}/pools/${poolAddress}/trades`;
const response = await fetch(url, {
headers: { [HEADER_KEY]: apiKey },
});
const data = await response.json();
return data.data?.map((item: any) => item.attributes) || [];
}
获取 Solana 上所有的去中心化交易所。
端点 : GET /networks/{network}/dexes
interface DexData {
id: string;
name: string;
}
async function getSolanaDexes(): Promise<DexData[]> {
const url = `${BASE_URL}/networks/${NETWORK}/dexes`;
const response = await fetch(url, {
headers: { [HEADER_KEY]: apiKey },
});
const data = await response.json();
return data.data?.map((item: any) => ({
id: item.id,
name: item.attributes.name,
})) || [];
}
跨网络、DEX 和代币对池进行高级筛选。
端点 : GET /pools/megafilter
参数 :
| 参数 | 类型 | 描述 |
|---|---|---|
networks | string | 按网络筛选 |
dexes | string | 按 DEX 筛选 |
sort | string | 排序方式(例如 pool_created_at_desc) |
min_reserve_in_usd | number | 最小流动性 |
min_h24_volume_usd | number | 最小 24 小时交易量 |
async function getMegafilterPools(options: {
dexes?: string[];
minLiquidity?: number;
minVolume?: number;
sort?: string;
}): Promise<PoolData[]> {
const url = `${BASE_URL}/pools/megafilter`;
const params = new URLSearchParams({
networks: NETWORK,
page: '1',
});
if (options.dexes) {
params.set('dexes', options.dexes.join(','));
}
if (options.minLiquidity) {
params.set('min_reserve_in_usd', options.minLiquidity.toString());
}
if (options.minVolume) {
params.set('min_h24_volume_usd', options.minVolume.toString());
}
if (options.sort) {
params.set('sort', options.sort);
}
const response = await fetch(`${url}?${params}`, {
headers: { [HEADER_KEY]: apiKey },
});
const data = await response.json();
return data.data?.map((item: any) => item.attributes) || [];
}
// 获取最新的 Pump.fun 池
const pumpfunPools = await getMegafilterPools({
dexes: ['pump-fun'],
sort: 'pool_created_at_desc',
});
// 获取高交易量的 Raydium 池
const raydiumPools = await getMegafilterPools({
dexes: ['raydium'],
minVolume: 100000,
minLiquidity: 50000,
});
| DEX | ID | 描述 |
|---|---|---|
| Raydium | raydium | Solana 上领先的 AMM |
| Orca | orca | 用户友好的 DEX |
| Jupiter | jupiter | 带池的聚合器 |
| Meteora | meteora | 动态 AMM |
| Pump.fun | pump-fun | Memecoin 启动平台 |
| OpenBook | openbook | 订单簿 DEX |
| Lifinity | lifinity | 主动做市商 |
| Phoenix | phoenix | 链上订单簿 |
| 代币 | 地址 |
|---|---|
| USDC | EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v |
| USDT | Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB |
| SOL (Wrapped) | So11111111111111111111111111111111111111112 |
| JUP | JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN |
| BONK | DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263 |
| WIF | EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm |
| PYTH | HZ1JovNiVvGrGNiiYvEozEVgZ58xaU3RKwX8eACQBCt3 |
| RAY | 4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R |
| ORCA | orcaEKTdK7LKz57vaAYr9QeNsVEPfiu6QeMU1kektZE |
| 套餐 | 调用次数/分钟 | 最大地址数/请求 |
|---|---|---|
| 演示版(免费) | 30 | 30 |
| 分析师版 | 500 | 50 |
| 轻量版 | 500 | 50 |
| 专业版 | 1,000 | 100 |
| 企业版 | 自定义 | 自定义 |
class RateLimiter {
private calls: number[] = [];
private maxCalls: number;
private windowMs: number = 60000; // 1 分钟
constructor(maxCallsPerMinute: number) {
this.maxCalls = maxCallsPerMinute;
}
async waitForSlot(): Promise<void> {
const now = Date.now();
this.calls = this.calls.filter(t => now - t < this.windowMs);
if (this.calls.length >= this.maxCalls) {
const oldestCall = this.calls[0];
const waitTime = this.windowMs - (now - oldestCall);
await new Promise(resolve => setTimeout(resolve, waitTime));
}
this.calls.push(Date.now());
}
}
// 用法
const rateLimiter = new RateLimiter(30); // 演示版 API
async function fetchWithRateLimit(url: string): Promise<any> {
await rateLimiter.waitForSlot();
const response = await fetch(url, {
headers: { [HEADER_KEY]: apiKey },
});
return response.json();
}
async function safeApiCall<T>(url: string): Promise<T | null> {
try {
const response = await fetch(url, {
headers: { [HEADER_KEY]: apiKey },
});
if (response.status === 401) {
throw new Error('无效的 API 密钥');
}
if (response.status === 429) {
throw new Error('超出速率限制 - 请等待后重试');
}
if (response.status === 404) {
console.warn('未找到资源');
return null;
}
if (!response.ok) {
throw new Error(`API 错误: ${response.status}`);
}
return response.json();
} catch (error) {
console.error('CoinGecko API 错误:', error);
throw error;
}
}
| 代码 | 含义 | 解决方案 |
|---|---|---|
| 401 | 无效的 API 密钥 | 检查您的 API 密钥 |
| 429 | 超出速率限制 | 等待后重试,或升级套餐 |
| 404 | 未找到资源 | 检查地址/网络 ID |
| 500+ | 服务器错误 | 使用指数退避重试 |
coingecko/
├── SKILL.md # 本文件
├── resources/
│ ├── api-reference.md # 完整的 API 端点参考
│ ├── network-dex-ids.md # Solana 网络和 DEX 标识符
│ └── token-addresses.md # 常见 Solana 代币地址
├── examples/
│ ├── token-prices/
│ │ └── get-token-price.ts # 代币价格示例
│ ├── pools/
│ │ └── pool-data.ts # 池数据示例
│ ├── ohlcv/
│ │ └── ohlcv-charts.ts # OHLCV 图表示例
│ ├── trades/
│ │ └── recent-trades.ts # 交易历史示例
│ └── integration/
│ └── full-client.ts # 完整客户端示例
├── templates/
│ └── coingecko-client.ts # 生产就绪的客户端模板
└── docs/
└── troubleshooting.md # 常见问题及解决方案
每周安装数
79
仓库
GitHub 星标数
68
首次出现
2026年1月24日
安全审计
安装于
opencode63
gemini-cli63
codex63
cursor62
github-copilot60
kimi-cli57
A comprehensive guide for integrating CoinGecko's on-chain API for Solana. Access real-time token prices, DEX pool data, OHLCV charts, trade history, and market analytics across 1,700+ decentralized exchanges.
CoinGecko's Solana API provides:
| Feature | Description |
|---|---|
| 250+ Networks | Multi-chain support including Solana |
| 1,700+ DEXes | Raydium, Orca, Jupiter, Meteora, Pump.fun, etc. |
| 15M+ Tokens | Comprehensive token coverage |
| Real-time Data | Updates every 10-30 seconds |
| Historical Data | OHLCV charts and trade history |
# .env file
COINGECKO_API_KEY=your_api_key_here
COINGECKO_API_TYPE=demo # or 'pro'
// Configuration for both Demo and Pro APIs
const CONFIG = {
demo: {
baseUrl: 'https://api.coingecko.com/api/v3/onchain',
headerKey: 'x-cg-demo-api-key',
rateLimit: 30, // calls per minute
},
pro: {
baseUrl: 'https://pro-api.coingecko.com/api/v3/onchain',
headerKey: 'x-cg-pro-api-key',
rateLimit: 500, // calls per minute (varies by plan)
},
};
const apiType = process.env.COINGECKO_API_TYPE || 'demo';
const apiKey = process.env.COINGECKO_API_KEY;
const BASE_URL = CONFIG[apiType].baseUrl;
const HEADER_KEY = CONFIG[apiType].headerKey;
// Solana network identifier
const NETWORK = 'solana';
async function getTokenPrice(tokenAddress: string): Promise<number | null> {
const url = `${BASE_URL}/simple/networks/${NETWORK}/token_price/${tokenAddress}`;
const response = await fetch(url, {
headers: {
[HEADER_KEY]: apiKey,
'Accept': 'application/json',
},
});
if (!response.ok) {
throw new Error(`API error: ${response.status}`);
}
const data = await response.json();
return data.data?.attributes?.token_prices?.[tokenAddress] ?? null;
}
// Usage
const USDC = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v';
const price = await getTokenPrice(USDC);
console.log(`USDC Price: $${price}`);
Get token prices by contract address.
Endpoint : GET /simple/networks/{network}/token_price/{addresses}
Parameters :
| Parameter | Type | Required | Description |
|---|---|---|---|
network | string | Yes | Network ID (solana) |
addresses | string | Yes | Comma-separated token addresses (max 30 Demo, 100 Pro) |
include_market_cap | boolean | No | Include market cap data |
include_24hr_vol | boolean |
async function getTokenPrices(addresses: string[]): Promise<Record<string, TokenPriceData>> {
const addressList = addresses.join(',');
const url = `${BASE_URL}/simple/networks/${NETWORK}/token_price/${addressList}`;
const params = new URLSearchParams({
include_market_cap: 'true',
include_24hr_vol: 'true',
include_24hr_price_change: 'true',
});
const response = await fetch(`${url}?${params}`, {
headers: { [HEADER_KEY]: apiKey },
});
const data = await response.json();
return data.data?.attributes || {};
}
Get detailed token information.
Endpoint : GET /networks/{network}/tokens/{address}
Parameters :
| Parameter | Type | Required | Description |
|---|---|---|---|
network | string | Yes | Network ID |
address | string | Yes | Token contract address |
include | string | No | Include top_pools for liquidity data |
interface TokenData {
address: string;
name: string;
symbol: string;
decimals: number;
image_url: string;
price_usd: string;
fdv_usd: string;
market_cap_usd: string;
total_supply: string;
volume_usd: {
h24: string;
};
price_change_percentage: {
h24: string;
};
}
async function getTokenData(address: string): Promise<TokenData> {
const url = `${BASE_URL}/networks/${NETWORK}/tokens/${address}?include=top_pools`;
const response = await fetch(url, {
headers: { [HEADER_KEY]: apiKey },
});
const data = await response.json();
return data.data?.attributes;
}
Batch fetch multiple tokens.
Endpoint : GET /networks/{network}/tokens/multi/{addresses}
async function getMultipleTokens(addresses: string[]): Promise<TokenData[]> {
const addressList = addresses.join(',');
const url = `${BASE_URL}/networks/${NETWORK}/tokens/multi/${addressList}`;
const response = await fetch(url, {
headers: { [HEADER_KEY]: apiKey },
});
const data = await response.json();
return data.data?.map((item: any) => item.attributes) || [];
}
Get detailed pool information.
Endpoint : GET /networks/{network}/pools/{address}
Parameters :
| Parameter | Type | Required | Description |
|---|---|---|---|
include | string | No | base_token, quote_token, dex |
include_volume_breakdown | boolean | No | Volume breakdown by timeframe |
interface PoolData {
address: string;
name: string;
pool_created_at: string;
base_token_price_usd: string;
quote_token_price_usd: string;
base_token_price_native_currency: string;
fdv_usd: string;
market_cap_usd: string;
reserve_in_usd: string;
price_change_percentage: {
m5: string;
h1: string;
h6: string;
h24: string;
};
transactions: {
m5: { buys: number; sells: number };
h1: { buys: number; sells: number };
h24: { buys: number; sells: number };
};
volume_usd: {
m5: string;
h1: string;
h6: string;
h24: string;
};
}
async function getPoolData(poolAddress: string): Promise<PoolData> {
const url = `${BASE_URL}/networks/${NETWORK}/pools/${poolAddress}`;
const params = new URLSearchParams({
include: 'base_token,quote_token,dex',
});
const response = await fetch(`${url}?${params}`, {
headers: { [HEADER_KEY]: apiKey },
});
const data = await response.json();
return data.data?.attributes;
}
Get trending pools across all networks or filtered by network.
Endpoint : GET /networks/trending_pools
Parameters :
| Parameter | Type | Default | Description |
|---|---|---|---|
include | string | base_token | Attributes to include |
page | integer | 1 | Page number |
duration | string | 24h | 5m, , , |
async function getTrendingPools(duration: '5m' | '1h' | '6h' | '24h' = '24h'): Promise<PoolData[]> {
const url = `${BASE_URL}/networks/trending_pools`;
const params = new URLSearchParams({
include: 'base_token,quote_token,dex,network',
duration,
page: '1',
});
const response = await fetch(`${url}?${params}`, {
headers: { [HEADER_KEY]: apiKey },
});
const data = await response.json();
return data.data?.map((item: any) => item.attributes) || [];
}
// Filter for Solana pools
async function getSolanaTrendingPools(): Promise<PoolData[]> {
const allPools = await getTrendingPools();
return allPools.filter(pool => pool.network === 'solana');
}
Get top pools by volume on Solana.
Endpoint : GET /networks/{network}/pools
async function getTopPools(page: number = 1): Promise<PoolData[]> {
const url = `${BASE_URL}/networks/${NETWORK}/pools`;
const params = new URLSearchParams({
include: 'base_token,quote_token,dex',
page: page.toString(),
});
const response = await fetch(`${url}?${params}`, {
headers: { [HEADER_KEY]: apiKey },
});
const data = await response.json();
return data.data?.map((item: any) => item.attributes) || [];
}
Search for pools by token name, symbol, or address.
Endpoint : GET /search/pools
Parameters :
| Parameter | Type | Description |
|---|---|---|
query | string | Search term (name, symbol, address) |
network | string | Filter by network |
page | integer | Page number |
async function searchPools(query: string): Promise<PoolData[]> {
const url = `${BASE_URL}/search/pools`;
const params = new URLSearchParams({
query,
network: NETWORK,
include: 'base_token,quote_token,dex',
});
const response = await fetch(`${url}?${params}`, {
headers: { [HEADER_KEY]: apiKey },
});
const data = await response.json();
return data.data?.map((item: any) => item.attributes) || [];
}
// Search for SOL pools
const solPools = await searchPools('SOL');
Get candlestick data for technical analysis.
Endpoint : GET /networks/{network}/pools/{pool_address}/ohlcv/{timeframe}
Timeframes : day, hour, minute
Parameters :
| Parameter | Type | Description |
|---|---|---|
aggregate | integer | Candle aggregation (1, 5, 15 for minute; 1, 4, 12 for hour) |
before_timestamp | integer | Unix timestamp for pagination |
limit | integer | Number of candles (max 1000) |
currency | string | usd or token |
interface OHLCVData {
timestamp: number;
open: number;
high: number;
low: number;
close: number;
volume: number;
}
async function getPoolOHLCV(
poolAddress: string,
timeframe: 'day' | 'hour' | 'minute' = 'hour',
aggregate: number = 1,
limit: number = 100
): Promise<OHLCVData[]> {
const url = `${BASE_URL}/networks/${NETWORK}/pools/${poolAddress}/ohlcv/${timeframe}`;
const params = new URLSearchParams({
aggregate: aggregate.toString(),
limit: limit.toString(),
currency: 'usd',
});
const response = await fetch(`${url}?${params}`, {
headers: { [HEADER_KEY]: apiKey },
});
const data = await response.json();
return data.data?.attributes?.ohlcv_list?.map((candle: number[]) => ({
timestamp: candle[0],
open: candle[1],
high: candle[2],
low: candle[3],
close: candle[4],
volume: candle[5],
})) || [];
}
// Get hourly candles
const hourlyCandles = await getPoolOHLCV(poolAddress, 'hour', 1, 24);
// Get 5-minute candles
const fiveMinCandles = await getPoolOHLCV(poolAddress, 'minute', 5, 100);
Get recent trades for a pool.
Endpoint : GET /networks/{network}/pools/{pool_address}/trades
interface TradeData {
block_number: number;
block_timestamp: string;
tx_hash: string;
tx_from_address: string;
from_token_amount: string;
to_token_amount: string;
price_from_in_currency_token: string;
price_to_in_currency_token: string;
price_from_in_usd: string;
price_to_in_usd: string;
kind: 'buy' | 'sell';
volume_in_usd: string;
}
async function getRecentTrades(poolAddress: string): Promise<TradeData[]> {
const url = `${BASE_URL}/networks/${NETWORK}/pools/${poolAddress}/trades`;
const response = await fetch(url, {
headers: { [HEADER_KEY]: apiKey },
});
const data = await response.json();
return data.data?.map((item: any) => item.attributes) || [];
}
Get all decentralized exchanges on Solana.
Endpoint : GET /networks/{network}/dexes
interface DexData {
id: string;
name: string;
}
async function getSolanaDexes(): Promise<DexData[]> {
const url = `${BASE_URL}/networks/${NETWORK}/dexes`;
const response = await fetch(url, {
headers: { [HEADER_KEY]: apiKey },
});
const data = await response.json();
return data.data?.map((item: any) => ({
id: item.id,
name: item.attributes.name,
})) || [];
}
Advanced filtering for pools across networks, DEXes, and tokens.
Endpoint : GET /pools/megafilter
Parameters :
| Parameter | Type | Description |
|---|---|---|
networks | string | Filter by network(s) |
dexes | string | Filter by DEX(es) |
sort | string | Sort order (e.g., pool_created_at_desc) |
min_reserve_in_usd | number | Minimum liquidity |
min_h24_volume_usd |
async function getMegafilterPools(options: {
dexes?: string[];
minLiquidity?: number;
minVolume?: number;
sort?: string;
}): Promise<PoolData[]> {
const url = `${BASE_URL}/pools/megafilter`;
const params = new URLSearchParams({
networks: NETWORK,
page: '1',
});
if (options.dexes) {
params.set('dexes', options.dexes.join(','));
}
if (options.minLiquidity) {
params.set('min_reserve_in_usd', options.minLiquidity.toString());
}
if (options.minVolume) {
params.set('min_h24_volume_usd', options.minVolume.toString());
}
if (options.sort) {
params.set('sort', options.sort);
}
const response = await fetch(`${url}?${params}`, {
headers: { [HEADER_KEY]: apiKey },
});
const data = await response.json();
return data.data?.map((item: any) => item.attributes) || [];
}
// Get newest Pump.fun pools
const pumpfunPools = await getMegafilterPools({
dexes: ['pump-fun'],
sort: 'pool_created_at_desc',
});
// Get high-volume Raydium pools
const raydiumPools = await getMegafilterPools({
dexes: ['raydium'],
minVolume: 100000,
minLiquidity: 50000,
});
| DEX | ID | Description |
|---|---|---|
| Raydium | raydium | Leading AMM on Solana |
| Orca | orca | User-friendly DEX |
| Jupiter | jupiter | Aggregator with pools |
| Meteora | meteora | Dynamic AMM |
| Pump.fun | pump-fun | Memecoin launchpad |
| Token | Address |
|---|---|
| USDC | EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v |
| USDT | Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB |
| SOL (Wrapped) | So11111111111111111111111111111111111111112 |
| JUP | JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN |
| BONK | DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263 |
| WIF | EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm |
| Plan | Calls/Minute | Max Addresses/Request |
|---|---|---|
| Demo (Free) | 30 | 30 |
| Analyst | 500 | 50 |
| Lite | 500 | 50 |
| Pro | 1,000 | 100 |
| Enterprise | Custom | Custom |
class RateLimiter {
private calls: number[] = [];
private maxCalls: number;
private windowMs: number = 60000; // 1 minute
constructor(maxCallsPerMinute: number) {
this.maxCalls = maxCallsPerMinute;
}
async waitForSlot(): Promise<void> {
const now = Date.now();
this.calls = this.calls.filter(t => now - t < this.windowMs);
if (this.calls.length >= this.maxCalls) {
const oldestCall = this.calls[0];
const waitTime = this.windowMs - (now - oldestCall);
await new Promise(resolve => setTimeout(resolve, waitTime));
}
this.calls.push(Date.now());
}
}
// Usage
const rateLimiter = new RateLimiter(30); // Demo API
async function fetchWithRateLimit(url: string): Promise<any> {
await rateLimiter.waitForSlot();
const response = await fetch(url, {
headers: { [HEADER_KEY]: apiKey },
});
return response.json();
}
async function safeApiCall<T>(url: string): Promise<T | null> {
try {
const response = await fetch(url, {
headers: { [HEADER_KEY]: apiKey },
});
if (response.status === 401) {
throw new Error('Invalid API key');
}
if (response.status === 429) {
throw new Error('Rate limit exceeded - wait before retrying');
}
if (response.status === 404) {
console.warn('Resource not found');
return null;
}
if (!response.ok) {
throw new Error(`API error: ${response.status}`);
}
return response.json();
} catch (error) {
console.error('CoinGecko API error:', error);
throw error;
}
}
| Code | Meaning | Solution |
|---|---|---|
| 401 | Invalid API key | Check your API key |
| 429 | Rate limit exceeded | Wait and retry, or upgrade plan |
| 404 | Resource not found | Check address/network ID |
| 500+ | Server error | Retry with exponential backoff |
coingecko/
├── SKILL.md # This file
├── resources/
│ ├── api-reference.md # Complete API endpoint reference
│ ├── network-dex-ids.md # Solana network and DEX identifiers
│ └── token-addresses.md # Common Solana token addresses
├── examples/
│ ├── token-prices/
│ │ └── get-token-price.ts # Token price examples
│ ├── pools/
│ │ └── pool-data.ts # Pool data examples
│ ├── ohlcv/
│ │ └── ohlcv-charts.ts # OHLCV chart examples
│ ├── trades/
│ │ └── recent-trades.ts # Trade history examples
│ └── integration/
│ └── full-client.ts # Complete client example
├── templates/
│ └── coingecko-client.ts # Production-ready client template
└── docs/
└── troubleshooting.md # Common issues and solutions
Weekly Installs
79
Repository
GitHub Stars
68
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubFailSocketPassSnykWarn
Installed on
opencode63
gemini-cli63
codex63
cursor62
github-copilot60
kimi-cli57
Lark CLI IM 即时消息管理工具:机器人/用户身份操作聊天、消息、文件下载
34,600 周安装
| No |
| Include 24h volume |
include_24hr_price_change | boolean | No | Include 24h price change % |
1h6h24h| number |
| Minimum 24h volume |
| OpenBook |
openbook |
| Order book DEX |
| Lifinity | lifinity | Proactive market maker |
| Phoenix | phoenix | On-chain order book |
| PYTH | HZ1JovNiVvGrGNiiYvEozEVgZ58xaU3RKwX8eACQBCt3 |
| RAY | 4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R |
| ORCA | orcaEKTdK7LKz57vaAYr9QeNsVEPfiu6QeMU1kektZE |