1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! CoinGecko cryptocurrency data.
//!
//! Requires the **`crypto`** feature flag.
//!
//! Uses the CoinGecko public API (no key required, 30 req/min free tier).
//! Rate limiting is handled automatically via a process-global client.
//!
//! # Quick Start
//!
//! ```no_run
//! use finance_query::crypto;
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! // Top 10 coins by market cap in USD
//! let top = crypto::coins("usd", 10).await?;
//! for coin in &top {
//! println!("{}: ${:.2}", coin.symbol, coin.current_price.unwrap_or(0.0));
//! }
//!
//! // Single coin by CoinGecko ID
//! let btc = crypto::coin("bitcoin", "usd").await?;
//! println!("BTC: ${:.2}", btc.current_price.unwrap_or(0.0));
//! # Ok(())
//! # }
//! ```
use CoinGeckoClient;
use OnceLock;
use crateResult;
pub use CoinQuote;
/// Process-global CoinGecko client (initialized lazily on first use).
static COINGECKO_CLIENT: = new;
/// Fetch the top `count` cryptocurrencies by market cap.
///
/// # Arguments
///
/// * `vs_currency` - Quote currency (e.g., `"usd"`, `"eur"`, `"btc"`)
/// * `count` - Number of coins to return (max 250)
///
/// # Errors
///
/// Returns an error on network failure or if the CoinGecko API rate limit is exceeded.
pub async
/// Fetch a single coin by its CoinGecko ID (e.g., `"bitcoin"`, `"ethereum"`).
///
/// Use <https://api.coingecko.com/api/v3/coins/list> to discover CoinGecko IDs.
///
/// # Arguments
///
/// * `id` - CoinGecko coin ID
/// * `vs_currency` - Quote currency (e.g., `"usd"`)
pub async