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;
}
pub async fn coins_markets(
&self,
vs_currency: &str,
ids: Vec<&str>,
category: Option<&str>,
order: MarketsOrder,
per_page: i64,
page: i64,
sparkline: bool,
price_change_percentage: Vec<PriceChangePercentage>
) -> Result<Vec<CoinsMarketItem>, Error>
pub async fn coins_markets(
&self,
vs_currency: &str,
ids: Vec<&str>,
category: Option<&str>,
order: MarketsOrder,
per_page: i64,
page: i64,
sparkline: bool,
price_change_percentage: Vec<PriceChangePercentage>
) -> Result<Vec<CoinsMarketItem>, Error>
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;
}
pub async fn coin_market_chart(
&self,
id: &str,
vs_currency: &str,
days: i64,
use_daily_interval: bool
) -> Result<MarketChart, Error>
pub async fn coin_market_chart(
&self,
id: &str,
vs_currency: &str,
days: i64,
use_daily_interval: bool
) -> Result<MarketChart, Error>
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;
}
pub async fn coin_market_chart_range(
&self,
id: &str,
vs_currency: &str,
from: NaiveDateTime,
to: NaiveDateTime
) -> Result<MarketChart, Error>
pub async fn coin_market_chart_range(
&self,
id: &str,
vs_currency: &str,
from: NaiveDateTime,
to: NaiveDateTime
) -> Result<MarketChart, Error>
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;
}
pub async fn coin_status_updates(
&self,
id: &str,
per_page: i64,
page: i64
) -> Result<StatusUpdates, Error>
pub async fn coin_status_updates(
&self,
id: &str,
per_page: i64,
page: i64
) -> Result<StatusUpdates, Error>
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;
}
pub async fn contract_market_chart(
&self,
id: &str,
contract_address: &str,
vs_currency: &str,
days: i64
) -> Result<MarketChart, Error>
pub async fn contract_market_chart(
&self,
id: &str,
contract_address: &str,
vs_currency: &str,
days: i64
) -> Result<MarketChart, Error>
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;
}
pub async fn contract_market_chart_range(
&self,
id: &str,
contract_address: &str,
vs_currency: &str,
from: NaiveDateTime,
to: NaiveDateTime
) -> Result<MarketChart, Error>
pub async fn contract_market_chart_range(
&self,
id: &str,
contract_address: &str,
vs_currency: &str,
from: NaiveDateTime,
to: NaiveDateTime
) -> Result<MarketChart, Error>
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;
}
pub async fn exchange_status_updates(
&self,
id: &str,
per_page: i64,
page: i64
) -> Result<StatusUpdates, Error>
pub async fn exchange_status_updates(
&self,
id: &str,
per_page: i64,
page: i64
) -> Result<StatusUpdates, Error>
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;
}
pub async fn exchange_volume_chart(
&self,
id: &str,
days: i64
) -> Result<Vec<VolumeChartData>, Error>
pub async fn exchange_volume_chart(
&self,
id: &str,
days: i64
) -> Result<Vec<VolumeChartData>, Error>
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;
}
pub async fn finance_platforms(
&self,
per_page: i64,
page: i64
) -> Result<Vec<FinancePlatform>, Error>
pub async fn finance_platforms(
&self,
per_page: i64,
page: i64
) -> Result<Vec<FinancePlatform>, Error>
List all finance platforms
Examples
#[tokio::main]
async fn main() {
use coingecko_rs::CoinGeckoClient;
let client = CoinGeckoClient::default();
client.finance_platforms(10, 1).await;
}
pub async fn finance_products(
&self,
per_page: i64,
page: i64
) -> Result<Vec<FinanceProduct>, Error>
pub async fn finance_products(
&self,
per_page: i64,
page: i64
) -> Result<Vec<FinanceProduct>, Error>
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;
}
pub async fn indexes_market_id(
&self,
market_id: &str,
id: &str
) -> Result<MarketIndex, Error>
pub async fn indexes_market_id(
&self,
market_id: &str,
id: &str
) -> Result<MarketIndex, Error>
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;
}
pub async fn derivatives(
&self,
include_tickers: Option<DerivativesIncludeTickers>
) -> Result<Vec<Derivative>, Error>
pub async fn derivatives(
&self,
include_tickers: Option<DerivativesIncludeTickers>
) -> Result<Vec<Derivative>, Error>
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;
}
pub async fn derivative_exchanges(
&self,
order: DerivativeExchangeOrder,
per_page: i64,
page: i64
) -> Result<Vec<Derivative>, Error>
pub async fn derivative_exchanges(
&self,
order: DerivativeExchangeOrder,
per_page: i64,
page: i64
) -> Result<Vec<Derivative>, Error>
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;
}
pub async fn derivatives_exchange(
&self,
id: &str,
include_tickers: Option<DerivativesIncludeTickers>
) -> Result<Vec<Derivative>, Error>
pub async fn derivatives_exchange(
&self,
id: &str,
include_tickers: Option<DerivativesIncludeTickers>
) -> Result<Vec<Derivative>, Error>
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;
}
pub async fn companies(
&self,
coin_id: CompaniesCoinId
) -> Result<CompaniesPublicTreasury, Error>
pub async fn companies(
&self,
coin_id: CompaniesCoinId
) -> Result<CompaniesPublicTreasury, Error>
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
Auto Trait Implementations
impl RefUnwindSafe for CoinGeckoClient
impl Send for CoinGeckoClient
impl Sync for CoinGeckoClient
impl Unpin for CoinGeckoClient
impl UnwindSafe for CoinGeckoClient
Blanket Implementations
Mutably borrows from an owned value. Read more
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