Set up your API key
Build faster with AI
TL;DR
Connect via MCP for zero-code data access, use the SDK for function calling in custom agents, and query /simple/price, /search, /search/trending, and onchain endpoints for real-time context.
Connect via MCP for zero-code data access, use the SDK for function calling in custom agents, and query /simple/price, /search, /search/trending, and onchain endpoints for real-time context.
Replace YOUR_API_KEY in the examples below with your actual key. Get one here →
Option 1: MCP Server (Zero-Code)
The fastest way to give an AI agent access to CoinGecko data. No SDK code needed — the agent calls tools directly through the Model Context Protocol.Connect the MCP server
- Claude Code
- Cursor / IDE
- Python (MCP Client)
https://mcp.pro-api.coingecko.com/mcp and authenticate via /mcp.Full setup for all platforms: CoinGecko MCP → | MCP Tools →
Add Docs MCP (optional)
Option 2: SDK Function Calling (Custom Agents)
For custom AI agents where you control the tool definitions and execution flow — use the SDK as the function calling backend.Initialize the client
Full SDK setup: Python → | TypeScript →
Define tools for your LLM
Map SDK methods to tool definitions your LLM can call. Example tool schema:
Execute tool calls
When the LLM returns a tool call, execute it against the SDK:
All available methods: TypeScript → | Python →
Key Endpoints for AI Agents
The most useful endpoints for agent tool definitions — each maps to a common user intent.| Intent | Endpoint | What it returns |
|---|---|---|
| ”What’s the price of X?” | /simple/price | Spot prices with optional market cap, volume, 24h change |
| ”Find tokens matching Y” | /search | Coins, categories, and markets matching a query |
| ”What’s trending?” | /search/trending | Top trending coins, NFTs, and categories (24h) |
| “Show me market data” | /coins/markets | Bulk market data — rankings, sparklines, price changes |
| ”Price of this token address” | /onchain/…/token_price | Onchain token price by contract address |
| ”Token info for address” | /onchain/…/tokens/{addr} | Token metadata, price, volume, and top pools |
| ”Trending DEX pools” | /onchain/…/trending_pools | Hottest liquidity pools across all networks |
Prompt Engineering Tips
- Always resolve IDs first. Coin names are ambiguous — use
/searchor/coins/listto resolve to a CoinGecko ID before querying price or market data. - Include units in responses. When returning prices, always include the currency (e.g. “$67,432 USD” not just “67432”).
- Handle missing data. Not all coins have market cap, volume, or contract addresses. Instruct your agent to check for null fields.
- Rate limit awareness. Tell your agent to batch requests where possible (e.g.
ids=bitcoin,ethereum,solanain one call instead of three).
SDK Prompts
AI prompt rules for generating correct CoinGecko SDK code.

