Skill: olisim02/coingecko (version 1.0.0)

--- name: coingecko description: Fetch crypto prices, market data, and token info from the CoinGecko free API. Use when the user asks about crypto prices, market caps, 24h changes, trending coins, or token lookups. Covers BTC, ETH, SOL, and thousands of altcoins. Also supports Solana token lookups by contract address. --- # CoinGecko Crypto Price Skill Fetches crypto market data from the CoinGecko free API (no key required, ~30 req/min rate limit). ## Commands ### Price check (one or more coins) ```bash python3 scripts/price.py bitcoin ethereum solana ``` Returns: price, 24h change, market cap, volume for each coin. ### Search for a coin by name/ticker ```bash python3 scripts/search.py "pepe" ``` Returns: matching coin IDs, symbols, and market cap ranks. ### Token lookup by contract address (Solana, Ethereum, etc.) ```bash python3 scripts/token.py solana <contract_address> ``` Returns: token name, price, 24h change, market cap, liquidity info. ### Trending coins ```bash python3 scripts/trending.py ``` Returns: top trending coins on CoinGecko. ## Coin IDs CoinGecko uses slug IDs (e.g., `bitcoin`, `ethereum`, `solana`, `dogecoin`). Use `search.py` to find the correct ID if unsure. ## Rate Limits Free API: ~30 calls/min. Cache results when doing bulk lookups. Avoid calling in tight loops.

path: scripts/price.py
content: #!/usr/bin/env python3
"""Fetch current prices for one or more CoinGecko coin IDs."""
import sys, json, urllib.request, urllib.error

def main():
    if len(sys.argv) < 2:
        print("Usage: price.py <coin_id> [coin_id2 ...]", file=sys.stderr)
        sys.exit(1)

    ids = ",".join(sys.argv[1:])
    url = f"https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids={ids}&order=market_cap_desc&sparkline=false&price_change_percentage=24h,7d"

    req = urllib.request.Request(url, headers={"Accept": "application/json", "User-Agent": "openclaw-coingecko/1.0"})
    try:
        with urllib.request.urlopen(req, timeout=15) as resp:
            data = json.loads(resp.read())
    except urllib.error.HTTPError as e:
        print(json.dumps({"error": f"HTTP {e.code}", "message": e.read().decode()[:500]}))
        sys.exit(1)

    results = []
    for coin in data:
        results.append({
            "id": coin["id"],
            "symbol": coin["symbol"].upper(),
            "name": coin["name"],
            "price": coin["current_price"],
            "market_cap": coin["market_cap"],
            "volume_24h": coin["total_volume"],
            "change_24h_pct": coin.get("price_change_percentage_24h"),
            "change_7d_pct": coin.get("price_change_percentage_7d_in_currency"),
            "high_24h": coin["high_24h"],
            "low_24h": coin["low_24h"],
            "ath": coin["ath"],
            "ath_change_pct": coin["ath_change_percentage"],
            "rank": coin["market_cap_rank"],
        })

    print(json.dumps(results, indent=2))

if __name__ == "__main__":
    main()


path: scripts/search.py
content: #!/usr/bin/env python3
"""Search CoinGecko for a coin by name or ticker."""
import sys, json, urllib.request, urllib.error, urllib.parse

def main():
    if len(sys.argv) < 2:
        print("Usage: search.py <query>", file=sys.stderr)
        sys.exit(1)

    query = urllib.parse.quote(" ".join(sys.argv[1:]))
    url = f"https://api.coingecko.com/api/v3/search?query={query}"

    req = urllib.request.Request(url, headers={"Accept": "application/json", "User-Agent": "openclaw-coingecko/1.0"})
    try:
        with urllib.request.urlopen(req, timeout=15) as resp:
            data = json.loads(resp.read())
    except urllib.error.HTTPError as e:
        print(json.dumps({"error": f"HTTP {e.code}"}))
        sys.exit(1)

    results = []
    for coin in data.get("coins", [])[:10]:
        results.append({
            "id": coin["id"],
            "symbol": coin["symbol"],
            "name": coin["name"],
            "market_cap_rank": coin.get("market_cap_rank"),
        })

    print(json.dumps(results, indent=2))

if __name__ == "__main__":
    main()


path: scripts/token.py
content: #!/usr/bin/env python3
"""Look up a token by contract address on a given platform."""
import sys, json, urllib.request, urllib.error

PLATFORMS = {"solana": "solana", "ethereum": "ethereum", "base": "base", "arbitrum": "arbitrum-one", "polygon": "polygon-pos"}

def main():
    if len(sys.argv) < 3:
        print("Usage: token.py <platform> <contract_address>", file=sys.stderr)
        print(f"Platforms: {', '.join(PLATFORMS.keys())}", file=sys.stderr)
        sys.exit(1)

    platform = PLATFORMS.get(sys.argv[1].lower(), sys.argv[1].lower())
    address = sys.argv[2]
    url = f"https://api.coingecko.com/api/v3/coins/{platform}/contract/{address}"

    req = urllib.request.Request(url, headers={"Accept": "application/json", "User-Agent": "openclaw-coingecko/1.0"})
    try:
        with urllib.request.urlopen(req, timeout=15) as resp:
            data = json.loads(resp.read())
    except urllib.error.HTTPError as e:
        if e.code == 404:
            print(json.dumps({"error": "Token not found", "platform": platform, "address": address}))
        else:
            print(json.dumps({"error": f"HTTP {e.code}", "message": e.read().decode()[:500]}))
        sys.exit(1)

    market = data.get("market_data", {})
    result = {
        "id": data.get("id"),
        "symbol": data.get("symbol", "").upper(),
        "name": data.get("name"),
        "price_usd": market.get("current_price", {}).get("usd"),
        "market_cap_usd": market.get("market_cap", {}).get("usd"),
        "volume_24h_usd": market.get("total_volume", {}).get("usd"),
        "change_24h_pct": market.get("price_change_percentage_24h"),
        "change_7d_pct": market.get("price_change_percentage_7d"),
        "total_supply": market.get("total_supply"),
        "circulating_supply": market.get("circulating_supply"),
    }

    print(json.dumps(result, indent=2))

if __name__ == "__main__":
    main()


path: scripts/trending.py
content: #!/usr/bin/env python3
"""Fetch trending coins from CoinGecko."""
import json, urllib.request, urllib.error

def main():
    url = "https://api.coingecko.com/api/v3/search/trending"
    req = urllib.request.Request(url, headers={"Accept": "application/json", "User-Agent": "openclaw-coingecko/1.0"})
    try:
        with urllib.request.urlopen(req, timeout=15) as resp:
            data = json.loads(resp.read())
    except urllib.error.HTTPError as e:
        print(json.dumps({"error": f"HTTP {e.code}"}))
        import sys; sys.exit(1)

    results = []
    for item in data.get("coins", []):
        coin = item.get("item", {})
        results.append({
            "id": coin.get("id"),
            "symbol": coin.get("symbol"),
            "name": coin.get("name"),
            "market_cap_rank": coin.get("market_cap_rank"),
            "price_btc": coin.get("price_btc"),
        })

    print(json.dumps(results, indent=2))

if __name__ == "__main__":
    main()


Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: suspicious | SkillSpector: clean (LOW)