Skip to main content

Crate cgko

Crate cgko 

Source
Expand description

§gecko

Unofficial Rust client for the CoinGecko API.

§Quick Start

let client = cgko::Client::new()?;

// Get Bitcoin price
let prices = client.simple().price(&["bitcoin"], &["usd"]).await?;
println!("{:?}", prices);

// Get trending coins
let trending = client.global().trending().await?;
for item in trending.coins.iter().take(5) {
    println!("{}: #{}", item.item.name, item.item.market_cap_rank.unwrap_or(0));
}

§Pro API

let client = cgko::Client::pro("your-api-key")?;
let markets = client.coins().markets("usd").await?;

§GeckoTerminal (Onchain)

let client = cgko::Client::new()?;
let pools = client.onchain().trending_pools().await?;

Re-exports§

pub use client::Client;
pub use client::Config;
pub use error::Error;
pub use error::Result;

Modules§

base_urls
Base URLs for the CoinGecko API
categories
Categories endpoints
client
HTTP client for the CoinGecko API
coins
Coins data endpoints
derivatives
Derivatives endpoints
error
Error types for the CoinGecko API client
exchanges
Exchanges data endpoints
global
Global and general data endpoints
nfts
NFT endpoints
onchain
Onchain/GeckoTerminal endpoints
simple
Simple price endpoints
treasury
Treasury endpoints (public companies and governments holding crypto)

Structs§

HttpClientConfig
HTTP client configuration
RetryConfig
Configuration for retry behavior
RetryError
Error wrapper that includes retry information

Traits§

RetryableError
Determines if an error should be retried

Functions§

default_config
Create a default CoinGecko config (demo mode)
demo_config_with_key
Create a demo config with API key
pro_config
Create a Pro config with API key
with_retry
Execute an async operation with retries
with_simple_retry
Simple retry wrapper for operations that return Result with any error type