Struct coingecko_rs::CoinGeckoClient[][src]

pub struct CoinGeckoClient { /* fields omitted */ }
Expand description

CoinGecko client

Implementations

Creates a new CoinGeckoClient client with a custom host url

Examples
use coingecko_rs::CoinGeckoClient;
let client = CoinGeckoClient::new("https://some.url");

Check API server status

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();

    client.ping().await;
}

Get the current price of any cryptocurrencies in any other supported currencies that you need

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();

    client.price(vec!["bitcoin", "ethereum"], vec!["usd"], true, true, true, true).await;
}

Get current price of tokens (using contract addresses) for a given platform in any other currency that you need

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();
    let uniswap_contract = "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984";

    client.token_price(
        "ethereum",
        vec![&uniswap_contract],
        vec!["usd"],
        true,
        true,
        true,
        true,
    ).await;
}

Get list of supported_vs_currencies

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();

    client.supported_vs_currencies().await;
}

List all supported coins id, name and symbol (no pagination required)

Use this to obtain all the coins’ id in order to make API calls

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();

    client.coins_list(true).await;
}

List all supported coins price, market cap, volume, and market related data

Use this to obtain all the coins market data (price, market cap, volume)

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::{
        params::{MarketsOrder, PriceChangePercentage},
        CoinGeckoClient,
    };
    let client = CoinGeckoClient::default();
     
    client.coins_markets(
        "usd",
        vec!["bitcoin"],
        None,
        MarketsOrder::GeckoDesc,
        1,
        0,
        true,
        vec![
            PriceChangePercentage::OneHour,
            PriceChangePercentage::TwentyFourHours,
            PriceChangePercentage::SevenDays,
            PriceChangePercentage::FourteenDays,
            PriceChangePercentage::ThirtyDays,
            PriceChangePercentage::OneYear,
        ],
    ).await;
}

Get current data (name, price, market, … including exchange tickers) for a coin

IMPORTANT: Ticker object is limited to 100 items, to get more tickers, use coin_tickers Ticker is_stale is true when ticker that has not been updated/unchanged from the exchange for a while. Ticker is_anomaly is true if ticker’s price is outliered by our system. You are responsible for managing how you want to display these information (e.g. footnote, different background, change opacity, hide)

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();
     
    client.coin("bitcoin", true, true, true, true, true, true).await;
}

Get coin tickers (paginated to 100 items)

IMPORTANT: Ticker is_stale is true when ticker that has not been updated/unchanged from the exchange for a while. Ticker is_anomaly is true if ticker’s price is outliered by our system. You are responsible for managing how you want to display these information (e.g. footnote, different background, change opacity, hide)

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::{params::TickersOrder, CoinGeckoClient};
    let client = CoinGeckoClient::default();

    client.coin_tickers("bitcoin", None, true, 1, TickersOrder::VolumeDesc, true).await;
}

Get historical data (name, price, market, stats) at a given date for a coin

Examples
#[tokio::main]
async fn main() {
    use chrono::NaiveDate;
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();

    client.coin_history("bitcoin", NaiveDate::from_ymd(2017, 12, 30), true).await;
}

Get historical market data include price, market cap, and 24h volume (granularity auto)

Minutely data will be used for duration within 1 day, Hourly data will be used for duration between 1 day and 90 days, Daily data will be used for duration above 90 days.

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();

    client.coin_market_chart("bitcoin", "usd", 1, true).await;
}

Get historical market data include price, market cap, and 24h volume within a range of timestamp (granularity auto)

  • Data granularity is automatic (cannot be adjusted)
  • 1 day from query time = 5 minute interval data
  • 1 - 90 days from query time = hourly data
  • above 90 days from query time = daily data (00:00 UTC)
Examples
#[tokio::main]
async fn main() {
    use chrono::NaiveDate;
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();

    let from = NaiveDate::from_ymd(2014, 2, 16).and_hms(19, 0, 32);
    let to = NaiveDate::from_ymd(2015, 1, 30).and_hms(0, 20, 32);

    client.coin_market_chart_range("bitcoin", "usd", from, to).await;
}

Get status updates for a given coin

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();
    client.coin_status_updates("qtum", 10, 1).await;
}

Get coin’s OHLC

Candle’s body: 1 - 2 days: 30 minutes 3 - 30 days: 4 hours 31 and before: 4 days

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::{params::OhlcDays, CoinGeckoClient};
    let client = CoinGeckoClient::default();
    client.coin_ohlc("bitcoin", "usd", OhlcDays::OneDay).await;
}

Get coin info from contract address

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();
    let uniswap_contract = "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984";

    client.contract("ethereum", &uniswap_contract).await;
}

Get historical market data include price, market cap, and 24h volume (granularity auto)

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();
    let uniswap_contract = "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984";

    client.contract_market_chart("ethereum", &uniswap_contract, "usd", 1).await;
}

Get historical market data include price, market cap, and 24h volume within a range of timestamp (granularity auto)

Examples
#[tokio::main]
async fn main() {
    use chrono::NaiveDate;
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();
    let uniswap_contract = "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984";

    let from = NaiveDate::from_ymd(2014, 2, 16).and_hms(19, 0, 32);
    let to = NaiveDate::from_ymd(2015, 1, 30).and_hms(0, 20, 32);

    client.contract_market_chart_range("ethereum", &uniswap_contract, "usd", from, to).await;
}

List all asset platforms (Blockchain networks)

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();

    client.asset_platforms().await;
}

List all categories

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();

    client.categories_list().await;
}

List all categories with market data

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();

    client.categories().await;
}

List all exchanges

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();

    client.exchanges(10, 1).await;
}

List all supported markets id and name (no pagination required)

Use this to obtain all the markets’ id in order to make API calls

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();

    client.exchanges_list().await;
}

Get exchange volume in BTC and top 100 tickers only

IMPORTANT: Ticker object is limited to 100 items, to get more tickers, use exchange_tickers Ticker is_stale is true when ticker that has not been updated/unchanged from the exchange for a while. Ticker is_anomaly is true if ticker’s price is outliered by our system. You are responsible for managing how you want to display these information (e.g. footnote, different background, change opacity, hide)

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();

    client.exchange("binance").await;
}

Get exchange tickers (paginated)

IMPORTANT: Ticker is_stale is true when ticker that has not been updated/unchanged from the exchange for a while. Ticker is_anomaly is true if ticker’s price is outliered by our system. You are responsible for managing how you want to display these information (e.g. footnote, different background, change opacity, hide)

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::{params::TickersOrder, CoinGeckoClient};
    let client = CoinGeckoClient::default();

    client.exchange_tickers("binance", Some(vec!["btc"]), true, 1, TickersOrder::TrustScoreAsc, true).await;
}

Get status updates for a given exchange

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();

    client.exchange_status_updates("binance", 10, 1).await;
}

Get volume_chart data for a given exchange

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();

    client.exchange_volume_chart("binance", 1).await;
}

List all finance platforms

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();

    client.finance_platforms(10, 1).await;
}

List all finance products

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();

    client.finance_products(10, 1).await;
}

List all market indexes

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();

    client.indexes(10, 1).await;
}

Get market index by market id and index id

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();

    client.indexes_market_id("binance_futures", "BTC").await;
}

List market indexes id and name

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();

    client.indexes_list().await;
}

List all derivative tickers

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::{params::DerivativesIncludeTickers, CoinGeckoClient};
    let client = CoinGeckoClient::default();

    client.derivatives(Some(DerivativesIncludeTickers::All)).await;
}

List all derivative exchanges

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::{params::DerivativeExchangeOrder, CoinGeckoClient};
    let client = CoinGeckoClient::default();

    client.derivative_exchanges(DerivativeExchangeOrder::NameAsc, 10, 1).await;
}

Show derivative exchange data

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::{params::DerivativesIncludeTickers, CoinGeckoClient};
    let client = CoinGeckoClient::default();

    client.derivatives_exchange("bitmex", Some(DerivativesIncludeTickers::All)).await;
}

List all derivative exchanges name and identifier

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();

    client.derivative_exchanges_list().await;
}

List all status_updates with data (description, category, created_at, user, user_title and pin)

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();

    client.status_updates(Some("general"), Some("coin"), 10, 1).await;
}

Get events, paginated by 100

Examples
#[tokio::main]
async fn main() {
    use chrono::NaiveDate;
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();

    let from = NaiveDate::from_ymd(2021, 10, 7);
    let to = NaiveDate::from_ymd(2022, 10, 7);

    client.events(Some("HK"), Some("Event"), 1, true, from, to).await;
}

Get list of event countries

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();

    client.event_countries().await;
}

Get list of event types

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();

    client.event_types().await;
}

Get BTC-to-Currency exchange rates

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();

    client.exchange_rates().await;
}

Top-7 trending coins on CoinGecko as searched by users in the last 24 hours (Ordered by most popular first)

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();

    client.trending().await;
}

Get cryptocurrency global data

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();

    client.global().await;
}

Get Top 100 Cryptocurrency Global Eecentralized Finance(defi) data

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::CoinGeckoClient;
    let client = CoinGeckoClient::default();

    client.global_defi().await;
}

Get public companies bitcoin or ethereum holdings (Ordered by total holdings descending)

Examples
#[tokio::main]
async fn main() {
    use coingecko_rs::{params::CompaniesCoinId, CoinGeckoClient};
    let client = CoinGeckoClient::default();

    client.companies(CompaniesCoinId::Bitcoin).await;
}

Trait Implementations

Creates a new CoinGeckoClient with host https://api.coingecko.com/api/v3

Examples

use coingecko_rs::CoinGeckoClient;
let client = CoinGeckoClient::default();

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more