Skip to content

Commit

Permalink
Merge pull request #2068 from Lukapetro/feat/coingecko-api-integration
Browse files Browse the repository at this point in the history
feat: pro api support, trending coins api
  • Loading branch information
wtfsayo authored Jan 10, 2025
2 parents e606729 + ea675fa commit b9dc459
Show file tree
Hide file tree
Showing 20 changed files with 1,542 additions and 132 deletions.
7 changes: 6 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,12 @@ TOGETHER_API_KEY= # Together API Key
#### Crypto Plugin Configurations ####
######################################

# COIN DATA SOURCES
# CoinMarketCap / CMC
COINMARKETCAP_API_KEY=

# CoinGecko
COINGECKO_API_KEY=
COINGECKO_PRO_API_KEY=

# EVM
EVM_PRIVATE_KEY=
Expand Down Expand Up @@ -438,6 +441,8 @@ GIPHY_API_KEY=
# OpenWeather
OPEN_WEATHER_API_KEY= # OpenWeather API key



# EchoChambers Configuration
ECHOCHAMBERS_API_URL=http://127.0.0.1:3333
ECHOCHAMBERS_API_KEY=testingkey0011
Expand Down
3 changes: 2 additions & 1 deletion agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@elizaos/plugin-0g": "workspace:*",
"@elizaos/plugin-abstract": "workspace:*",
"@elizaos/plugin-aptos": "workspace:*",
"@elizaos/plugin-coingecko": "workspace:*",
"@elizaos/plugin-coinmarketcap": "workspace:*",
"@elizaos/plugin-coingecko": "workspace:*",
"@elizaos/plugin-binance": "workspace:*",
Expand Down Expand Up @@ -94,4 +95,4 @@
"ts-node": "10.9.2",
"tsup": "8.3.5"
}
}
}
8 changes: 6 additions & 2 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,18 @@ import { nearPlugin } from "@elizaos/plugin-near";
import { nftGenerationPlugin } from "@elizaos/plugin-nft-generation";
import { createNodePlugin } from "@elizaos/plugin-node";
import { obsidianPlugin } from "@elizaos/plugin-obsidian";
import { sgxPlugin } from "@elizaos/plugin-sgx";
import { solanaPlugin } from "@elizaos/plugin-solana";
import { solanaAgentkitPlguin } from "@elizaos/plugin-solana-agentkit";
import { storyPlugin } from "@elizaos/plugin-story";
import { suiPlugin } from "@elizaos/plugin-sui";
import { sgxPlugin } from "@elizaos/plugin-sgx";
import { TEEMode, teePlugin } from "@elizaos/plugin-tee";
import { teeLogPlugin } from "@elizaos/plugin-tee-log";
import { teeMarlinPlugin } from "@elizaos/plugin-tee-marlin";
import { tonPlugin } from "@elizaos/plugin-ton";
import { webSearchPlugin } from "@elizaos/plugin-web-search";

import { coingeckoPlugin } from "@elizaos/plugin-coingecko";
import { giphyPlugin } from "@elizaos/plugin-giphy";
import { letzAIPlugin } from "@elizaos/plugin-letzai";
import { thirdwebPlugin } from "@elizaos/plugin-thirdweb";
Expand Down Expand Up @@ -678,7 +679,10 @@ export async function createAgent(
? webhookPlugin
: null,
goatPlugin,
getSecret(character, "COINGECKO_API_KEY") ? coingeckoPlugin : null,
getSecret(character, "COINGECKO_API_KEY") ||
getSecret(character, "COINGECKO_PRO_API_KEY")
? coingeckoPlugin
: null,
getSecret(character, "EVM_PROVIDER_URL") ? goatPlugin : null,
getSecret(character, "ABSTRACT_PRIVATE_KEY")
? abstractPlugin
Expand Down
71 changes: 60 additions & 11 deletions packages/plugin-coingecko/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ A plugin for fetching cryptocurrency price data from the CoinGecko API.

## Overview

The Plugin CoinGecko provides a simple interface to get real-time cryptocurrency prices. It integrates with CoinGecko's API to fetch current prices for various cryptocurrencies in different fiat currencies.
The Plugin CoinGecko provides a simple interface to get real-time cryptocurrency data. It integrates with CoinGecko's API to fetch current prices, market data, trending coins, and top gainers/losers for various cryptocurrencies in different fiat currencies.

This plugin uses the [CoinGecko Pro API](https://docs.coingecko.com/reference/introduction). Please refer to their documentation for detailed information about rate limits, available endpoints, and response formats.

## Installation

Expand All @@ -18,7 +20,8 @@ Set up your environment with the required CoinGecko API key:

| Variable Name | Description |
| ------------------- | ---------------------- |
| `COINGECKO_API_KEY` | Your CoinGecko API key |
| `COINGECKO_API_KEY` | Your CoinGecko Pro API key |
| `COINGECKO_PRO_API_KEY` | Your CoinGecko Pro API key |

## Usage

Expand All @@ -27,23 +30,69 @@ import { coingeckoPlugin } from "@elizaos/plugin-coingecko";

// Initialize the plugin
const plugin = coingeckoPlugin;

// The plugin provides the GET_PRICE action which can be used to fetch prices
// Supported coins: BTC, ETH, USDC, and more
```

## Actions

### GET_PRICE

Fetches the current price of a cryptocurrency.
Fetches the current price and market data for one or more cryptocurrencies.

Examples:
Features:
- Multiple currency support (e.g., USD, EUR, JPY)
- Optional market cap data
- Optional 24h volume data
- Optional 24h price change data
- Optional last update timestamp

Examples:
- "What's the current price of Bitcoin?"
- "Check ETH price in EUR"
- "What's USDC worth?"
- "Check ETH price in EUR with market cap"
- "Show me BTC and ETH prices in USD and EUR"
- "What's USDC worth with 24h volume and price change?"

### GET_TRENDING

Fetches the current trending cryptocurrencies on CoinGecko.

## License
Features:
- Includes trending coins with market data
- Optional NFT inclusion
- Optional category inclusion

MIT
Examples:
- "What's trending in crypto?"
- "Show me trending coins only"
- "What are the hot cryptocurrencies right now?"

### GET_TOP_GAINERS_LOSERS

Fetches the top gaining and losing cryptocurrencies by price change.

Features:
- Customizable time range (1h, 24h, 7d, 14d, 30d, 60d, 1y)
- Configurable number of top coins to include
- Multiple currency support
- Market cap ranking included

Examples:
- "Show me the biggest gainers and losers today"
- "What are the top movers in EUR for the past week?"
- "Show me monthly performance of top 100 coins"

## Response Format

All actions return structured data including:
- Formatted text for easy reading
- Raw data for programmatic use
- Request parameters used
- Error details when applicable

## Error Handling

The plugin handles various error scenarios:
- Rate limiting
- API key validation
- Invalid parameters
- Network issues
- Pro plan requirements
Loading

0 comments on commit b9dc459

Please sign in to comment.