Skip to main content

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.
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.
1

Connect the MCP server

For higher limits, use https://mcp.pro-api.coingecko.com/mcp and authenticate via /mcp.
Full setup for all platforms: CoinGecko MCP → | MCP Tools →
2

Add Docs MCP (optional)

Let your agent search CoinGecko documentation for endpoint details and parameter info.
Docs MCP →
3

Ask your agent

The agent now has access to 85+ CoinGecko tools. Try:
  • “What’s the current price of Bitcoin, Ethereum, and Solana?”
  • “Show me the top 10 trending pools on Base”
  • “Find all tokens related to ‘AI’ and get their market data”

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.
1

Install the SDK

2

Initialize the client

Full SDK setup: Python → | TypeScript →
3

Define tools for your LLM

Map SDK methods to tool definitions your LLM can call. Example tool schema:
4

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.
Use /search as your agent’s resolver — when a user mentions a coin by name or symbol, search first to get the correct CoinGecko ID, then pass it to other endpoints.

Prompt Engineering Tips

  • Always resolve IDs first. Coin names are ambiguous — use /search or /coins/list to 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,solana in one call instead of three).

SDK Prompts

AI prompt rules for generating correct CoinGecko SDK code.