OpenParable
Skip to content
← Back to skills

Coingecko API

Apps & Automation
coingecko-api

Coingecko API is an Agent Skill for apps & automation published in the Nethereum/Nethereum repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

Fetch token metadata, prices by contract address or CoinGecko ID, asset platform mappings, and token lists via the CoinGecko API in Nethereum.DataServices

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/Nethereum/Nethereum/blob/HEAD/plugins/nethereum-skills/skills/coingecko-api/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/coingecko-api, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

CoinGecko API

Access CoinGecko token metadata, pricing, and asset platform mappings using Nethereum.DataServices.

NuGet Package: Nethereum.DataServices

Installation

dotnet add package Nethereum.DataServices

Quick Start

using Nethereum.DataServices.CoinGecko;

var coingecko = new CoinGeckoApiService();

// Map chain ID to CoinGecko platform
string platformId = await coingecko.GetPlatformIdForChainAsync(chainId: 1);
// "ethereum"

// Get token list for a chain
var tokenList = await coingecko.GetTokenListForChainAsync(chainId: 1);
Console.WriteLine($"Ethereum tokens: {tokenList.Tokens.Count}");

// Get prices by CoinGecko ID
var prices = await coingecko.GetPricesAsync(new[] { "ethereum", "usd-coin" }, "usd");
Console.WriteLine($"ETH: ${prices["ethereum"]["usd"]}");

// Get price by contract address
decimal? usdcPrice = await coingecko.GetTokenPriceByContractAsync(
    "ethereum", "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", "usd");

Available Methods

MethodReturnsDescription
GetAssetPlatformsAsync(forceRefresh?)List<CoinGeckoAssetPlatform>All blockchain platforms with chain identifiers
GetPlatformIdForChainAsync(chainId)stringMap numeric chain ID to CoinGecko platform ID
GetCoinsListAsync(forceRefresh?)List<CoinGeckoCoin>Every coin with platform/address mappings
GetTokenListForChainAsync(chainId, forceRefresh?)CoinGeckoTokenListToken list for a chain (address, symbol, name, decimals, logo)
GetTokenListForPlatformAsync(platformId, forceRefresh?)CoinGeckoTokenListToken list by platform ID
GetTokensForChainAsync(chainId, forceRefresh?)List<CoinGeckoToken>Flat token collection for a chain
GetPricesAsync(geckoIds, vsCurrency)Dictionary<string, Dictionary<string, decimal>>Batch prices by CoinGecko ID
GetTokenPriceByContractAsync(platformId, address, vsCurrency)decimal?Price by contract address (null if not found)
FindCoinGeckoIdAsync(contractAddress, chainId)stringMap contract address to CoinGecko ID
FindCoinGeckoIdsAsync(addresses, chainId)Dictionary<string, string>Batch address-to-ID mapping
ClearCache()voidClear all cached data

Asset Platforms

var platforms = await coingecko.GetAssetPlatformsAsync();
foreach (var p in platforms.Where(x => x.ChainIdentifier.HasValue).Take(10))
    Console.WriteLine($"Chain {p.ChainIdentifier}: {p.Id} ({p.Name})");

Token Lists

var tokenList = await coingecko.GetTokenListForChainAsync(chainId: 1);
foreach (var token in tokenList.Tokens.Take(5))
    Console.WriteLine($"{token.Symbol}: {token.Name} ({token.Address})");

Pricing

// By CoinGecko ID (batches at 250 per request)
var prices = await coingecko.GetPricesAsync(
    new[] { "ethereum", "usd-coin", "bitcoin" }, "usd");

// By contract address
decimal? price = await coingecko.GetTokenPriceByContractAsync(
    "ethereum", "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", "usd");

Address-to-ID Mapping

string geckoId = await coingecko.FindCoinGeckoIdAsync(
    "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", chainId: 1);
// "usd-coin"

var ids = await coingecko.FindCoinGeckoIdsAsync(
    new[] { "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", "0xdAC17F958D2ee523a2206206994597C13D831ec7" },
    chainId: 1);

Cache Configuration

var config = new CoinGeckoCacheConfiguration
{
    Enabled = true,
    PlatformsCacheDuration = TimeSpan.FromHours(24),
    CoinsListCacheDuration = TimeSpan.FromHours(1),
    TokenListCacheDuration = TimeSpan.FromHours(1),
    RateLimitDelay = TimeSpan.FromMilliseconds(1500)
};

var coingecko = new CoinGeckoApiService(config);

// Disable caching (for tests)
var testService = new CoinGeckoApiService(CoinGeckoCacheConfiguration.Disabled);

// Force refresh specific cache
var fresh = await coingecko.GetAssetPlatformsAsync(forceRefresh: true);

// Clear all caches
coingecko.ClearCache();

Key Namespaces

  • Nethereum.DataServices.CoinGecko — Service, cache config, and response models

Documentation