├── .github └── workflows │ └── general.yml ├── .gitignore ├── CHANGELOG.md ├── Cargo.toml ├── LICENSE ├── README.md ├── logo.png └── src ├── client.rs ├── lib.rs ├── params.rs └── response ├── asset_platforms.rs ├── coins.rs ├── common.rs ├── companies.rs ├── derivatives.rs ├── events.rs ├── exchange_rates.rs ├── exchanges.rs ├── finance.rs ├── global.rs ├── indexes.rs ├── mod.rs ├── ping.rs ├── simple.rs └── trending.rs /.github/workflows/general.yml: -------------------------------------------------------------------------------- 1 | name: Rust CI 2 | 3 | on: [push, pull_request] 4 | 5 | env: 6 | CARGO_TERM_COLOR: always 7 | RUST_BACKTRACE: 1 8 | 9 | jobs: 10 | test: 11 | name: Test 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v2 15 | - uses: actions-rs/toolchain@v1 16 | with: 17 | profile: minimal 18 | toolchain: stable 19 | override: true 20 | - uses: actions-rs/cargo@v1 21 | env: 22 | COINGECKO_DEMO_API_KEY: ${{ secrets.COINGECKO_DEMO_API_KEY }} 23 | with: 24 | command: test 25 | 26 | fmt: 27 | name: Rustfmt 28 | runs-on: ubuntu-latest 29 | steps: 30 | - uses: actions/checkout@v2 31 | - uses: actions-rs/toolchain@v1 32 | with: 33 | toolchain: stable 34 | override: true 35 | components: rustfmt 36 | - uses: actions-rs/cargo@v1 37 | with: 38 | command: fmt 39 | args: --all -- --check 40 | 41 | clippy: 42 | name: Clippy 43 | runs-on: ubuntu-latest 44 | steps: 45 | - uses: actions/checkout@v2 46 | - uses: actions-rs/toolchain@v1 47 | with: 48 | toolchain: stable 49 | override: true 50 | components: clippy 51 | - uses: actions-rs/clippy-check@v1 52 | with: 53 | token: ${{ secrets.GITHUB_TOKEN }} 54 | args: -- -D warnings 55 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | Cargo.lock 3 | .DS_Store -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 6 | 7 | # Change Log 8 | 9 | All notable changes to this project will be documented in this file. 10 | 11 | ## [1.1.3] - 2025-02-09 12 | 13 | Add `rustls-tls` feature 14 | 15 | ## [1.1.2] - 2025-02-08 16 | 17 | Fixes broken response types for contract item 18 | 19 | ## [1.1.1] - 2025-02-08 20 | 21 | Fixes some broken payloads, and tweaks CI for tests with demo API key 22 | 23 | ## [1.1.0] - 2025-02-08 24 | 25 | Create client with API keys, fixes broken endpoints 26 | 27 | ## [1.0.1] - 2022-09-02 28 | 29 | Misc fixes 30 | 31 | ## [1.0.0] - 2022-03-24 32 | 33 | Initial release 34 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "coingecko" 3 | version = "1.1.3" 4 | authors = ["ecklf "] 5 | description = "Rust library for the CoinGecko V3 API" 6 | documentation = "https://docs.rs/coingecko" 7 | repository = "https://github.com/ecklf/coingecko-rs" 8 | keywords = ["coingecko", "api", "cryptocurrency"] 9 | edition = "2021" 10 | readme = "README.md" 11 | license = "MIT" 12 | include = ["src/**/*", "LICENSE.md", "README.md", "CHANGELOG.md"] 13 | 14 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 15 | 16 | [dependencies] 17 | tokio = { version = "1.36.0", features = ["full"] } 18 | reqwest = { version = "0.12.12", features = ["charset", "http2", "macos-system-configuration", "json"], default-features = false } 19 | serde = { version = "1.0.197", features = ["derive"] } 20 | serde_json = "1.0.114" 21 | chrono = "0.4.39" 22 | 23 | [features] 24 | default = ["reqwest/default-tls"] 25 | rustls-tls = ["reqwest/rustls-tls"] 26 | 27 | [dev-dependencies] 28 | tokio-test = "0.4.3" 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Florentin Eckl 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # coingecko 2 | 3 | Rust library for the CoinGecko V3 API (formerly known as `coingecko-rs` crate) 4 | 5 |

6 | 7 |

8 | 9 | ## Installation 10 | 11 | Add the following to your `Cargo.toml` file: 12 | 13 | ```toml 14 | [dependencies] 15 | coingecko = "1.1.3" 16 | # If you want to use rustls-tls 17 | # coingecko = { version = "1.1.3", features = ["rustls-tls"] } 18 | ``` 19 | 20 | ## Features 21 | 22 | - Supports all API endpoints 23 | - Responses are fully typed using `serde_json` 24 | - Date params using `chrono` 25 | - Market order enum params 26 | 27 | ## Documentation 28 | 29 | [docs.rs](https://docs.rs/coingecko) 30 | -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ecklf/coingecko-rs/63fd9d115c20d6101f45988ff6416de7c4a9b24b/logo.png -------------------------------------------------------------------------------- /src/client.rs: -------------------------------------------------------------------------------- 1 | #![allow(clippy::too_many_arguments)] 2 | use std::collections::HashMap; 3 | 4 | use chrono::{NaiveDate, NaiveDateTime}; 5 | use reqwest::Error; 6 | use serde::de::DeserializeOwned; 7 | 8 | use crate::params::{ 9 | CompaniesCoinId, DerivativeExchangeOrder, DerivativesIncludeTickers, MarketsOrder, OhlcDays, 10 | PriceChangePercentage, TickersOrder, 11 | }; 12 | 13 | use crate::response::coins::TopGainersLosers; 14 | use crate::response::{ 15 | asset_platforms::AssetPlatform, 16 | coins::{ 17 | Category, CategoryId, CoinsItem, CoinsListItem, CoinsMarketItem, Contract, History, 18 | MarketChart, 19 | }, 20 | common::{StatusUpdates, Tickers}, 21 | companies::CompaniesPublicTreasury, 22 | derivatives::{Derivative, DerivativeExchangeId}, 23 | events::Events, 24 | events::{EventCountries, EventTypes}, 25 | exchange_rates::ExchangeRates, 26 | exchanges::VolumeChartData, 27 | exchanges::{Exchange, ExchangeId}, 28 | finance::{FinancePlatform, FinanceProduct}, 29 | global::{Global, GlobalDefi}, 30 | indexes::Index, 31 | indexes::{IndexId, MarketIndex}, 32 | ping::SimplePing, 33 | simple::{Price, SupportedVsCurrencies}, 34 | trending::Trending, 35 | }; 36 | 37 | /// CoinGecko API URL 38 | pub const COINGECKO_API_DEMO_URL: &str = "https://api.coingecko.com/api/v3"; 39 | pub const COINGECKO_API_PRO_URL: &str = "https://pro-api.coingecko.com/api/v3"; 40 | 41 | /// CoinGecko client 42 | pub struct CoinGeckoClient { 43 | host: &'static str, 44 | client: reqwest::Client, 45 | api_key: Option, 46 | } 47 | 48 | /// Creates a new CoinGeckoClient with host https://api.coingecko.com/api/v3 49 | /// 50 | /// # Examples 51 | /// 52 | /// ```rust 53 | /// use coingecko::CoinGeckoClient; 54 | /// let client = CoinGeckoClient::default(); 55 | /// ``` 56 | impl Default for CoinGeckoClient { 57 | fn default() -> Self { 58 | std::env::var("COINGECKO_PRO_API_KEY") 59 | .map(|k| CoinGeckoClient::new_with_pro_api_key(&k)) 60 | .or_else(|_| { 61 | std::env::var("COINGECKO_DEMO_API_KEY") 62 | .map(|k| CoinGeckoClient::new_with_demo_api_key(&k)) 63 | }) 64 | .unwrap_or_else(|_| CoinGeckoClient::new(COINGECKO_API_DEMO_URL)) 65 | } 66 | } 67 | 68 | impl CoinGeckoClient { 69 | /// Creates a new CoinGeckoClient client with a custom host url 70 | /// 71 | /// # Examples 72 | /// 73 | /// ```rust 74 | /// use coingecko::CoinGeckoClient; 75 | /// let client = CoinGeckoClient::new("https://some.url"); 76 | /// ``` 77 | pub fn new(host: &'static str) -> Self { 78 | CoinGeckoClient { 79 | host, 80 | client: reqwest::Client::new(), 81 | api_key: None, 82 | } 83 | } 84 | 85 | /// Creates a new CoinGeckoClient client with demo api key 86 | /// 87 | /// # Examples 88 | /// 89 | /// ```rust 90 | /// use coingecko::CoinGeckoClient; 91 | /// let client = CoinGeckoClient::new_with_demo_api_key("x_cg_demo_api_key=some_api_key"); 92 | /// ``` 93 | pub fn new_with_demo_api_key(api_key: &str) -> Self { 94 | CoinGeckoClient { 95 | host: COINGECKO_API_DEMO_URL, 96 | client: reqwest::Client::new(), 97 | api_key: Some(format!("x_cg_demo_api_key={}", api_key)), 98 | } 99 | } 100 | 101 | /// Creates a new CoinGeckoClient client with pro api key 102 | /// 103 | /// # Examples 104 | /// 105 | /// ```rust 106 | /// use coingecko::CoinGeckoClient; 107 | /// let client = CoinGeckoClient::new_with_pro_api_key("x_cg_demo_api_key=some_api_key"); 108 | /// ``` 109 | pub fn new_with_pro_api_key(api_key: &str) -> Self { 110 | CoinGeckoClient { 111 | host: COINGECKO_API_PRO_URL, 112 | client: reqwest::Client::new(), 113 | api_key: Some(format!("x_cg_pro_api_key={}", api_key)), 114 | } 115 | } 116 | 117 | /// Creates a new CoinGeckoClient client with a custom host url and api key 118 | /// 119 | /// # Examples 120 | /// 121 | /// ```rust 122 | /// use coingecko::CoinGeckoClient; 123 | /// let client = CoinGeckoClient::new_with_api_key("https://some.url", "x_cg_demo_api_key=some_api_key"); 124 | /// ``` 125 | pub fn new_with_api_key(host: &'static str, api_key: &str) -> Self { 126 | CoinGeckoClient { 127 | host, 128 | client: reqwest::Client::new(), 129 | api_key: Some(api_key.to_owned()), 130 | } 131 | } 132 | 133 | /// Send a GET request to the given endpoint 134 | pub async fn get(&self, endpoint: &str) -> Result { 135 | let host = self.host; 136 | let slash = if endpoint.starts_with('/') { "" } else { "/" }; 137 | 138 | let api_key = if let Some(api_key) = &self.api_key { 139 | let del = if endpoint.contains('?') { "&" } else { "?" }; 140 | format!("{del}{api_key}") 141 | } else { 142 | String::new() 143 | }; 144 | 145 | let url = format!("{host}{slash}{endpoint}{api_key}"); 146 | 147 | let res = self.client.get(&url).send().await?; 148 | 149 | if res.status().is_success() { 150 | res.json().await 151 | } else { 152 | Err(res.error_for_status().unwrap_err()) 153 | } 154 | } 155 | 156 | /// Check API server status 157 | /// 158 | /// # Examples 159 | /// 160 | /// ```rust 161 | /// #[tokio::main] 162 | /// async fn main() { 163 | /// use coingecko::CoinGeckoClient; 164 | /// let client = CoinGeckoClient::default(); 165 | /// 166 | /// client.ping().await; 167 | /// } 168 | /// ``` 169 | pub async fn ping(&self) -> Result { 170 | self.get("/ping").await 171 | } 172 | 173 | /// Get the current price of any cryptocurrencies in any other supported currencies that you need 174 | /// 175 | /// # Examples 176 | /// 177 | /// ```rust 178 | /// #[tokio::main] 179 | /// async fn main() { 180 | /// use coingecko::CoinGeckoClient; 181 | /// let client = CoinGeckoClient::default(); 182 | /// 183 | /// client.price(&["bitcoin", "ethereum"], &["usd"], true, true, true, true).await; 184 | /// } 185 | /// ``` 186 | pub async fn price, Curr: AsRef>( 187 | &self, 188 | ids: &[Id], 189 | vs_currencies: &[Curr], 190 | include_market_cap: bool, 191 | include_24hr_vol: bool, 192 | include_24hr_change: bool, 193 | include_last_updated_at: bool, 194 | ) -> Result, Error> { 195 | let ids = ids.iter().map(AsRef::as_ref).collect::>(); 196 | let vs_currencies = vs_currencies.iter().map(AsRef::as_ref).collect::>(); 197 | let req = format!("/simple/price?ids={}&vs_currencies={}&include_market_cap={}&include_24hr_vol={}&include_24hr_change={}&include_last_updated_at={}", ids.join("%2C"), vs_currencies.join("%2C"), include_market_cap, include_24hr_vol, include_24hr_change, include_last_updated_at); 198 | self.get(&req).await 199 | } 200 | 201 | /// Get current price of tokens (using contract addresses) for a given platform in any other currency that you need 202 | /// 203 | /// # Examples 204 | /// 205 | /// ```rust 206 | /// #[tokio::main] 207 | /// async fn main() { 208 | /// use coingecko::CoinGeckoClient; 209 | /// let client = CoinGeckoClient::default(); 210 | /// let uniswap_contract = "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984"; 211 | /// 212 | /// client.token_price( 213 | /// "ethereum", 214 | /// &[uniswap_contract], 215 | /// &["usd"], 216 | /// true, 217 | /// true, 218 | /// true, 219 | /// true, 220 | /// ).await; 221 | /// } 222 | /// ``` 223 | pub async fn token_price, Curr: AsRef>( 224 | &self, 225 | id: &str, 226 | contract_addresses: &[Addr], 227 | vs_currencies: &[Curr], 228 | include_market_cap: bool, 229 | include_24hr_vol: bool, 230 | include_24hr_change: bool, 231 | include_last_updated_at: bool, 232 | ) -> Result, Error> { 233 | let contract_addresses = contract_addresses 234 | .iter() 235 | .map(AsRef::as_ref) 236 | .collect::>(); 237 | let vs_currencies = vs_currencies.iter().map(AsRef::as_ref).collect::>(); 238 | let req = format!("/simple/token_price/{}?contract_addresses={}&vs_currencies={}&include_market_cap={}&include_24hr_vol={}&include_24hr_change={}&include_last_updated_at={}", id, contract_addresses.join("%2C"), vs_currencies.join("%2C"), include_market_cap, include_24hr_vol, include_24hr_change, include_last_updated_at); 239 | self.get(&req).await 240 | } 241 | 242 | /// Get list of supported_vs_currencies 243 | /// 244 | /// # Examples 245 | /// 246 | /// ```rust 247 | /// #[tokio::main] 248 | /// async fn main() { 249 | /// use coingecko::CoinGeckoClient; 250 | /// let client = CoinGeckoClient::default(); 251 | /// 252 | /// client.supported_vs_currencies().await; 253 | /// } 254 | /// ``` 255 | pub async fn supported_vs_currencies(&self) -> Result { 256 | self.get("/simple/supported_vs_currencies").await 257 | } 258 | 259 | /// List all supported coins id, name and symbol (no pagination required) 260 | /// 261 | /// Use this to obtain all the coins’ id in order to make API calls 262 | /// 263 | /// # Examples 264 | /// 265 | /// ```rust 266 | /// #[tokio::main] 267 | /// async fn main() { 268 | /// use coingecko::CoinGeckoClient; 269 | /// let client = CoinGeckoClient::default(); 270 | /// 271 | /// client.coins_list(true).await; 272 | /// } 273 | /// ``` 274 | pub async fn coins_list(&self, include_platform: bool) -> Result, Error> { 275 | let req = format!("/coins/list?include_platform={}", include_platform); 276 | self.get(&req).await 277 | } 278 | 279 | /// List all supported coins id, name and symbol (no pagination required) 280 | /// 281 | /// Use this to obtain all the coins’ id in order to make API calls 282 | /// 283 | /// # Examples 284 | /// 285 | /// ```rust 286 | /// #[tokio::main] 287 | /// async fn main() { 288 | /// use coingecko::CoinGeckoClient; 289 | /// let client = CoinGeckoClient::default(); 290 | /// 291 | /// client.coins_list(true).await; 292 | /// } 293 | /// ``` 294 | pub async fn top_gainers_losers( 295 | &self, 296 | vs_currency: &str, 297 | duration: &str, 298 | top_coins: u32, 299 | ) -> Result { 300 | let url = format!( 301 | "/coins/top_gainers_losers?vs_currency={}&duration={}&top_coins={}", 302 | vs_currency, duration, top_coins 303 | ); 304 | 305 | self.get(&url).await 306 | } 307 | 308 | /// List all supported coins price, market cap, volume, and market related data 309 | /// 310 | /// Use this to obtain all the coins market data (price, market cap, volume) 311 | /// 312 | /// # Examples 313 | /// 314 | /// ```rust 315 | /// #[tokio::main] 316 | /// async fn main() { 317 | /// use coingecko::{ 318 | /// params::{MarketsOrder, PriceChangePercentage}, 319 | /// CoinGeckoClient, 320 | /// }; 321 | /// let client = CoinGeckoClient::default(); 322 | /// 323 | /// client.coins_markets( 324 | /// "usd", 325 | /// &["bitcoin"], 326 | /// None, 327 | /// MarketsOrder::GeckoDesc, 328 | /// 1, 329 | /// 0, 330 | /// true, 331 | /// &[ 332 | /// PriceChangePercentage::OneHour, 333 | /// PriceChangePercentage::TwentyFourHours, 334 | /// PriceChangePercentage::SevenDays, 335 | /// PriceChangePercentage::FourteenDays, 336 | /// PriceChangePercentage::ThirtyDays, 337 | /// PriceChangePercentage::OneYear, 338 | /// ], 339 | /// ).await; 340 | /// } 341 | /// ``` 342 | pub async fn coins_markets>( 343 | &self, 344 | vs_currency: &str, 345 | ids: &[Id], 346 | category: Option<&str>, 347 | order: MarketsOrder, 348 | per_page: i64, 349 | page: i64, 350 | sparkline: bool, 351 | price_change_percentage: &[PriceChangePercentage], 352 | ) -> Result, Error> { 353 | let ids = ids.iter().map(AsRef::as_ref).collect::>(); 354 | 355 | let category = match category { 356 | Some(c) => format!("&category={}", c), 357 | _ => String::from(""), 358 | }; 359 | 360 | let order = match order { 361 | MarketsOrder::MarketCapDesc => "market_cap_desc", 362 | MarketsOrder::MarketCapAsc => "market_cap_asc", 363 | MarketsOrder::GeckoDesc => "gecko_desc", 364 | MarketsOrder::GeckoAsc => "gecko_asc", 365 | MarketsOrder::VolumeDesc => "volume_desc", 366 | MarketsOrder::VolumeAsc => "volume_asc", 367 | MarketsOrder::IdDesc => "id_desc", 368 | MarketsOrder::IdAsc => "id_asc", 369 | }; 370 | 371 | let price_change_percentage = price_change_percentage.iter().fold( 372 | Vec::with_capacity(price_change_percentage.len()), 373 | |mut acc, x| { 374 | let current = match *x { 375 | PriceChangePercentage::OneHour => "1h", 376 | PriceChangePercentage::TwentyFourHours => "24h", 377 | PriceChangePercentage::SevenDays => "7d", 378 | PriceChangePercentage::FourteenDays => "14d", 379 | PriceChangePercentage::ThirtyDays => "30d", 380 | PriceChangePercentage::TwoHundredDays => "200d", 381 | PriceChangePercentage::OneYear => "1y", 382 | }; 383 | 384 | acc.push(current); 385 | acc 386 | }, 387 | ); 388 | 389 | let req = format!("/coins/markets?vs_currency={}&ids={}{}&order={}&per_page={}&page={}&sparkline={}&price_change_percentage={}", vs_currency, ids.join("%2C"), category, order, per_page, page, sparkline, price_change_percentage.join("%2C")); 390 | self.get(&req).await 391 | } 392 | 393 | /// Get current data (name, price, market, ... including exchange tickers) for a coin 394 | /// 395 | /// **IMPORTANT**: 396 | /// Ticker object is limited to 100 items, to get more tickers, use coin_tickers 397 | /// Ticker is_stale is true when ticker that has not been updated/unchanged from the exchange for a while. 398 | /// Ticker is_anomaly is true if ticker’s price is outliered by our system. 399 | /// You are responsible for managing how you want to display these information (e.g. footnote, different background, change opacity, hide) 400 | /// 401 | /// # Examples 402 | /// 403 | /// ```rust 404 | /// #[tokio::main] 405 | /// async fn main() { 406 | /// use coingecko::CoinGeckoClient; 407 | /// let client = CoinGeckoClient::default(); 408 | /// 409 | /// client.coin("bitcoin", true, true, true, true, true, true).await; 410 | /// } 411 | /// ``` 412 | pub async fn coin( 413 | &self, 414 | id: &str, 415 | localization: bool, 416 | tickers: bool, 417 | market_data: bool, 418 | community_data: bool, 419 | developer_data: bool, 420 | sparkline: bool, 421 | ) -> Result { 422 | let req = format!("/coins/{}?localization={}&tickers={}&market_data={}&community_data={}&developer_data={}&sparkline={}", id, localization, tickers, market_data, community_data, developer_data, sparkline); 423 | self.get(&req).await 424 | } 425 | 426 | /// Get coin tickers (paginated to 100 items) 427 | /// 428 | /// **IMPORTANT**: 429 | /// Ticker is_stale is true when ticker that has not been updated/unchanged from the exchange for a while. 430 | /// Ticker is_anomaly is true if ticker’s price is outliered by our system. 431 | /// You are responsible for managing how you want to display these information (e.g. footnote, different background, change opacity, hide) 432 | /// 433 | /// # Examples 434 | /// 435 | /// ```rust 436 | /// #[tokio::main] 437 | /// async fn main() { 438 | /// use coingecko::{params::TickersOrder, CoinGeckoClient}; 439 | /// let client = CoinGeckoClient::default(); 440 | /// 441 | /// client.coin_tickers::<&str>("bitcoin", None, true, 1, TickersOrder::VolumeDesc, true).await; 442 | /// } 443 | /// ``` 444 | pub async fn coin_tickers>( 445 | &self, 446 | id: &str, 447 | exchange_ids: Option<&[Ex]>, 448 | include_exchange_logo: bool, 449 | page: i64, 450 | order: TickersOrder, 451 | depth: bool, 452 | ) -> Result { 453 | let order = match order { 454 | TickersOrder::TrustScoreAsc => "trust_score_asc", 455 | TickersOrder::TrustScoreDesc => "trust_score_desc", 456 | TickersOrder::VolumeDesc => "volume_desc", 457 | }; 458 | 459 | let req = match exchange_ids { 460 | Some(e_ids) => { 461 | let e_ids = e_ids.iter().map(AsRef::as_ref).collect::>(); 462 | format!("/coins/{}/tickers?exchange_ids={}&include_exchange_logo={}&page={}&order={}&depth={}", id, e_ids.join("%2C"), include_exchange_logo, &page, order, depth) 463 | } 464 | None => format!( 465 | "/coins/{}/tickers?include_exchange_logo={}&page={}&order={}&depth={}", 466 | id, include_exchange_logo, &page, order, depth 467 | ), 468 | }; 469 | 470 | self.get(&req).await 471 | } 472 | 473 | /// Get historical data (name, price, market, stats) at a given date for a coin 474 | /// 475 | /// # Examples 476 | /// 477 | /// ```rust 478 | /// #[tokio::main] 479 | /// async fn main() { 480 | /// use chrono::{NaiveDate, Datelike}; 481 | /// use coingecko::CoinGeckoClient; 482 | /// let client = CoinGeckoClient::default(); 483 | /// 484 | /// let current_date = chrono::Utc::now(); 485 | /// let year = current_date.year(); 486 | /// client.coin_history("bitcoin", NaiveDate::from_ymd(year, 1, 1), true).await; 487 | /// } 488 | /// ``` 489 | pub async fn coin_history( 490 | &self, 491 | id: &str, 492 | date: NaiveDate, 493 | localization: bool, 494 | ) -> Result { 495 | let formatted_date = date.format("%d-%m-%Y").to_string(); 496 | 497 | let req = format!( 498 | "/coins/{}/history?date={}&localization={}", 499 | id, formatted_date, localization 500 | ); 501 | self.get(&req).await 502 | } 503 | 504 | /// Get historical market data include price, market cap, and 24h volume (granularity auto) 505 | /// 506 | /// **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.** 507 | /// 508 | /// # Examples 509 | /// 510 | /// ```rust 511 | /// #[tokio::main] 512 | /// async fn main() { 513 | /// use coingecko::CoinGeckoClient; 514 | /// let client = CoinGeckoClient::default(); 515 | /// 516 | /// client.coin_market_chart("bitcoin", "usd", 1, true).await; 517 | /// } 518 | /// ``` 519 | pub async fn coin_market_chart( 520 | &self, 521 | id: &str, 522 | vs_currency: &str, 523 | days: i64, 524 | use_daily_interval: bool, 525 | ) -> Result { 526 | let req = match use_daily_interval { 527 | true => format!( 528 | "/coins/{}/market_chart?vs_currency={}&days={}", 529 | id, vs_currency, days 530 | ), 531 | false => format!( 532 | "/coins/{}/market_chart?vs_currency={}&days={}&interval=daily", 533 | id, vs_currency, days 534 | ), 535 | }; 536 | 537 | self.get(&req).await 538 | } 539 | 540 | /// Get historical market data include price, market cap, and 24h volume within a range of timestamp (granularity auto) 541 | /// 542 | /// - **Data granularity is automatic (cannot be adjusted)** 543 | /// - **1 day from query time = 5 minute interval data** 544 | /// - **1 - 90 days from query time = hourly data** 545 | /// - **above 90 days from query time = daily data (00:00 UTC)** 546 | /// 547 | /// # Examples 548 | /// 549 | /// ```rust 550 | /// #[tokio::main] 551 | /// async fn main() { 552 | /// use chrono::{NaiveDate, Datelike}; 553 | /// use coingecko::CoinGeckoClient; 554 | /// let client = CoinGeckoClient::default(); 555 | /// 556 | /// let current_date = chrono::Utc::now(); 557 | /// let from = NaiveDate::from_ymd_opt(current_date.year(), current_date.month() - 1, current_date.day()).unwrap().and_hms_opt(0, 0, 0).unwrap(); 558 | /// let to = NaiveDate::from_ymd_opt(current_date.year(), current_date.month(), current_date.day()).unwrap().and_hms_opt(0, 0, 0).unwrap(); 559 | /// 560 | /// client.coin_market_chart_range("bitcoin", "usd", from, to).await; 561 | /// } 562 | /// ``` 563 | pub async fn coin_market_chart_range( 564 | &self, 565 | id: &str, 566 | vs_currency: &str, 567 | from: NaiveDateTime, 568 | to: NaiveDateTime, 569 | ) -> Result { 570 | let from_unix_timestamp = from.and_utc().timestamp(); 571 | let to_unix_timestamp = to.and_utc().timestamp(); 572 | 573 | let req = format!( 574 | "/coins/{}/market_chart/range?vs_currency={}&from={}&to={}", 575 | id, vs_currency, from_unix_timestamp, to_unix_timestamp 576 | ); 577 | self.get(&req).await 578 | } 579 | 580 | /// Get coin's OHLC 581 | /// 582 | /// Candle’s body: 583 | /// 1 - 2 days: 30 minutes 584 | /// 3 - 30 days: 4 hours 585 | /// 31 and before: 4 days 586 | /// 587 | /// # Examples 588 | /// 589 | /// ```rust 590 | /// #[tokio::main] 591 | /// async fn main() { 592 | /// use coingecko::{params::OhlcDays, CoinGeckoClient}; 593 | /// let client = CoinGeckoClient::default(); 594 | /// client.coin_ohlc("bitcoin", "usd", OhlcDays::OneDay).await; 595 | /// } 596 | /// ``` 597 | pub async fn coin_ohlc( 598 | &self, 599 | id: &str, 600 | vs_currency: &str, 601 | days: OhlcDays, 602 | ) -> Result>, Error> { 603 | let days = match days { 604 | OhlcDays::OneDay => 1, 605 | OhlcDays::SevenDays => 7, 606 | OhlcDays::FourteenDays => 14, 607 | OhlcDays::ThirtyDays => 30, 608 | OhlcDays::NinetyDays => 90, 609 | OhlcDays::OneHundredEightyDays => 180, 610 | OhlcDays::ThreeHundredSixtyFiveDays => 365, 611 | }; 612 | 613 | let req = format!( 614 | "/coins/{}/ohlc?vs_currency={}&days={}", 615 | id, vs_currency, days 616 | ); 617 | self.get(&req).await 618 | } 619 | 620 | /// Get coin info from contract address 621 | /// 622 | /// # Examples 623 | /// 624 | /// ```rust 625 | /// #[tokio::main] 626 | /// async fn main() { 627 | /// use coingecko::CoinGeckoClient; 628 | /// let client = CoinGeckoClient::default(); 629 | /// let uniswap_contract = "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984"; 630 | /// 631 | /// client.contract("ethereum", &uniswap_contract).await; 632 | /// } 633 | /// ``` 634 | pub async fn contract(&self, id: &str, contract_address: &str) -> Result { 635 | let req = format!("/coins/{}/contract/{}", id, contract_address); 636 | self.get(&req).await 637 | } 638 | 639 | /// Get historical market data include price, market cap, and 24h volume (granularity auto) 640 | /// 641 | /// # Examples 642 | /// 643 | /// ```rust 644 | /// #[tokio::main] 645 | /// async fn main() { 646 | /// use coingecko::CoinGeckoClient; 647 | /// let client = CoinGeckoClient::default(); 648 | /// let uniswap_contract = "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984"; 649 | /// 650 | /// client.contract_market_chart("ethereum", &uniswap_contract, "usd", 1).await; 651 | /// } 652 | /// ``` 653 | pub async fn contract_market_chart( 654 | &self, 655 | id: &str, 656 | contract_address: &str, 657 | vs_currency: &str, 658 | days: i64, 659 | ) -> Result { 660 | let req = format!( 661 | "/coins/{}/contract/{}/market_chart/?vs_currency={}&days={}", 662 | id, contract_address, vs_currency, days 663 | ); 664 | self.get(&req).await 665 | } 666 | 667 | /// Get historical market data include price, market cap, and 24h volume within a range of timestamp (granularity auto) 668 | /// 669 | /// # Examples 670 | /// 671 | /// ```rust 672 | /// #[tokio::main] 673 | /// async fn main() { 674 | /// use chrono::NaiveDate; 675 | /// use coingecko::CoinGeckoClient; 676 | /// let client = CoinGeckoClient::default(); 677 | /// let uniswap_contract = "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984"; 678 | /// 679 | /// let from = NaiveDate::from_ymd(2014, 2, 16).and_hms(19, 0, 32); 680 | /// let to = NaiveDate::from_ymd(2015, 1, 30).and_hms(0, 20, 32); 681 | /// 682 | /// client.contract_market_chart_range("ethereum", &uniswap_contract, "usd", from, to).await; 683 | /// } 684 | /// ``` 685 | pub async fn contract_market_chart_range( 686 | &self, 687 | id: &str, 688 | contract_address: &str, 689 | vs_currency: &str, 690 | from: NaiveDateTime, 691 | to: NaiveDateTime, 692 | ) -> Result { 693 | let from_unix_timestamp = from.and_utc().timestamp(); 694 | let to_unix_timestamp = to.and_utc().timestamp(); 695 | 696 | let req = format!( 697 | "/coins/{}/contract/{}/market_chart/range?vs_currency={}&from={}&to={}", 698 | id, contract_address, vs_currency, from_unix_timestamp, to_unix_timestamp 699 | ); 700 | self.get(&req).await 701 | } 702 | 703 | /// List all asset platforms (Blockchain networks) 704 | /// 705 | /// # Examples 706 | /// 707 | /// ```rust 708 | /// #[tokio::main] 709 | /// async fn main() { 710 | /// use coingecko::CoinGeckoClient; 711 | /// let client = CoinGeckoClient::default(); 712 | /// 713 | /// client.asset_platforms().await; 714 | /// } 715 | /// ``` 716 | pub async fn asset_platforms(&self) -> Result, Error> { 717 | self.get("/asset_platforms").await 718 | } 719 | 720 | /// List all categories 721 | /// 722 | /// # Examples 723 | /// 724 | /// ```rust 725 | /// #[tokio::main] 726 | /// async fn main() { 727 | /// use coingecko::CoinGeckoClient; 728 | /// let client = CoinGeckoClient::default(); 729 | /// 730 | /// client.categories_list().await; 731 | /// } 732 | /// ``` 733 | pub async fn categories_list(&self) -> Result, Error> { 734 | self.get("/coins/categories/list").await 735 | } 736 | 737 | /// List all categories with market data 738 | /// 739 | /// # Examples 740 | /// 741 | /// ```rust 742 | /// #[tokio::main] 743 | /// async fn main() { 744 | /// use coingecko::CoinGeckoClient; 745 | /// let client = CoinGeckoClient::default(); 746 | /// 747 | /// client.categories().await; 748 | /// } 749 | /// ``` 750 | pub async fn categories(&self) -> Result, Error> { 751 | self.get("/coins/categories").await 752 | } 753 | 754 | /// List all exchanges 755 | /// 756 | /// # Examples 757 | /// 758 | /// ```rust 759 | /// #[tokio::main] 760 | /// async fn main() { 761 | /// use coingecko::CoinGeckoClient; 762 | /// let client = CoinGeckoClient::default(); 763 | /// 764 | /// client.exchanges(10, 1).await; 765 | /// } 766 | /// ``` 767 | pub async fn exchanges(&self, per_page: i64, page: i64) -> Result, Error> { 768 | let req = format!("/exchanges?per_page={}&page={}", per_page, page); 769 | self.get(&req).await 770 | } 771 | 772 | /// List all supported markets id and name (no pagination required) 773 | /// 774 | /// Use this to obtain all the markets’ id in order to make API calls 775 | /// 776 | /// # Examples 777 | /// 778 | /// ```rust 779 | /// #[tokio::main] 780 | /// async fn main() { 781 | /// use coingecko::CoinGeckoClient; 782 | /// let client = CoinGeckoClient::default(); 783 | /// 784 | /// client.exchanges_list().await; 785 | /// } 786 | /// ``` 787 | pub async fn exchanges_list(&self) -> Result, Error> { 788 | self.get("/exchanges/list").await 789 | } 790 | 791 | /// Get exchange volume in BTC and top 100 tickers only 792 | /// 793 | /// **IMPORTANT**: 794 | /// Ticker object is limited to 100 items, to get more tickers, use exchange_tickers 795 | /// Ticker is_stale is true when ticker that has not been updated/unchanged from the exchange for a while. 796 | /// Ticker is_anomaly is true if ticker’s price is outliered by our system. 797 | /// You are responsible for managing how you want to display these information (e.g. footnote, different background, change opacity, hide) 798 | /// 799 | /// # Examples 800 | /// 801 | /// ```rust 802 | /// #[tokio::main] 803 | /// async fn main() { 804 | /// use coingecko::CoinGeckoClient; 805 | /// let client = CoinGeckoClient::default(); 806 | /// 807 | /// client.exchange("binance").await; 808 | /// } 809 | /// ``` 810 | pub async fn exchange(&self, id: &str) -> Result { 811 | let req = format!("/exchanges/{}", id); 812 | self.get(&req).await 813 | } 814 | 815 | /// Get exchange tickers (paginated) 816 | /// 817 | /// **IMPORTANT**: 818 | /// Ticker is_stale is true when ticker that has not been updated/unchanged from the exchange for a while. 819 | /// Ticker is_anomaly is true if ticker’s price is outliered by our system. 820 | /// You are responsible for managing how you want to display these information (e.g. footnote, different background, change opacity, hide) 821 | /// 822 | /// # Examples 823 | /// 824 | /// ```rust 825 | /// #[tokio::main] 826 | /// async fn main() { 827 | /// use coingecko::{params::TickersOrder, CoinGeckoClient}; 828 | /// let client = CoinGeckoClient::default(); 829 | /// 830 | /// client.exchange_tickers("binance", Some(&["btc"]), true, 1, TickersOrder::TrustScoreAsc, true).await; 831 | /// } 832 | /// ``` 833 | pub async fn exchange_tickers>( 834 | &self, 835 | id: &str, 836 | coin_ids: Option<&[CoinId]>, 837 | include_exchange_logo: bool, 838 | page: i64, 839 | order: TickersOrder, 840 | depth: bool, 841 | ) -> Result { 842 | let order = match order { 843 | TickersOrder::TrustScoreAsc => "trust_score_asc", 844 | TickersOrder::TrustScoreDesc => "trust_score_desc", 845 | TickersOrder::VolumeDesc => "volume_desc", 846 | }; 847 | 848 | let req = match coin_ids { 849 | Some(c_ids) => { 850 | let c_ids = c_ids.iter().map(AsRef::as_ref).collect::>(); 851 | format!("/exchanges/{}/tickers?coin_ids={}&include_exchange_logo={}&page={}&order={}&depth={}", id, c_ids.join("%2C"), include_exchange_logo, &page, order, depth) 852 | } 853 | None => format!( 854 | "/exchanges/{}/tickers?include_exchange_logo={}&page={}&order={}&depth={}", 855 | id, include_exchange_logo, &page, order, depth 856 | ), 857 | }; 858 | 859 | self.get(&req).await 860 | } 861 | 862 | /// Get status updates for a given exchange 863 | /// 864 | /// # Examples 865 | /// 866 | /// ```rust 867 | /// #[tokio::main] 868 | /// async fn main() { 869 | /// use coingecko::CoinGeckoClient; 870 | /// let client = CoinGeckoClient::default(); 871 | /// 872 | /// client.exchange_status_updates("binance", 10, 1).await; 873 | /// } 874 | /// ``` 875 | pub async fn exchange_status_updates( 876 | &self, 877 | id: &str, 878 | per_page: i64, 879 | page: i64, 880 | ) -> Result { 881 | let req = format!( 882 | "/exchanges/{}/status_updates?per_page={}&page={}", 883 | id, per_page, page, 884 | ); 885 | 886 | self.get(&req).await 887 | } 888 | 889 | /// Get volume_chart data for a given exchange 890 | /// 891 | /// # Examples 892 | /// 893 | /// ```rust 894 | /// #[tokio::main] 895 | /// async fn main() { 896 | /// use coingecko::CoinGeckoClient; 897 | /// let client = CoinGeckoClient::default(); 898 | /// 899 | /// client.exchange_volume_chart("binance", 1).await; 900 | /// } 901 | /// ``` 902 | pub async fn exchange_volume_chart( 903 | &self, 904 | id: &str, 905 | days: i64, 906 | ) -> Result, Error> { 907 | let req = format!("/exchanges/{}/volume_chart?days={}", id, days); 908 | self.get(&req).await 909 | } 910 | 911 | /// List all finance platforms 912 | /// 913 | /// # Examples 914 | /// 915 | /// ```rust 916 | /// #[tokio::main] 917 | /// async fn main() { 918 | /// use coingecko::CoinGeckoClient; 919 | /// let client = CoinGeckoClient::default(); 920 | /// 921 | /// client.finance_platforms(10, 1).await; 922 | /// } 923 | /// ``` 924 | pub async fn finance_platforms( 925 | &self, 926 | per_page: i64, 927 | page: i64, 928 | ) -> Result, Error> { 929 | let req = format!("/finance_platforms?per_page={}&page={}", per_page, page,); 930 | 931 | self.get(&req).await 932 | } 933 | 934 | /// List all finance products 935 | /// 936 | /// # Examples 937 | /// 938 | /// ```rust 939 | /// #[tokio::main] 940 | /// async fn main() { 941 | /// use coingecko::CoinGeckoClient; 942 | /// let client = CoinGeckoClient::default(); 943 | /// 944 | /// client.finance_products(10, 1).await; 945 | /// } 946 | /// ``` 947 | pub async fn finance_products( 948 | &self, 949 | per_page: i64, 950 | page: i64, 951 | ) -> Result, Error> { 952 | let req = format!("/finance_products?per_page={}&page={}", per_page, page,); 953 | 954 | self.get(&req).await 955 | } 956 | 957 | /// List all market indexes 958 | /// 959 | /// # Examples 960 | /// 961 | /// ```rust 962 | /// #[tokio::main] 963 | /// async fn main() { 964 | /// use coingecko::CoinGeckoClient; 965 | /// let client = CoinGeckoClient::default(); 966 | /// 967 | /// client.indexes(10, 1).await; 968 | /// } 969 | /// ``` 970 | pub async fn indexes(&self, per_page: i64, page: i64) -> Result, Error> { 971 | let req = format!("/indexes?per_page={}&page={}", per_page, page,); 972 | 973 | self.get(&req).await 974 | } 975 | 976 | /// Get market index by market id and index id 977 | /// 978 | /// # Examples 979 | /// 980 | /// ```rust 981 | /// #[tokio::main] 982 | /// async fn main() { 983 | /// use coingecko::CoinGeckoClient; 984 | /// let client = CoinGeckoClient::default(); 985 | /// 986 | /// client.indexes_market_id("binance_futures", "BTC").await; 987 | /// } 988 | /// ``` 989 | pub async fn indexes_market_id(&self, market_id: &str, id: &str) -> Result { 990 | let req = format!("/indexes/{}/{}", market_id, id); 991 | self.get(&req).await 992 | } 993 | 994 | /// List market indexes id and name 995 | /// 996 | /// # Examples 997 | /// 998 | /// ```rust 999 | /// #[tokio::main] 1000 | /// async fn main() { 1001 | /// use coingecko::CoinGeckoClient; 1002 | /// let client = CoinGeckoClient::default(); 1003 | /// 1004 | /// client.indexes_list().await; 1005 | /// } 1006 | /// ``` 1007 | pub async fn indexes_list(&self) -> Result, Error> { 1008 | self.get("/indexes/list").await 1009 | } 1010 | 1011 | /// List all derivative tickers 1012 | /// 1013 | /// # Examples 1014 | /// 1015 | /// ```rust 1016 | /// #[tokio::main] 1017 | /// async fn main() { 1018 | /// use coingecko::{params::DerivativesIncludeTickers, CoinGeckoClient}; 1019 | /// let client = CoinGeckoClient::default(); 1020 | /// 1021 | /// client.derivatives(Some(DerivativesIncludeTickers::All)).await; 1022 | /// } 1023 | /// ``` 1024 | pub async fn derivatives( 1025 | &self, 1026 | include_tickers: Option, 1027 | ) -> Result, Error> { 1028 | let include_tickers = match include_tickers { 1029 | Some(ic_enum) => match ic_enum { 1030 | DerivativesIncludeTickers::All => "all", 1031 | DerivativesIncludeTickers::Unexpired => "unexpired", 1032 | }, 1033 | None => "unexpired", 1034 | }; 1035 | 1036 | let req = format!("/derivatives?include_tickers={}", include_tickers); 1037 | self.get(&req).await 1038 | } 1039 | 1040 | /// List all derivative exchanges 1041 | /// 1042 | /// # Examples 1043 | /// 1044 | /// ```rust 1045 | /// #[tokio::main] 1046 | /// async fn main() { 1047 | /// use coingecko::{params::DerivativeExchangeOrder, CoinGeckoClient}; 1048 | /// let client = CoinGeckoClient::default(); 1049 | /// 1050 | /// client.derivative_exchanges(DerivativeExchangeOrder::NameAsc, 10, 1).await; 1051 | /// } 1052 | /// ``` 1053 | pub async fn derivative_exchanges( 1054 | &self, 1055 | order: DerivativeExchangeOrder, 1056 | per_page: i64, 1057 | page: i64, 1058 | ) -> Result, Error> { 1059 | let order = match order { 1060 | DerivativeExchangeOrder::NameAsc => "name_asc", 1061 | DerivativeExchangeOrder::NameDesc => "name_desc", 1062 | DerivativeExchangeOrder::OpenInterestBtcAsc => "open_interest_btc_asc", 1063 | DerivativeExchangeOrder::OpenInterestBtcDesc => "open_interest_btc_desc", 1064 | DerivativeExchangeOrder::TradeVolume24hBtcAsc => "trade_volume_24h_btc_asc", 1065 | DerivativeExchangeOrder::TradeVolume24hBtcDesc => "trade_volume_24h_btc_desc", 1066 | }; 1067 | 1068 | let req = format!( 1069 | "/derivatives/exchanges?order={}&per_page={}&page={}", 1070 | order, per_page, page 1071 | ); 1072 | self.get(&req).await 1073 | } 1074 | 1075 | /// Show derivative exchange data 1076 | /// 1077 | /// # Examples 1078 | /// 1079 | /// ```rust 1080 | /// #[tokio::main] 1081 | /// async fn main() { 1082 | /// use coingecko::{params::DerivativesIncludeTickers, CoinGeckoClient}; 1083 | /// let client = CoinGeckoClient::default(); 1084 | /// 1085 | /// client.derivatives_exchange("bitmex", Some(DerivativesIncludeTickers::All)).await; 1086 | /// } 1087 | /// ``` 1088 | pub async fn derivatives_exchange( 1089 | &self, 1090 | id: &str, 1091 | include_tickers: Option, 1092 | ) -> Result, Error> { 1093 | let include_tickers = match include_tickers { 1094 | Some(ic_enum) => match ic_enum { 1095 | DerivativesIncludeTickers::All => "all", 1096 | DerivativesIncludeTickers::Unexpired => "unexpired", 1097 | }, 1098 | None => "unexpired", 1099 | }; 1100 | 1101 | let req = format!( 1102 | "/derivatives/exchanges/{}?include_tickers={}", 1103 | id, include_tickers 1104 | ); 1105 | self.get(&req).await 1106 | } 1107 | 1108 | /// List all derivative exchanges name and identifier 1109 | /// 1110 | /// # Examples 1111 | /// 1112 | /// ```rust 1113 | /// #[tokio::main] 1114 | /// async fn main() { 1115 | /// use coingecko::CoinGeckoClient; 1116 | /// let client = CoinGeckoClient::default(); 1117 | /// 1118 | /// client.derivative_exchanges_list().await; 1119 | /// } 1120 | /// ``` 1121 | pub async fn derivative_exchanges_list(&self) -> Result, Error> { 1122 | self.get("/derivatives/exchanges/list").await 1123 | } 1124 | 1125 | /// List all status_updates with data (description, category, created_at, user, user_title and pin) 1126 | /// 1127 | /// # Examples 1128 | /// 1129 | /// ```rust 1130 | /// #[tokio::main] 1131 | /// async fn main() { 1132 | /// use coingecko::CoinGeckoClient; 1133 | /// let client = CoinGeckoClient::default(); 1134 | /// 1135 | /// client.status_updates(Some("general"), Some("coin"), 10, 1).await; 1136 | /// } 1137 | /// ``` 1138 | pub async fn status_updates( 1139 | &self, 1140 | category: Option<&str>, 1141 | project_type: Option<&str>, 1142 | per_page: i64, 1143 | page: i64, 1144 | ) -> Result { 1145 | let mut params: Vec = Vec::with_capacity(4); 1146 | 1147 | if let Some(c) = category { 1148 | params.push(format!("category={}", c)); 1149 | } 1150 | 1151 | if let Some(t) = project_type { 1152 | params.push(format!("project_type={}", t)); 1153 | } 1154 | 1155 | params.push(per_page.to_string()); 1156 | params.push(page.to_string()); 1157 | 1158 | let req = format!("/status_updates?{}", params.join("&")); 1159 | 1160 | self.get(&req).await 1161 | } 1162 | 1163 | /// Get events, paginated by 100 1164 | /// 1165 | /// # Examples 1166 | /// 1167 | /// ```rust 1168 | /// #[tokio::main] 1169 | /// async fn main() { 1170 | /// use chrono::NaiveDate; 1171 | /// use coingecko::CoinGeckoClient; 1172 | /// let client = CoinGeckoClient::default(); 1173 | /// 1174 | /// let from = NaiveDate::from_ymd(2021, 10, 7); 1175 | /// let to = NaiveDate::from_ymd(2022, 10, 7); 1176 | /// 1177 | /// client.events(Some("HK"), Some("Event"), 1, true, from, to).await; 1178 | /// } 1179 | /// ``` 1180 | pub async fn events( 1181 | &self, 1182 | country_code: Option<&str>, 1183 | event_type: Option<&str>, 1184 | page: i64, 1185 | upcoming_events_only: bool, 1186 | from_date: NaiveDate, 1187 | to_date: NaiveDate, 1188 | ) -> Result { 1189 | let mut params: Vec = Vec::with_capacity(2); 1190 | 1191 | if let Some(c) = country_code { 1192 | params.push(format!("country_code={}", c)); 1193 | } 1194 | 1195 | if let Some(t) = event_type { 1196 | params.push(format!("type={}", t)); 1197 | } 1198 | 1199 | let from_date = from_date.format("%Y-%m-%d").to_string(); 1200 | let to_date = to_date.format("%Y-%m-%d").to_string(); 1201 | 1202 | let req = format!( 1203 | "/events?{}&page={}&upcoming_events_only={}&from_date={}&to_date={}", 1204 | params.join("&"), 1205 | page, 1206 | upcoming_events_only, 1207 | from_date, 1208 | to_date, 1209 | ); 1210 | 1211 | self.get(&req).await 1212 | } 1213 | 1214 | /// Get list of event countries 1215 | /// 1216 | /// # Examples 1217 | /// 1218 | /// ```rust 1219 | /// #[tokio::main] 1220 | /// async fn main() { 1221 | /// use coingecko::CoinGeckoClient; 1222 | /// let client = CoinGeckoClient::default(); 1223 | /// 1224 | /// client.event_countries().await; 1225 | /// } 1226 | /// ``` 1227 | pub async fn event_countries(&self) -> Result { 1228 | self.get("/events/types").await 1229 | } 1230 | 1231 | /// Get list of event types 1232 | /// 1233 | /// # Examples 1234 | /// 1235 | /// ```rust 1236 | /// #[tokio::main] 1237 | /// async fn main() { 1238 | /// use coingecko::CoinGeckoClient; 1239 | /// let client = CoinGeckoClient::default(); 1240 | /// 1241 | /// client.event_types().await; 1242 | /// } 1243 | /// ``` 1244 | pub async fn event_types(&self) -> Result { 1245 | self.get("/events/types").await 1246 | } 1247 | 1248 | /// Get BTC-to-Currency exchange rates 1249 | /// 1250 | /// # Examples 1251 | /// 1252 | /// ```rust 1253 | /// #[tokio::main] 1254 | /// async fn main() { 1255 | /// use coingecko::CoinGeckoClient; 1256 | /// let client = CoinGeckoClient::default(); 1257 | /// 1258 | /// client.exchange_rates().await; 1259 | /// } 1260 | /// ``` 1261 | pub async fn exchange_rates(&self) -> Result { 1262 | self.get("/exchange_rates").await 1263 | } 1264 | 1265 | /// Top-7 trending coins on CoinGecko as searched by users in the last 24 hours (Ordered by most popular first) 1266 | /// 1267 | /// # Examples 1268 | /// 1269 | /// ```rust 1270 | /// #[tokio::main] 1271 | /// async fn main() { 1272 | /// use coingecko::CoinGeckoClient; 1273 | /// let client = CoinGeckoClient::default(); 1274 | /// 1275 | /// client.trending().await; 1276 | /// } 1277 | /// ``` 1278 | pub async fn trending(&self) -> Result { 1279 | self.get("/search/trending").await 1280 | } 1281 | 1282 | /// Get cryptocurrency global data 1283 | /// 1284 | /// # Examples 1285 | /// 1286 | /// ```rust 1287 | /// #[tokio::main] 1288 | /// async fn main() { 1289 | /// use coingecko::CoinGeckoClient; 1290 | /// let client = CoinGeckoClient::default(); 1291 | /// 1292 | /// client.global().await; 1293 | /// } 1294 | /// ``` 1295 | pub async fn global(&self) -> Result { 1296 | self.get("/global").await 1297 | } 1298 | 1299 | /// Get Top 100 Cryptocurrency Global Eecentralized Finance(defi) data 1300 | /// 1301 | /// # Examples 1302 | /// 1303 | /// ```rust 1304 | /// #[tokio::main] 1305 | /// async fn main() { 1306 | /// use coingecko::CoinGeckoClient; 1307 | /// let client = CoinGeckoClient::default(); 1308 | /// 1309 | /// client.global_defi().await; 1310 | /// } 1311 | /// ``` 1312 | pub async fn global_defi(&self) -> Result { 1313 | self.get("/global/decentralized_finance_defi").await 1314 | } 1315 | 1316 | /// Get public companies bitcoin or ethereum holdings (Ordered by total holdings descending) 1317 | /// 1318 | /// # Examples 1319 | /// 1320 | /// ```rust 1321 | /// #[tokio::main] 1322 | /// async fn main() { 1323 | /// use coingecko::{params::CompaniesCoinId, CoinGeckoClient}; 1324 | /// let client = CoinGeckoClient::default(); 1325 | /// 1326 | /// client.companies(CompaniesCoinId::Bitcoin).await; 1327 | /// } 1328 | /// ``` 1329 | pub async fn companies( 1330 | &self, 1331 | coin_id: CompaniesCoinId, 1332 | ) -> Result { 1333 | let req = match coin_id { 1334 | CompaniesCoinId::Bitcoin => "/companies/public_treasury/bitcoin".to_string(), 1335 | CompaniesCoinId::Ethereum => "/companies/public_treasury/ethereum".to_string(), 1336 | }; 1337 | 1338 | self.get(&req).await 1339 | } 1340 | } 1341 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | #![warn(missing_docs)] 2 | #![warn(unused_extern_crates)] 3 | #![warn(unused_qualifications)] 4 | 5 | //! Rust library for the CoinGecko API. 6 | //! 7 | //! # Installation 8 | //! 9 | //! Add the following to your `Cargo.toml` file: 10 | //! 11 | //! ```toml 12 | //! [dependencies] 13 | //! coingecko = "1.1.3" 14 | //! ``` 15 | 16 | /// Client module 17 | mod client; 18 | /// CoinGecko API Parameters 19 | pub mod params; 20 | /// Response structs for API requests 21 | pub mod response; 22 | /// CoinGecko Client 23 | pub use crate::client::{CoinGeckoClient, COINGECKO_API_DEMO_URL}; 24 | 25 | #[cfg(test)] 26 | mod tests { 27 | use chrono::{self, Datelike}; 28 | 29 | use crate::{ 30 | params::{MarketsOrder, OhlcDays, PriceChangePercentage, TickersOrder}, 31 | CoinGeckoClient, 32 | }; 33 | use chrono::NaiveDate; 34 | 35 | macro_rules! aw { 36 | ($e:expr) => { 37 | tokio_test::block_on($e) 38 | }; 39 | } 40 | 41 | // --------------------------------------------- 42 | // /ping 43 | // --------------------------------------------- 44 | #[test] 45 | #[doc(hidden)] 46 | fn ping() { 47 | let client: CoinGeckoClient = CoinGeckoClient::default(); 48 | let res = aw!(client.ping()); 49 | assert!(res.is_ok(), "ping should resolve"); 50 | assert_eq!(res.unwrap().gecko_says, "(V3) To the Moon!"); 51 | } 52 | 53 | // --------------------------------------------- 54 | // /simple 55 | // --------------------------------------------- 56 | #[test] 57 | fn price() { 58 | let client: CoinGeckoClient = CoinGeckoClient::default(); 59 | let res_1 = aw!(client.price(&["bitcoin"], &["usd"], true, true, true, true)); 60 | 61 | assert!(res_1.is_ok(), "price should resolve"); 62 | let price_1 = &res_1.unwrap()["bitcoin"]; 63 | assert!(price_1.usd.is_some(), "usd price should be defined"); 64 | assert!( 65 | price_1.usd_market_cap.is_some(), 66 | "usd price should be defined" 67 | ); 68 | assert!( 69 | price_1.usd24_h_vol.is_some(), 70 | "usd 24h vol should be defined" 71 | ); 72 | assert!( 73 | price_1.usd24_h_change.is_some(), 74 | "usd 24h change should be defined" 75 | ); 76 | assert!( 77 | price_1.last_updated_at.is_some(), 78 | "usd last update should be defined" 79 | ); 80 | 81 | let res_2 = aw!(client.price(&["ethereum"], &["eur"], true, true, true, true)); 82 | 83 | assert!(res_2.is_ok(), "price should resolve"); 84 | let price_2 = &res_2.unwrap()["ethereum"]; 85 | assert!(price_2.eur.is_some(), "eur price should be defined"); 86 | assert!( 87 | price_2.eur_market_cap.is_some(), 88 | "eur price should be defined" 89 | ); 90 | assert!( 91 | price_2.eur24_h_vol.is_some(), 92 | "eur 24h vol should be defined" 93 | ); 94 | assert!( 95 | price_2.eur24_h_change.is_some(), 96 | "eur 24h change should be defined" 97 | ); 98 | assert!( 99 | price_2.last_updated_at.is_some(), 100 | "eur last update should be defined" 101 | ); 102 | } 103 | 104 | #[test] 105 | fn token_price() { 106 | let client: CoinGeckoClient = CoinGeckoClient::default(); 107 | let uniswap_contract = "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984"; 108 | let res = aw!(client.token_price( 109 | "ethereum", 110 | &[uniswap_contract], 111 | &["usd"], 112 | true, 113 | true, 114 | true, 115 | true 116 | )); 117 | 118 | assert!(res.is_ok(), "token price should resolve"); 119 | let token_price = &res.unwrap()[&uniswap_contract.to_string()]; 120 | assert!(token_price.usd.is_some(), "usd price should be defined"); 121 | assert!( 122 | token_price.usd_market_cap.is_some(), 123 | "usd price should be defined" 124 | ); 125 | assert!( 126 | token_price.usd24_h_vol.is_some(), 127 | "usd 24h vol should be defined" 128 | ); 129 | assert!( 130 | token_price.usd24_h_change.is_some(), 131 | "usd 24h change should be defined" 132 | ); 133 | assert!( 134 | token_price.last_updated_at.is_some(), 135 | "usd last update should be defined" 136 | ); 137 | } 138 | 139 | #[test] 140 | fn supported_vs_currencies() { 141 | let client: CoinGeckoClient = CoinGeckoClient::default(); 142 | let res = aw!(client.supported_vs_currencies()); 143 | 144 | assert!(res.is_ok(), "supported_vs_currencies should resolve"); 145 | assert!( 146 | !res.unwrap().is_empty(), 147 | "should return at least one currency" 148 | ); 149 | } 150 | 151 | // --------------------------------------------- 152 | // /coins 153 | // --------------------------------------------- 154 | #[test] 155 | fn coins_list() { 156 | let client: CoinGeckoClient = CoinGeckoClient::default(); 157 | let res = aw!(client.coins_list(true)); 158 | assert!(res.is_ok(), "list should resolve"); 159 | assert!(!res.unwrap().is_empty(), "should return at least one coin"); 160 | } 161 | 162 | #[test] 163 | fn coins_markets() { 164 | let client: CoinGeckoClient = CoinGeckoClient::default(); 165 | 166 | let res = aw!(client.coins_markets( 167 | "usd", 168 | &["bitcoin"], 169 | None, 170 | MarketsOrder::GeckoDesc, 171 | 1, 172 | 0, 173 | true, 174 | &[ 175 | PriceChangePercentage::OneHour, 176 | PriceChangePercentage::TwentyFourHours, 177 | PriceChangePercentage::SevenDays, 178 | PriceChangePercentage::FourteenDays, 179 | PriceChangePercentage::ThirtyDays, 180 | PriceChangePercentage::OneYear 181 | ], 182 | )); 183 | 184 | assert!(res.is_ok(), "markets should resolve"); 185 | 186 | let res2 = aw!(client.coins_markets( 187 | "usd", 188 | &[] as &[&str], 189 | None, 190 | MarketsOrder::MarketCapDesc, 191 | 250, 192 | 30, 193 | false, 194 | &[], 195 | )); 196 | assert!( 197 | res2.is_ok(), 198 | "markets should resolve for pages near the end" 199 | ); 200 | } 201 | 202 | #[tokio::test(flavor = "multi_thread", worker_threads = 2)] 203 | async fn coin() { 204 | let client: CoinGeckoClient = CoinGeckoClient::default(); 205 | let res1 = client 206 | .coin("01coin", false, false, false, false, false, false) 207 | .await; 208 | 209 | assert!(&res1.is_ok(), "coin should resolve"); 210 | assert_eq!(res1.unwrap().id, "01coin", "coin 01coin should resolve"); 211 | } 212 | 213 | #[test] 214 | fn coin_tickers() { 215 | let client: CoinGeckoClient = CoinGeckoClient::default(); 216 | 217 | let res1 = aw!(client.coin_tickers::<&str>( 218 | "bitcoin", 219 | None, 220 | true, 221 | 1, 222 | TickersOrder::VolumeDesc, 223 | true 224 | )); 225 | 226 | assert!(res1.is_ok(), "tickers without filter should resolve"); 227 | 228 | let res2 = aw!(client.coin_tickers( 229 | "bitcoin", 230 | #[allow(clippy::useless_vec)] 231 | Some(&vec![String::from("binance")]), // &Vec should also work 232 | true, 233 | 1, 234 | TickersOrder::VolumeDesc, 235 | true 236 | )); 237 | 238 | assert!(res2.is_ok(), "tickers without page should resolve"); 239 | 240 | let res3 = aw!(client.coin_tickers( 241 | "bitcoin", 242 | Some(&["binance"]), 243 | true, 244 | 1, 245 | TickersOrder::VolumeDesc, 246 | true 247 | )); 248 | 249 | assert!(res3.is_ok(), "tickers should resolve"); 250 | } 251 | 252 | #[test] 253 | fn coin_history() { 254 | let client: CoinGeckoClient = CoinGeckoClient::default(); 255 | let current_date = chrono::Utc::now(); 256 | 257 | let res = aw!(client.coin_history( 258 | "bitcoin", 259 | NaiveDate::from_ymd_opt(current_date.year(), 12, 30).unwrap(), 260 | true 261 | )); 262 | 263 | assert!(res.is_ok(), "history should resolve"); 264 | } 265 | 266 | #[test] 267 | fn coin_market_chart() { 268 | let client: CoinGeckoClient = CoinGeckoClient::default(); 269 | 270 | let res = aw!(client.coin_market_chart("bitcoin", "usd", 1, true)); 271 | 272 | assert!(res.is_ok(), "market chart should resolve"); 273 | } 274 | 275 | #[test] 276 | fn coin_market_chart_range() { 277 | let client: CoinGeckoClient = CoinGeckoClient::default(); 278 | 279 | let current_date = chrono::Utc::now(); 280 | let from = NaiveDate::from_ymd_opt( 281 | current_date.year(), 282 | current_date.month() - 1, 283 | current_date.day(), 284 | ) 285 | .unwrap() 286 | .and_hms_opt(0, 0, 0) 287 | .unwrap(); 288 | let to = NaiveDate::from_ymd_opt( 289 | current_date.year(), 290 | current_date.month(), 291 | current_date.day(), 292 | ) 293 | .unwrap() 294 | .and_hms_opt(0, 0, 0) 295 | .unwrap(); 296 | 297 | let res = aw!(client.coin_market_chart_range("bitcoin", "usd", from, to)); 298 | 299 | assert!(res.is_ok(), "market chart range should resolve"); 300 | } 301 | 302 | #[test] 303 | fn coin_ohlc() { 304 | let client: CoinGeckoClient = CoinGeckoClient::default(); 305 | 306 | let res = aw!(client.coin_ohlc("bitcoin", "usd", OhlcDays::OneDay)); 307 | 308 | assert!(res.is_ok(), "ohlc should resolve"); 309 | } 310 | } 311 | -------------------------------------------------------------------------------- /src/params.rs: -------------------------------------------------------------------------------- 1 | use serde::{Deserialize, Serialize}; 2 | 3 | /// Market display order for `coins_markets` 4 | #[derive(Deserialize, Serialize, Debug, Clone, Copy)] 5 | pub enum MarketsOrder { 6 | /// Marketcap descending 7 | MarketCapDesc, 8 | /// Marketcap ascending 9 | MarketCapAsc, 10 | /// Coingecko descending 11 | GeckoDesc, 12 | /// Coingecko ascending 13 | GeckoAsc, 14 | /// Volume descending 15 | VolumeDesc, 16 | /// Volume ascending 17 | VolumeAsc, 18 | /// ID descending 19 | IdDesc, 20 | /// ID ascending 21 | IdAsc, 22 | } 23 | 24 | /// Price change percentage times for `coins_markets` 25 | #[derive(Deserialize, Serialize, Debug, Clone, Copy)] 26 | pub enum PriceChangePercentage { 27 | /// 1h 28 | OneHour, 29 | /// 24h 30 | TwentyFourHours, 31 | /// 7d 32 | SevenDays, 33 | /// 14d 34 | FourteenDays, 35 | /// 30d 36 | ThirtyDays, 37 | /// 200d 38 | TwoHundredDays, 39 | /// 1y 40 | OneYear, 41 | } 42 | 43 | /// Tickers order for `coin_tickers` and `exchange_tickers` 44 | #[derive(Deserialize, Serialize, Debug, Clone, Copy)] 45 | pub enum TickersOrder { 46 | /// Trust Score ascending 47 | TrustScoreAsc, 48 | /// Trust Score descending 49 | TrustScoreDesc, 50 | /// Volume descending 51 | VolumeDesc, 52 | } 53 | 54 | /// Ohlc times for `coin_ohlc` 55 | #[derive(Deserialize, Serialize, Debug, Clone, Copy)] 56 | pub enum OhlcDays { 57 | /// 1d 58 | OneDay, 59 | /// 7d 60 | SevenDays, 61 | /// 14d 62 | FourteenDays, 63 | /// 30d 64 | ThirtyDays, 65 | /// 90d 66 | NinetyDays, 67 | /// 180d 68 | OneHundredEightyDays, 69 | /// 365 70 | ThreeHundredSixtyFiveDays, 71 | } 72 | 73 | /// Tickers to include for `derivatives` and `derivatives_exchange` 74 | #[derive(Deserialize, Serialize, Debug, Clone, Copy)] 75 | pub enum DerivativesIncludeTickers { 76 | /// All tickers 77 | All, 78 | /// Unexpired tickers 79 | Unexpired, 80 | } 81 | 82 | /// Order of exchanges for `derivative_exchanges` 83 | #[derive(Deserialize, Serialize, Debug, Clone, Copy)] 84 | pub enum DerivativeExchangeOrder { 85 | /// Name ascending 86 | NameAsc, 87 | /// Name descending 88 | NameDesc, 89 | /// Open interest BTC ascending 90 | OpenInterestBtcAsc, 91 | /// Open interest BTC descending 92 | OpenInterestBtcDesc, 93 | /// 24h BTC trade volume ascending 94 | TradeVolume24hBtcAsc, 95 | /// 24h BTC trade volume descending 96 | TradeVolume24hBtcDesc, 97 | } 98 | 99 | /// IDs for coins held in treasury for `companies` 100 | #[derive(Deserialize, Serialize, Debug, Clone, Copy)] 101 | pub enum CompaniesCoinId { 102 | /// Bitcoin 103 | Bitcoin, 104 | /// Ethereum 105 | Ethereum, 106 | } 107 | -------------------------------------------------------------------------------- /src/response/asset_platforms.rs: -------------------------------------------------------------------------------- 1 | #![allow(missing_docs)] 2 | use serde::{Deserialize, Serialize}; 3 | 4 | #[derive(Serialize, Deserialize, Debug, Clone)] 5 | pub struct AssetPlatform { 6 | pub id: String, 7 | pub chain_identifier: Option, 8 | pub name: String, 9 | pub shortname: String, 10 | pub native_coin_id: String, 11 | } 12 | -------------------------------------------------------------------------------- /src/response/coins.rs: -------------------------------------------------------------------------------- 1 | #![allow(missing_docs)] 2 | use serde::{Deserialize, Serialize}; 3 | use serde_json::Value; 4 | use std::collections::HashMap; 5 | 6 | use super::common::{ 7 | CommunityData, CurrentPrice, DeveloperData, Image, Links, Localization, MarketCap, 8 | PublicInterestStats, Ticker, TotalVolume, 9 | }; 10 | 11 | // --------------------------------------------- 12 | // /coins/list 13 | // --------------------------------------------- 14 | #[derive(Serialize, Deserialize, Debug, Clone)] 15 | pub struct CoinsListItem { 16 | pub id: String, 17 | pub symbol: String, 18 | pub name: String, 19 | pub platforms: Option>>, 20 | } 21 | 22 | // --------------------------------------------- 23 | // /coins/markets 24 | // --------------------------------------------- 25 | #[derive(Serialize, Deserialize, Debug, Clone)] 26 | pub struct SparklineIn7D { 27 | pub price: Vec, 28 | } 29 | 30 | #[derive(Serialize, Deserialize, Debug, Clone)] 31 | pub struct CoinsMarketItem { 32 | pub id: String, 33 | pub symbol: String, 34 | pub name: String, 35 | pub image: String, 36 | pub current_price: Option, 37 | pub market_cap: Option, 38 | pub market_cap_rank: Value, 39 | pub fully_diluted_valuation: Value, 40 | pub total_volume: Option, 41 | #[serde(rename = "high_24h")] 42 | pub high24_h: Option, 43 | #[serde(rename = "low_24h")] 44 | pub low24_h: Option, 45 | #[serde(rename = "price_change_24h")] 46 | pub price_change24_h: Option, 47 | #[serde(rename = "price_change_percentage_24h")] 48 | pub price_change_percentage24_h: Option, 49 | #[serde(rename = "market_cap_change_24h")] 50 | pub market_cap_change24_h: Option, 51 | #[serde(rename = "market_cap_change_percentage_24h")] 52 | pub market_cap_change_percentage24_h: Option, 53 | pub circulating_supply: Option, 54 | pub total_supply: Option, 55 | pub max_supply: Option, 56 | pub ath: Option, 57 | pub ath_change_percentage: Option, 58 | pub ath_date: Option, 59 | pub atl: Option, 60 | pub atl_change_percentage: Option, 61 | pub atl_date: Option, 62 | pub roi: Value, 63 | pub last_updated: Option, 64 | #[serde(rename = "sparkline_in_7d")] 65 | pub sparkline_in7_d: Option, 66 | #[serde(rename = "price_change_percentage_14d_in_currency")] 67 | pub price_change_percentage14_d_in_currency: Option, 68 | #[serde(rename = "price_change_percentage_1h_in_currency")] 69 | pub price_change_percentage1_h_in_currency: Option, 70 | #[serde(rename = "price_change_percentage_1y_in_currency")] 71 | pub price_change_percentage1_y_in_currency: Option, 72 | #[serde(rename = "price_change_percentage_200d_in_currency")] 73 | pub price_change_percentage200_d_in_currency: Option, 74 | #[serde(rename = "price_change_percentage_24h_in_currency")] 75 | pub price_change_percentage24_h_in_currency: Option, 76 | #[serde(rename = "price_change_percentage_30d_in_currency")] 77 | pub price_change_percentage30_d_in_currency: Option, 78 | #[serde(rename = "price_change_percentage_7d_in_currency")] 79 | pub price_change_percentage7_d_in_currency: Option, 80 | } 81 | 82 | #[derive(Serialize, Deserialize, Debug, Clone)] 83 | pub struct DetailPlatform { 84 | pub contract_address: String, 85 | pub decimal_place: Option, 86 | } 87 | 88 | // --------------------------------------------- 89 | // /coins/{id} 90 | // --------------------------------------------- 91 | #[derive(Serialize, Deserialize, Default, Debug, Clone)] 92 | pub struct CoinsItem { 93 | pub id: String, 94 | pub symbol: String, 95 | pub name: String, 96 | pub web_slug: String, 97 | pub asset_platform_id: Option, 98 | pub platforms: HashMap, 99 | pub detail_platforms: HashMap, 100 | pub block_time_in_minutes: f64, 101 | pub hashing_algorithm: Value, 102 | pub categories: Vec, 103 | pub public_notice: Value, 104 | pub additional_notices: Vec, 105 | pub localization: Option, 106 | pub description: Description, 107 | pub links: Links, 108 | pub image: Image, 109 | pub country_origin: Value, 110 | pub genesis_date: Value, 111 | pub contract_address: Option, 112 | pub sentiment_votes_up_percentage: Value, 113 | pub sentiment_votes_down_percentage: Value, 114 | pub market_cap_rank: Value, 115 | // pub coingecko_rank: Value, 116 | // pub coingecko_score: Value, 117 | // pub developer_score: Value, 118 | //pub community_score: Value, 119 | //pub liquidity_score: Value, 120 | //pub public_interest_score: Value, 121 | pub market_data: Option, 122 | pub community_data: Option, 123 | pub developer_data: Option, 124 | //pub public_interest_stats: PublicInterestStats, 125 | pub status_updates: Vec, 126 | pub last_updated: Value, 127 | pub tickers: Option>, 128 | } 129 | 130 | #[derive(Serialize, Deserialize, Default, Debug, Clone)] 131 | pub struct Description { 132 | pub en: Option, 133 | pub de: Option, 134 | pub es: Option, 135 | pub fr: Option, 136 | pub it: Option, 137 | pub pl: Option, 138 | pub ro: Option, 139 | pub hu: Option, 140 | pub nl: Option, 141 | pub pt: Option, 142 | pub sv: Option, 143 | pub vi: Option, 144 | pub tr: Option, 145 | pub ru: Option, 146 | pub ja: Option, 147 | pub zh: Option, 148 | #[serde(rename = "zh-tw")] 149 | pub zh_tw: Option, 150 | pub ko: Option, 151 | pub ar: Option, 152 | pub th: Option, 153 | pub id: Option, 154 | } 155 | 156 | #[derive(Serialize, Deserialize, Debug, Clone)] 157 | pub struct MarketData { 158 | pub current_price: CurrentPrice, 159 | pub total_value_locked: Value, 160 | pub mcap_to_tvl_ratio: Value, 161 | pub fdv_to_tvl_ratio: Value, 162 | pub roi: Value, 163 | pub ath: Ath, 164 | pub ath_change_percentage: AthChangePercentage, 165 | pub ath_date: AthDate, 166 | pub atl: Atl, 167 | pub atl_change_percentage: AtlChangePercentage, 168 | pub atl_date: AtlDate, 169 | pub market_cap: MarketCap, 170 | pub market_cap_rank: Value, 171 | pub fully_diluted_valuation: FullyDilutedValuation, 172 | pub total_volume: TotalVolume, 173 | #[serde(rename = "high_24h")] 174 | pub high24_h: High24H, 175 | #[serde(rename = "low_24h")] 176 | pub low24_h: Low24H, 177 | #[serde(rename = "price_change_24h")] 178 | pub price_change24_h: Option, 179 | #[serde(rename = "price_change_percentage_24h")] 180 | pub price_change_percentage24_h: Option, 181 | #[serde(rename = "price_change_percentage_7d")] 182 | pub price_change_percentage7_d: Option, 183 | #[serde(rename = "price_change_percentage_14d")] 184 | pub price_change_percentage14_d: Option, 185 | #[serde(rename = "price_change_percentage_30d")] 186 | pub price_change_percentage30_d: Option, 187 | #[serde(rename = "price_change_percentage_60d")] 188 | pub price_change_percentage60_d: Option, 189 | #[serde(rename = "price_change_percentage_200d")] 190 | pub price_change_percentage200_d: Option, 191 | #[serde(rename = "price_change_percentage_1y")] 192 | pub price_change_percentage1_y: Option, 193 | #[serde(rename = "market_cap_change_24h")] 194 | pub market_cap_change24_h: Option, 195 | #[serde(rename = "market_cap_change_percentage_24h")] 196 | pub market_cap_change_percentage24_h: Option, 197 | #[serde(rename = "price_change_24h_in_currency")] 198 | pub price_change24_h_in_currency: Option, 199 | #[serde(rename = "price_change_percentage_1h_in_currency")] 200 | pub price_change_percentage1_h_in_currency: Option, 201 | #[serde(rename = "price_change_percentage_24h_in_currency")] 202 | pub price_change_percentage24_h_in_currency: Option, 203 | #[serde(rename = "price_change_percentage_7d_in_currency")] 204 | pub price_change_percentage7_d_in_currency: Option, 205 | #[serde(rename = "price_change_percentage_14d_in_currency")] 206 | pub price_change_percentage14_d_in_currency: Option, 207 | #[serde(rename = "price_change_percentage_30d_in_currency")] 208 | pub price_change_percentage30_d_in_currency: Option, 209 | #[serde(rename = "price_change_percentage_60d_in_currency")] 210 | pub price_change_percentage60_d_in_currency: Option, 211 | #[serde(rename = "price_change_percentage_200d_in_currency")] 212 | pub price_change_percentage200_d_in_currency: Option, 213 | #[serde(rename = "price_change_percentage_1y_in_currency")] 214 | pub price_change_percentage1_y_in_currency: Option, 215 | #[serde(rename = "market_cap_change_24h_in_currency")] 216 | pub market_cap_change24_h_in_currency: Option, 217 | #[serde(rename = "market_cap_change_percentage_24h_in_currency")] 218 | pub market_cap_change_percentage24_h_in_currency: 219 | Option, 220 | pub total_supply: Value, 221 | pub max_supply: Value, 222 | pub circulating_supply: Value, 223 | #[serde(rename = "sparkline_7d")] 224 | pub sparkline7_d: Option, 225 | pub last_updated: Value, 226 | } 227 | 228 | #[derive(Serialize, Deserialize, Debug, Clone)] 229 | pub struct Ath { 230 | pub aed: Option, 231 | pub ars: Option, 232 | pub aud: Option, 233 | pub bch: Option, 234 | pub bdt: Option, 235 | pub bhd: Option, 236 | pub bmd: Option, 237 | pub bnb: Option, 238 | pub brl: Option, 239 | pub btc: Option, 240 | pub cad: Option, 241 | pub chf: Option, 242 | pub clp: Option, 243 | pub cny: Option, 244 | pub czk: Option, 245 | pub dkk: Option, 246 | pub dot: Option, 247 | pub eos: Option, 248 | pub eth: Option, 249 | pub eur: Option, 250 | pub gbp: Option, 251 | pub hkd: Option, 252 | pub huf: Option, 253 | pub idr: Option, 254 | pub ils: Option, 255 | pub inr: Option, 256 | pub jpy: Option, 257 | pub krw: Option, 258 | pub kwd: Option, 259 | pub lkr: Option, 260 | pub ltc: Option, 261 | pub mmk: Option, 262 | pub mxn: Option, 263 | pub myr: Option, 264 | pub ngn: Option, 265 | pub nok: Option, 266 | pub nzd: Option, 267 | pub php: Option, 268 | pub pkr: Option, 269 | pub pln: Option, 270 | pub rub: Option, 271 | pub sar: Option, 272 | pub sek: Option, 273 | pub sgd: Option, 274 | pub thb: Option, 275 | #[serde(rename = "try")] 276 | pub try_field: Option, 277 | pub twd: Option, 278 | pub uah: Option, 279 | pub usd: Option, 280 | pub vef: Option, 281 | pub vnd: Option, 282 | pub xag: Option, 283 | pub xau: Option, 284 | pub xdr: Option, 285 | pub xlm: Option, 286 | pub xrp: Option, 287 | pub yfi: Option, 288 | pub zar: Option, 289 | pub bits: Option, 290 | pub link: Option, 291 | pub sats: Option, 292 | } 293 | 294 | #[derive(Serialize, Deserialize, Debug, Clone)] 295 | pub struct AthChangePercentage { 296 | pub aed: Option, 297 | pub ars: Option, 298 | pub aud: Option, 299 | pub bch: Option, 300 | pub bdt: Option, 301 | pub bhd: Option, 302 | pub bmd: Option, 303 | pub bnb: Option, 304 | pub brl: Option, 305 | pub btc: Option, 306 | pub cad: Option, 307 | pub chf: Option, 308 | pub clp: Option, 309 | pub cny: Option, 310 | pub czk: Option, 311 | pub dkk: Option, 312 | pub dot: Option, 313 | pub eos: Option, 314 | pub eth: Option, 315 | pub eur: Option, 316 | pub gbp: Option, 317 | pub hkd: Option, 318 | pub huf: Option, 319 | pub idr: Option, 320 | pub ils: Option, 321 | pub inr: Option, 322 | pub jpy: Option, 323 | pub krw: Option, 324 | pub kwd: Option, 325 | pub lkr: Option, 326 | pub ltc: Option, 327 | pub mmk: Option, 328 | pub mxn: Option, 329 | pub myr: Option, 330 | pub ngn: Option, 331 | pub nok: Option, 332 | pub nzd: Option, 333 | pub php: Option, 334 | pub pkr: Option, 335 | pub pln: Option, 336 | pub rub: Option, 337 | pub sar: Option, 338 | pub sek: Option, 339 | pub sgd: Option, 340 | pub thb: Option, 341 | #[serde(rename = "try")] 342 | pub try_field: Option, 343 | pub twd: Option, 344 | pub uah: Option, 345 | pub usd: Option, 346 | pub vef: Option, 347 | pub vnd: Option, 348 | pub xag: Option, 349 | pub xau: Option, 350 | pub xdr: Option, 351 | pub xlm: Option, 352 | pub xrp: Option, 353 | pub yfi: Option, 354 | pub zar: Option, 355 | pub bits: Option, 356 | pub link: Option, 357 | pub sats: Option, 358 | } 359 | 360 | #[derive(Serialize, Deserialize, Debug, Clone)] 361 | pub struct AthDate { 362 | pub aed: Option, 363 | pub ars: Option, 364 | pub aud: Option, 365 | pub bch: Option, 366 | pub bdt: Option, 367 | pub bhd: Option, 368 | pub bmd: Option, 369 | pub bnb: Option, 370 | pub brl: Option, 371 | pub btc: Option, 372 | pub cad: Option, 373 | pub chf: Option, 374 | pub clp: Option, 375 | pub cny: Option, 376 | pub czk: Option, 377 | pub dkk: Option, 378 | pub dot: Option, 379 | pub eos: Option, 380 | pub eth: Option, 381 | pub eur: Option, 382 | pub gbp: Option, 383 | pub hkd: Option, 384 | pub huf: Option, 385 | pub idr: Option, 386 | pub ils: Option, 387 | pub inr: Option, 388 | pub jpy: Option, 389 | pub krw: Option, 390 | pub kwd: Option, 391 | pub lkr: Option, 392 | pub ltc: Option, 393 | pub mmk: Option, 394 | pub mxn: Option, 395 | pub myr: Option, 396 | pub ngn: Option, 397 | pub nok: Option, 398 | pub nzd: Option, 399 | pub php: Option, 400 | pub pkr: Option, 401 | pub pln: Option, 402 | pub rub: Option, 403 | pub sar: Option, 404 | pub sek: Option, 405 | pub sgd: Option, 406 | pub thb: Option, 407 | #[serde(rename = "try")] 408 | pub try_field: Option, 409 | pub twd: Option, 410 | pub uah: Option, 411 | pub usd: Option, 412 | pub vef: Option, 413 | pub vnd: Option, 414 | pub xag: Option, 415 | pub xau: Option, 416 | pub xdr: Option, 417 | pub xlm: Option, 418 | pub xrp: Option, 419 | pub yfi: Option, 420 | pub zar: Option, 421 | pub bits: Option, 422 | pub link: Option, 423 | pub sats: Option, 424 | } 425 | 426 | #[derive(Serialize, Deserialize, Debug, Clone)] 427 | pub struct Atl { 428 | pub aed: Option, 429 | pub ars: Option, 430 | pub aud: Option, 431 | pub bch: Option, 432 | pub bdt: Option, 433 | pub bhd: Option, 434 | pub bmd: Option, 435 | pub bnb: Option, 436 | pub brl: Option, 437 | pub btc: Option, 438 | pub cad: Option, 439 | pub chf: Option, 440 | pub clp: Option, 441 | pub cny: Option, 442 | pub czk: Option, 443 | pub dkk: Option, 444 | pub dot: Option, 445 | pub eos: Option, 446 | pub eth: Option, 447 | pub eur: Option, 448 | pub gbp: Option, 449 | pub hkd: Option, 450 | pub huf: Option, 451 | pub idr: Option, 452 | pub ils: Option, 453 | pub inr: Option, 454 | pub jpy: Option, 455 | pub krw: Option, 456 | pub kwd: Option, 457 | pub lkr: Option, 458 | pub ltc: Option, 459 | pub mmk: Option, 460 | pub mxn: Option, 461 | pub myr: Option, 462 | pub ngn: Option, 463 | pub nok: Option, 464 | pub nzd: Option, 465 | pub php: Option, 466 | pub pkr: Option, 467 | pub pln: Option, 468 | pub rub: Option, 469 | pub sar: Option, 470 | pub sek: Option, 471 | pub sgd: Option, 472 | pub thb: Option, 473 | #[serde(rename = "try")] 474 | pub try_field: Option, 475 | pub twd: Option, 476 | pub uah: Option, 477 | pub usd: Option, 478 | pub vef: Option, 479 | pub vnd: Option, 480 | pub xag: Option, 481 | pub xau: Option, 482 | pub xdr: Option, 483 | pub xlm: Option, 484 | pub xrp: Option, 485 | pub yfi: Option, 486 | pub zar: Option, 487 | pub bits: Option, 488 | pub link: Option, 489 | pub sats: Option, 490 | } 491 | 492 | #[derive(Serialize, Deserialize, Debug, Clone)] 493 | pub struct AtlChangePercentage { 494 | pub aed: Option, 495 | pub ars: Option, 496 | pub aud: Option, 497 | pub bch: Option, 498 | pub bdt: Option, 499 | pub bhd: Option, 500 | pub bmd: Option, 501 | pub bnb: Option, 502 | pub brl: Option, 503 | pub btc: Option, 504 | pub cad: Option, 505 | pub chf: Option, 506 | pub clp: Option, 507 | pub cny: Option, 508 | pub czk: Option, 509 | pub dkk: Option, 510 | pub dot: Option, 511 | pub eos: Option, 512 | pub eth: Option, 513 | pub eur: Option, 514 | pub gbp: Option, 515 | pub hkd: Option, 516 | pub huf: Option, 517 | pub idr: Option, 518 | pub ils: Option, 519 | pub inr: Option, 520 | pub jpy: Option, 521 | pub krw: Option, 522 | pub kwd: Option, 523 | pub lkr: Option, 524 | pub ltc: Option, 525 | pub mmk: Option, 526 | pub mxn: Option, 527 | pub myr: Option, 528 | pub ngn: Option, 529 | pub nok: Option, 530 | pub nzd: Option, 531 | pub php: Option, 532 | pub pkr: Option, 533 | pub pln: Option, 534 | pub rub: Option, 535 | pub sar: Option, 536 | pub sek: Option, 537 | pub sgd: Option, 538 | pub thb: Option, 539 | #[serde(rename = "try")] 540 | pub try_field: Option, 541 | pub twd: Option, 542 | pub uah: Option, 543 | pub usd: Option, 544 | pub vef: Option, 545 | pub vnd: Option, 546 | pub xag: Option, 547 | pub xau: Option, 548 | pub xdr: Option, 549 | pub xlm: Option, 550 | pub xrp: Option, 551 | pub yfi: Option, 552 | pub zar: Option, 553 | pub bits: Option, 554 | pub link: Option, 555 | pub sats: Option, 556 | } 557 | 558 | #[derive(Serialize, Deserialize, Debug, Clone)] 559 | pub struct AtlDate { 560 | pub aed: Option, 561 | pub ars: Option, 562 | pub aud: Option, 563 | pub bch: Option, 564 | pub bdt: Option, 565 | pub bhd: Option, 566 | pub bmd: Option, 567 | pub bnb: Option, 568 | pub brl: Option, 569 | pub btc: Option, 570 | pub cad: Option, 571 | pub chf: Option, 572 | pub clp: Option, 573 | pub cny: Option, 574 | pub czk: Option, 575 | pub dkk: Option, 576 | pub dot: Option, 577 | pub eos: Option, 578 | pub eth: Option, 579 | pub eur: Option, 580 | pub gbp: Option, 581 | pub hkd: Option, 582 | pub huf: Option, 583 | pub idr: Option, 584 | pub ils: Option, 585 | pub inr: Option, 586 | pub jpy: Option, 587 | pub krw: Option, 588 | pub kwd: Option, 589 | pub lkr: Option, 590 | pub ltc: Option, 591 | pub mmk: Option, 592 | pub mxn: Option, 593 | pub myr: Option, 594 | pub ngn: Option, 595 | pub nok: Option, 596 | pub nzd: Option, 597 | pub php: Option, 598 | pub pkr: Option, 599 | pub pln: Option, 600 | pub rub: Option, 601 | pub sar: Option, 602 | pub sek: Option, 603 | pub sgd: Option, 604 | pub thb: Option, 605 | #[serde(rename = "try")] 606 | pub try_field: Option, 607 | pub twd: Option, 608 | pub uah: Option, 609 | pub usd: Option, 610 | pub vef: Option, 611 | pub vnd: Option, 612 | pub xag: Option, 613 | pub xau: Option, 614 | pub xdr: Option, 615 | pub xlm: Option, 616 | pub xrp: Option, 617 | pub yfi: Option, 618 | pub zar: Option, 619 | pub bits: Option, 620 | pub link: Option, 621 | pub sats: Option, 622 | } 623 | 624 | #[derive(Serialize, Deserialize, Debug, Clone)] 625 | pub struct FullyDilutedValuation { 626 | pub aed: Option, 627 | pub ars: Option, 628 | pub aud: Option, 629 | pub bch: Option, 630 | pub bdt: Option, 631 | pub bhd: Option, 632 | pub bmd: Option, 633 | pub bnb: Option, 634 | pub brl: Option, 635 | pub btc: Option, 636 | pub cad: Option, 637 | pub chf: Option, 638 | pub clp: Option, 639 | pub cny: Option, 640 | pub czk: Option, 641 | pub dkk: Option, 642 | pub dot: Option, 643 | pub eos: Option, 644 | pub eth: Option, 645 | pub eur: Option, 646 | pub gbp: Option, 647 | pub hkd: Option, 648 | pub huf: Option, 649 | pub idr: Option, 650 | pub ils: Option, 651 | pub inr: Option, 652 | pub jpy: Option, 653 | pub krw: Option, 654 | pub kwd: Option, 655 | pub lkr: Option, 656 | pub ltc: Option, 657 | pub mmk: Option, 658 | pub mxn: Option, 659 | pub myr: Option, 660 | pub ngn: Option, 661 | pub nok: Option, 662 | pub nzd: Option, 663 | pub php: Option, 664 | pub pkr: Option, 665 | pub pln: Option, 666 | pub rub: Option, 667 | pub sar: Option, 668 | pub sek: Option, 669 | pub sgd: Option, 670 | pub thb: Option, 671 | #[serde(rename = "try")] 672 | pub try_field: Option, 673 | pub twd: Option, 674 | pub uah: Option, 675 | pub usd: Option, 676 | pub vef: Option, 677 | pub vnd: Option, 678 | pub xag: Option, 679 | pub xau: Option, 680 | pub xdr: Option, 681 | pub xlm: Option, 682 | pub xrp: Option, 683 | pub yfi: Option, 684 | pub zar: Option, 685 | pub bits: Option, 686 | pub link: Option, 687 | pub sats: Option, 688 | } 689 | 690 | #[derive(Serialize, Deserialize, Debug, Clone)] 691 | pub struct High24H { 692 | pub aed: Option, 693 | pub ars: Option, 694 | pub aud: Option, 695 | pub bch: Option, 696 | pub bdt: Option, 697 | pub bhd: Option, 698 | pub bmd: Option, 699 | pub bnb: Option, 700 | pub brl: Option, 701 | pub btc: Option, 702 | pub cad: Option, 703 | pub chf: Option, 704 | pub clp: Option, 705 | pub cny: Option, 706 | pub czk: Option, 707 | pub dkk: Option, 708 | pub dot: Option, 709 | pub eos: Option, 710 | pub eth: Option, 711 | pub eur: Option, 712 | pub gbp: Option, 713 | pub hkd: Option, 714 | pub huf: Option, 715 | pub idr: Option, 716 | pub ils: Option, 717 | pub inr: Option, 718 | pub jpy: Option, 719 | pub krw: Option, 720 | pub kwd: Option, 721 | pub lkr: Option, 722 | pub ltc: Option, 723 | pub mmk: Option, 724 | pub mxn: Option, 725 | pub myr: Option, 726 | pub ngn: Option, 727 | pub nok: Option, 728 | pub nzd: Option, 729 | pub php: Option, 730 | pub pkr: Option, 731 | pub pln: Option, 732 | pub rub: Option, 733 | pub sar: Option, 734 | pub sek: Option, 735 | pub sgd: Option, 736 | pub thb: Option, 737 | #[serde(rename = "try")] 738 | pub try_field: Option, 739 | pub twd: Option, 740 | pub uah: Option, 741 | pub usd: Option, 742 | pub vef: Option, 743 | pub vnd: Option, 744 | pub xag: Option, 745 | pub xau: Option, 746 | pub xdr: Option, 747 | pub xlm: Option, 748 | pub xrp: Option, 749 | pub yfi: Option, 750 | pub zar: Option, 751 | pub bits: Option, 752 | pub link: Option, 753 | pub sats: Option, 754 | } 755 | 756 | #[derive(Serialize, Deserialize, Debug, Clone)] 757 | pub struct Low24H { 758 | pub aed: Option, 759 | pub ars: Option, 760 | pub aud: Option, 761 | pub bch: Option, 762 | pub bdt: Option, 763 | pub bhd: Option, 764 | pub bmd: Option, 765 | pub bnb: Option, 766 | pub brl: Option, 767 | pub btc: Option, 768 | pub cad: Option, 769 | pub chf: Option, 770 | pub clp: Option, 771 | pub cny: Option, 772 | pub czk: Option, 773 | pub dkk: Option, 774 | pub dot: Option, 775 | pub eos: Option, 776 | pub eth: Option, 777 | pub eur: Option, 778 | pub gbp: Option, 779 | pub hkd: Option, 780 | pub huf: Option, 781 | pub idr: Option, 782 | pub ils: Option, 783 | pub inr: Option, 784 | pub jpy: Option, 785 | pub krw: Option, 786 | pub kwd: Option, 787 | pub lkr: Option, 788 | pub ltc: Option, 789 | pub mmk: Option, 790 | pub mxn: Option, 791 | pub myr: Option, 792 | pub ngn: Option, 793 | pub nok: Option, 794 | pub nzd: Option, 795 | pub php: Option, 796 | pub pkr: Option, 797 | pub pln: Option, 798 | pub rub: Option, 799 | pub sar: Option, 800 | pub sek: Option, 801 | pub sgd: Option, 802 | pub thb: Option, 803 | #[serde(rename = "try")] 804 | pub try_field: Option, 805 | pub twd: Option, 806 | pub uah: Option, 807 | pub usd: Option, 808 | pub vef: Option, 809 | pub vnd: Option, 810 | pub xag: Option, 811 | pub xau: Option, 812 | pub xdr: Option, 813 | pub xlm: Option, 814 | pub xrp: Option, 815 | pub yfi: Option, 816 | pub zar: Option, 817 | pub bits: Option, 818 | pub link: Option, 819 | pub sats: Option, 820 | } 821 | 822 | #[derive(Serialize, Deserialize, Debug, Clone)] 823 | pub struct PriceChange24HInCurrency { 824 | pub aed: Option, 825 | pub ars: Option, 826 | pub aud: Option, 827 | pub bch: Option, 828 | pub bdt: Option, 829 | pub bhd: Option, 830 | pub bmd: Option, 831 | pub bnb: Option, 832 | pub brl: Option, 833 | pub btc: Option, 834 | pub cad: Option, 835 | pub chf: Option, 836 | pub clp: Option, 837 | pub cny: Option, 838 | pub czk: Option, 839 | pub dkk: Option, 840 | pub dot: Option, 841 | pub eos: Option, 842 | pub eth: Option, 843 | pub eur: Option, 844 | pub gbp: Option, 845 | pub hkd: Option, 846 | pub huf: Option, 847 | pub idr: Option, 848 | pub ils: Option, 849 | pub inr: Option, 850 | pub jpy: Option, 851 | pub krw: Option, 852 | pub kwd: Option, 853 | pub lkr: Option, 854 | pub ltc: Option, 855 | pub mmk: Option, 856 | pub mxn: Option, 857 | pub myr: Option, 858 | pub ngn: Option, 859 | pub nok: Option, 860 | pub nzd: Option, 861 | pub php: Option, 862 | pub pkr: Option, 863 | pub pln: Option, 864 | pub rub: Option, 865 | pub sar: Option, 866 | pub sek: Option, 867 | pub sgd: Option, 868 | pub thb: Option, 869 | #[serde(rename = "try")] 870 | pub try_field: Option, 871 | pub twd: Option, 872 | pub uah: Option, 873 | pub usd: Option, 874 | pub vef: Option, 875 | pub vnd: Option, 876 | pub xag: Option, 877 | pub xau: Option, 878 | pub xdr: Option, 879 | pub xlm: Option, 880 | pub xrp: Option, 881 | pub yfi: Option, 882 | pub zar: Option, 883 | pub bits: Option, 884 | pub link: Option, 885 | pub sats: Option, 886 | } 887 | 888 | #[derive(Serialize, Deserialize, Debug, Clone, Default)] 889 | pub struct PriceChangePercentage1HInCurrency { 890 | pub aed: Option, 891 | pub ars: Option, 892 | pub aud: Option, 893 | pub bch: Option, 894 | pub bdt: Option, 895 | pub bhd: Option, 896 | pub bmd: Option, 897 | pub bnb: Option, 898 | pub brl: Option, 899 | pub btc: Option, 900 | pub cad: Option, 901 | pub chf: Option, 902 | pub clp: Option, 903 | pub cny: Option, 904 | pub czk: Option, 905 | pub dkk: Option, 906 | pub dot: Option, 907 | pub eos: Option, 908 | pub eth: Option, 909 | pub eur: Option, 910 | pub gbp: Option, 911 | pub hkd: Option, 912 | pub huf: Option, 913 | pub idr: Option, 914 | pub ils: Option, 915 | pub inr: Option, 916 | pub jpy: Option, 917 | pub krw: Option, 918 | pub kwd: Option, 919 | pub lkr: Option, 920 | pub ltc: Option, 921 | pub mmk: Option, 922 | pub mxn: Option, 923 | pub myr: Option, 924 | pub ngn: Option, 925 | pub nok: Option, 926 | pub nzd: Option, 927 | pub php: Option, 928 | pub pkr: Option, 929 | pub pln: Option, 930 | pub rub: Option, 931 | pub sar: Option, 932 | pub sek: Option, 933 | pub sgd: Option, 934 | pub thb: Option, 935 | #[serde(rename = "try")] 936 | pub try_field: Option, 937 | pub twd: Option, 938 | pub uah: Option, 939 | pub usd: Option, 940 | pub vef: Option, 941 | pub vnd: Option, 942 | pub xag: Option, 943 | pub xau: Option, 944 | pub xdr: Option, 945 | pub xlm: Option, 946 | pub xrp: Option, 947 | pub yfi: Option, 948 | pub zar: Option, 949 | pub bits: Option, 950 | pub link: Option, 951 | pub sats: Option, 952 | } 953 | 954 | #[derive(Serialize, Deserialize, Debug, Clone)] 955 | pub struct PriceChangePercentage24HInCurrency { 956 | pub aed: Option, 957 | pub ars: Option, 958 | pub aud: Option, 959 | pub bch: Option, 960 | pub bdt: Option, 961 | pub bhd: Option, 962 | pub bmd: Option, 963 | pub bnb: Option, 964 | pub brl: Option, 965 | pub btc: Option, 966 | pub cad: Option, 967 | pub chf: Option, 968 | pub clp: Option, 969 | pub cny: Option, 970 | pub czk: Option, 971 | pub dkk: Option, 972 | pub dot: Option, 973 | pub eos: Option, 974 | pub eth: Option, 975 | pub eur: Option, 976 | pub gbp: Option, 977 | pub hkd: Option, 978 | pub huf: Option, 979 | pub idr: Option, 980 | pub ils: Option, 981 | pub inr: Option, 982 | pub jpy: Option, 983 | pub krw: Option, 984 | pub kwd: Option, 985 | pub lkr: Option, 986 | pub ltc: Option, 987 | pub mmk: Option, 988 | pub mxn: Option, 989 | pub myr: Option, 990 | pub ngn: Option, 991 | pub nok: Option, 992 | pub nzd: Option, 993 | pub php: Option, 994 | pub pkr: Option, 995 | pub pln: Option, 996 | pub rub: Option, 997 | pub sar: Option, 998 | pub sek: Option, 999 | pub sgd: Option, 1000 | pub thb: Option, 1001 | #[serde(rename = "try")] 1002 | pub try_field: Option, 1003 | pub twd: Option, 1004 | pub uah: Option, 1005 | pub usd: Option, 1006 | pub vef: Option, 1007 | pub vnd: Option, 1008 | pub xag: Option, 1009 | pub xau: Option, 1010 | pub xdr: Option, 1011 | pub xlm: Option, 1012 | pub xrp: Option, 1013 | pub yfi: Option, 1014 | pub zar: Option, 1015 | pub bits: Option, 1016 | pub link: Option, 1017 | pub sats: Option, 1018 | } 1019 | 1020 | #[derive(Serialize, Deserialize, Debug, Clone)] 1021 | pub struct PriceChangePercentage7DInCurrency { 1022 | pub aed: Option, 1023 | pub ars: Option, 1024 | pub aud: Option, 1025 | pub bch: Option, 1026 | pub bdt: Option, 1027 | pub bhd: Option, 1028 | pub bmd: Option, 1029 | pub bnb: Option, 1030 | pub brl: Option, 1031 | pub btc: Option, 1032 | pub cad: Option, 1033 | pub chf: Option, 1034 | pub clp: Option, 1035 | pub cny: Option, 1036 | pub czk: Option, 1037 | pub dkk: Option, 1038 | pub dot: Option, 1039 | pub eos: Option, 1040 | pub eth: Option, 1041 | pub eur: Option, 1042 | pub gbp: Option, 1043 | pub hkd: Option, 1044 | pub huf: Option, 1045 | pub idr: Option, 1046 | pub ils: Option, 1047 | pub inr: Option, 1048 | pub jpy: Option, 1049 | pub krw: Option, 1050 | pub kwd: Option, 1051 | pub lkr: Option, 1052 | pub ltc: Option, 1053 | pub mmk: Option, 1054 | pub mxn: Option, 1055 | pub myr: Option, 1056 | pub ngn: Option, 1057 | pub nok: Option, 1058 | pub nzd: Option, 1059 | pub php: Option, 1060 | pub pkr: Option, 1061 | pub pln: Option, 1062 | pub rub: Option, 1063 | pub sar: Option, 1064 | pub sek: Option, 1065 | pub sgd: Option, 1066 | pub thb: Option, 1067 | #[serde(rename = "try")] 1068 | pub try_field: Option, 1069 | pub twd: Option, 1070 | pub uah: Option, 1071 | pub usd: Option, 1072 | pub vef: Option, 1073 | pub vnd: Option, 1074 | pub xag: Option, 1075 | pub xau: Option, 1076 | pub xdr: Option, 1077 | pub xlm: Option, 1078 | pub xrp: Option, 1079 | pub yfi: Option, 1080 | pub zar: Option, 1081 | pub bits: Option, 1082 | pub link: Option, 1083 | pub sats: Option, 1084 | } 1085 | 1086 | #[derive(Serialize, Deserialize, Debug, Clone)] 1087 | pub struct PriceChangePercentage14DInCurrency { 1088 | pub aed: Option, 1089 | pub ars: Option, 1090 | pub aud: Option, 1091 | pub bch: Option, 1092 | pub bdt: Option, 1093 | pub bhd: Option, 1094 | pub bmd: Option, 1095 | pub bnb: Option, 1096 | pub brl: Option, 1097 | pub btc: Option, 1098 | pub cad: Option, 1099 | pub chf: Option, 1100 | pub clp: Option, 1101 | pub cny: Option, 1102 | pub czk: Option, 1103 | pub dkk: Option, 1104 | pub dot: Option, 1105 | pub eos: Option, 1106 | pub eth: Option, 1107 | pub eur: Option, 1108 | pub gbp: Option, 1109 | pub hkd: Option, 1110 | pub huf: Option, 1111 | pub idr: Option, 1112 | pub ils: Option, 1113 | pub inr: Option, 1114 | pub jpy: Option, 1115 | pub krw: Option, 1116 | pub kwd: Option, 1117 | pub lkr: Option, 1118 | pub ltc: Option, 1119 | pub mmk: Option, 1120 | pub mxn: Option, 1121 | pub myr: Option, 1122 | pub ngn: Option, 1123 | pub nok: Option, 1124 | pub nzd: Option, 1125 | pub php: Option, 1126 | pub pkr: Option, 1127 | pub pln: Option, 1128 | pub rub: Option, 1129 | pub sar: Option, 1130 | pub sek: Option, 1131 | pub sgd: Option, 1132 | pub thb: Option, 1133 | #[serde(rename = "try")] 1134 | pub try_field: Option, 1135 | pub twd: Option, 1136 | pub uah: Option, 1137 | pub usd: Option, 1138 | pub vef: Option, 1139 | pub vnd: Option, 1140 | pub xag: Option, 1141 | pub xau: Option, 1142 | pub xdr: Option, 1143 | pub xlm: Option, 1144 | pub xrp: Option, 1145 | pub yfi: Option, 1146 | pub zar: Option, 1147 | pub bits: Option, 1148 | pub link: Option, 1149 | pub sats: Option, 1150 | } 1151 | 1152 | #[derive(Serialize, Deserialize, Debug, Clone)] 1153 | pub struct PriceChangePercentage30DInCurrency { 1154 | pub aed: Option, 1155 | pub ars: Option, 1156 | pub aud: Option, 1157 | pub bch: Option, 1158 | pub bdt: Option, 1159 | pub bhd: Option, 1160 | pub bmd: Option, 1161 | pub bnb: Option, 1162 | pub brl: Option, 1163 | pub btc: Option, 1164 | pub cad: Option, 1165 | pub chf: Option, 1166 | pub clp: Option, 1167 | pub cny: Option, 1168 | pub czk: Option, 1169 | pub dkk: Option, 1170 | pub dot: Option, 1171 | pub eos: Option, 1172 | pub eth: Option, 1173 | pub eur: Option, 1174 | pub gbp: Option, 1175 | pub hkd: Option, 1176 | pub huf: Option, 1177 | pub idr: Option, 1178 | pub ils: Option, 1179 | pub inr: Option, 1180 | pub jpy: Option, 1181 | pub krw: Option, 1182 | pub kwd: Option, 1183 | pub lkr: Option, 1184 | pub ltc: Option, 1185 | pub mmk: Option, 1186 | pub mxn: Option, 1187 | pub myr: Option, 1188 | pub ngn: Option, 1189 | pub nok: Option, 1190 | pub nzd: Option, 1191 | pub php: Option, 1192 | pub pkr: Option, 1193 | pub pln: Option, 1194 | pub rub: Option, 1195 | pub sar: Option, 1196 | pub sek: Option, 1197 | pub sgd: Option, 1198 | pub thb: Option, 1199 | #[serde(rename = "try")] 1200 | pub try_field: Option, 1201 | pub twd: Option, 1202 | pub uah: Option, 1203 | pub usd: Option, 1204 | pub vef: Option, 1205 | pub vnd: Option, 1206 | pub xag: Option, 1207 | pub xau: Option, 1208 | pub xdr: Option, 1209 | pub xlm: Option, 1210 | pub xrp: Option, 1211 | pub yfi: Option, 1212 | pub zar: Option, 1213 | pub bits: Option, 1214 | pub link: Option, 1215 | pub sats: Option, 1216 | } 1217 | 1218 | #[derive(Serialize, Deserialize, Debug, Clone)] 1219 | pub struct PriceChangePercentage60DInCurrency { 1220 | pub aed: Option, 1221 | pub ars: Option, 1222 | pub aud: Option, 1223 | pub bch: Option, 1224 | pub bdt: Option, 1225 | pub bhd: Option, 1226 | pub bmd: Option, 1227 | pub bnb: Option, 1228 | pub brl: Option, 1229 | pub btc: Option, 1230 | pub cad: Option, 1231 | pub chf: Option, 1232 | pub clp: Option, 1233 | pub cny: Option, 1234 | pub czk: Option, 1235 | pub dkk: Option, 1236 | pub dot: Option, 1237 | pub eos: Option, 1238 | pub eth: Option, 1239 | pub eur: Option, 1240 | pub gbp: Option, 1241 | pub hkd: Option, 1242 | pub huf: Option, 1243 | pub idr: Option, 1244 | pub ils: Option, 1245 | pub inr: Option, 1246 | pub jpy: Option, 1247 | pub krw: Option, 1248 | pub kwd: Option, 1249 | pub lkr: Option, 1250 | pub ltc: Option, 1251 | pub mmk: Option, 1252 | pub mxn: Option, 1253 | pub myr: Option, 1254 | pub ngn: Option, 1255 | pub nok: Option, 1256 | pub nzd: Option, 1257 | pub php: Option, 1258 | pub pkr: Option, 1259 | pub pln: Option, 1260 | pub rub: Option, 1261 | pub sar: Option, 1262 | pub sek: Option, 1263 | pub sgd: Option, 1264 | pub thb: Option, 1265 | #[serde(rename = "try")] 1266 | pub try_field: Option, 1267 | pub twd: Option, 1268 | pub uah: Option, 1269 | pub usd: Option, 1270 | pub vef: Option, 1271 | pub vnd: Option, 1272 | pub xag: Option, 1273 | pub xau: Option, 1274 | pub xdr: Option, 1275 | pub xlm: Option, 1276 | pub xrp: Option, 1277 | pub yfi: Option, 1278 | pub zar: Option, 1279 | pub bits: Option, 1280 | pub link: Option, 1281 | pub sats: Option, 1282 | } 1283 | 1284 | #[derive(Serialize, Deserialize, Debug, Clone)] 1285 | pub struct PriceChangePercentage200DInCurrency { 1286 | pub aed: Option, 1287 | pub ars: Option, 1288 | pub aud: Option, 1289 | pub bch: Option, 1290 | pub bdt: Option, 1291 | pub bhd: Option, 1292 | pub bmd: Option, 1293 | pub bnb: Option, 1294 | pub brl: Option, 1295 | pub btc: Option, 1296 | pub cad: Option, 1297 | pub chf: Option, 1298 | pub clp: Option, 1299 | pub cny: Option, 1300 | pub czk: Option, 1301 | pub dkk: Option, 1302 | pub dot: Option, 1303 | pub eos: Option, 1304 | pub eth: Option, 1305 | pub eur: Option, 1306 | pub gbp: Option, 1307 | pub hkd: Option, 1308 | pub huf: Option, 1309 | pub idr: Option, 1310 | pub ils: Option, 1311 | pub inr: Option, 1312 | pub jpy: Option, 1313 | pub krw: Option, 1314 | pub kwd: Option, 1315 | pub lkr: Option, 1316 | pub ltc: Option, 1317 | pub mmk: Option, 1318 | pub mxn: Option, 1319 | pub myr: Option, 1320 | pub ngn: Option, 1321 | pub nok: Option, 1322 | pub nzd: Option, 1323 | pub php: Option, 1324 | pub pkr: Option, 1325 | pub pln: Option, 1326 | pub rub: Option, 1327 | pub sar: Option, 1328 | pub sek: Option, 1329 | pub sgd: Option, 1330 | pub thb: Option, 1331 | #[serde(rename = "try")] 1332 | pub try_field: Option, 1333 | pub twd: Option, 1334 | pub uah: Option, 1335 | pub usd: Option, 1336 | pub vef: Option, 1337 | pub vnd: Option, 1338 | pub xag: Option, 1339 | pub xau: Option, 1340 | pub xdr: Option, 1341 | pub xlm: Option, 1342 | pub xrp: Option, 1343 | pub yfi: Option, 1344 | pub zar: Option, 1345 | pub bits: Option, 1346 | pub link: Option, 1347 | pub sats: Option, 1348 | } 1349 | 1350 | #[derive(Serialize, Deserialize, Debug, Clone)] 1351 | pub struct PriceChangePercentage1YInCurrency { 1352 | pub aed: Option, 1353 | pub ars: Option, 1354 | pub aud: Option, 1355 | pub bch: Option, 1356 | pub bdt: Option, 1357 | pub bhd: Option, 1358 | pub bmd: Option, 1359 | pub bnb: Option, 1360 | pub brl: Option, 1361 | pub btc: Option, 1362 | pub cad: Option, 1363 | pub chf: Option, 1364 | pub clp: Option, 1365 | pub cny: Option, 1366 | pub czk: Option, 1367 | pub dkk: Option, 1368 | pub eos: Option, 1369 | pub eth: Option, 1370 | pub eur: Option, 1371 | pub gbp: Option, 1372 | pub hkd: Option, 1373 | pub huf: Option, 1374 | pub idr: Option, 1375 | pub ils: Option, 1376 | pub inr: Option, 1377 | pub jpy: Option, 1378 | pub krw: Option, 1379 | pub kwd: Option, 1380 | pub lkr: Option, 1381 | pub ltc: Option, 1382 | pub mmk: Option, 1383 | pub mxn: Option, 1384 | pub myr: Option, 1385 | pub ngn: Option, 1386 | pub nok: Option, 1387 | pub nzd: Option, 1388 | pub php: Option, 1389 | pub pkr: Option, 1390 | pub pln: Option, 1391 | pub rub: Option, 1392 | pub sar: Option, 1393 | pub sek: Option, 1394 | pub sgd: Option, 1395 | pub thb: Option, 1396 | #[serde(rename = "try")] 1397 | pub try_field: Option, 1398 | pub twd: Option, 1399 | pub uah: Option, 1400 | pub usd: Option, 1401 | pub vef: Option, 1402 | pub vnd: Option, 1403 | pub xag: Option, 1404 | pub xau: Option, 1405 | pub xdr: Option, 1406 | pub xlm: Option, 1407 | pub xrp: Option, 1408 | pub zar: Option, 1409 | pub bits: Option, 1410 | pub link: Option, 1411 | pub sats: Option, 1412 | } 1413 | 1414 | #[derive(Serialize, Deserialize, Debug, Clone)] 1415 | pub struct MarketCapChange24HInCurrency { 1416 | pub aed: Option, 1417 | pub ars: Option, 1418 | pub aud: Option, 1419 | pub bch: Option, 1420 | pub bdt: Option, 1421 | pub bhd: Option, 1422 | pub bmd: Option, 1423 | pub bnb: Option, 1424 | pub brl: Option, 1425 | pub btc: Option, 1426 | pub cad: Option, 1427 | pub chf: Option, 1428 | pub clp: Option, 1429 | pub cny: Option, 1430 | pub czk: Option, 1431 | pub dkk: Option, 1432 | pub dot: Option, 1433 | pub eos: Option, 1434 | pub eth: Option, 1435 | pub eur: Option, 1436 | pub gbp: Option, 1437 | pub hkd: Option, 1438 | pub huf: Option, 1439 | pub idr: Option, 1440 | pub ils: Option, 1441 | pub inr: Option, 1442 | pub jpy: Option, 1443 | pub krw: Option, 1444 | pub kwd: Option, 1445 | pub lkr: Option, 1446 | pub ltc: Option, 1447 | pub mmk: Option, 1448 | pub mxn: Option, 1449 | pub myr: Option, 1450 | pub ngn: Option, 1451 | pub nok: Option, 1452 | pub nzd: Option, 1453 | pub php: Option, 1454 | pub pkr: Option, 1455 | pub pln: Option, 1456 | pub rub: Option, 1457 | pub sar: Option, 1458 | pub sek: Option, 1459 | pub sgd: Option, 1460 | pub thb: Option, 1461 | #[serde(rename = "try")] 1462 | pub try_field: Option, 1463 | pub twd: Option, 1464 | pub uah: Option, 1465 | pub usd: Option, 1466 | pub vef: Option, 1467 | pub vnd: Option, 1468 | pub xag: Option, 1469 | pub xau: Option, 1470 | pub xdr: Option, 1471 | pub xlm: Option, 1472 | pub xrp: Option, 1473 | pub yfi: Option, 1474 | pub zar: Option, 1475 | pub bits: Option, 1476 | pub link: Option, 1477 | pub sats: Option, 1478 | } 1479 | 1480 | #[derive(Serialize, Deserialize, Debug, Clone)] 1481 | pub struct MarketCapChangePercentage24HInCurrency { 1482 | pub aed: Option, 1483 | pub ars: Option, 1484 | pub aud: Option, 1485 | pub bch: Option, 1486 | pub bdt: Option, 1487 | pub bhd: Option, 1488 | pub bmd: Option, 1489 | pub bnb: Option, 1490 | pub brl: Option, 1491 | pub btc: Option, 1492 | pub cad: Option, 1493 | pub chf: Option, 1494 | pub clp: Option, 1495 | pub cny: Option, 1496 | pub czk: Option, 1497 | pub dkk: Option, 1498 | pub dot: Option, 1499 | pub eos: Option, 1500 | pub eth: Option, 1501 | pub eur: Option, 1502 | pub gbp: Option, 1503 | pub hkd: Option, 1504 | pub huf: Option, 1505 | pub idr: Option, 1506 | pub ils: Option, 1507 | pub inr: Option, 1508 | pub jpy: Option, 1509 | pub krw: Option, 1510 | pub kwd: Option, 1511 | pub lkr: Option, 1512 | pub ltc: Option, 1513 | pub mmk: Option, 1514 | pub mxn: Option, 1515 | pub myr: Option, 1516 | pub ngn: Option, 1517 | pub nok: Option, 1518 | pub nzd: Option, 1519 | pub php: Option, 1520 | pub pkr: Option, 1521 | pub pln: Option, 1522 | pub rub: Option, 1523 | pub sar: Option, 1524 | pub sek: Option, 1525 | pub sgd: Option, 1526 | pub thb: Option, 1527 | #[serde(rename = "try")] 1528 | pub try_field: Option, 1529 | pub twd: Option, 1530 | pub uah: Option, 1531 | pub usd: Option, 1532 | pub vef: Option, 1533 | pub vnd: Option, 1534 | pub xag: Option, 1535 | pub xau: Option, 1536 | pub xdr: Option, 1537 | pub xlm: Option, 1538 | pub xrp: Option, 1539 | pub yfi: Option, 1540 | pub zar: Option, 1541 | pub bits: Option, 1542 | pub link: Option, 1543 | pub sats: Option, 1544 | } 1545 | 1546 | #[derive(Serialize, Deserialize, Debug, Clone)] 1547 | pub struct Sparkline7D { 1548 | pub price: Vec, 1549 | } 1550 | 1551 | // --------------------------------------------- 1552 | // /coins/{id}/history 1553 | // --------------------------------------------- 1554 | #[derive(Serialize, Deserialize, Debug, Clone)] 1555 | pub struct History { 1556 | pub id: String, 1557 | pub symbol: String, 1558 | pub name: String, 1559 | pub localization: Option, 1560 | pub image: Image, 1561 | pub market_data: Option, 1562 | pub community_data: Option, 1563 | pub developer_data: Option, 1564 | pub public_interest_stats: Option, 1565 | } 1566 | 1567 | #[derive(Serialize, Deserialize, Debug, Clone)] 1568 | pub struct HistoryMarketData { 1569 | pub current_price: CurrentPrice, 1570 | pub market_cap: MarketCap, 1571 | pub total_volume: TotalVolume, 1572 | } 1573 | 1574 | // --------------------------------------------- 1575 | // /coins/{id}/market_chart 1576 | // --------------------------------------------- 1577 | #[derive(Serialize, Deserialize, Debug, Clone)] 1578 | pub struct MarketChart { 1579 | pub prices: Vec>, 1580 | pub market_caps: Vec>, 1581 | pub total_volumes: Vec>, 1582 | } 1583 | 1584 | // --------------------------------------------- 1585 | // /coins/top_gainers_losers?vs_currency={}&duration={}&top_coins={} 1586 | // --------------------------------------------- 1587 | #[derive(Debug, Serialize, Deserialize)] 1588 | pub struct TopGainerLoserCoin { 1589 | pub id: String, 1590 | pub symbol: String, 1591 | pub name: String, 1592 | pub image: String, 1593 | pub market_cap_rank: u32, 1594 | pub usd: f64, 1595 | pub usd_24h_vol: f64, 1596 | pub usd_24h_change: f64, 1597 | } 1598 | 1599 | #[derive(Debug, Serialize, Deserialize)] 1600 | pub struct TopGainersLosers { 1601 | pub top_gainers: Vec, 1602 | pub top_losers: Vec, 1603 | } 1604 | 1605 | // --------------------------------------------- 1606 | // /coins/{id}/contract/{contract_address} 1607 | // --------------------------------------------- 1608 | #[derive(Serialize, Deserialize, Debug, Clone)] 1609 | pub struct Contract { 1610 | pub id: String, 1611 | pub symbol: String, 1612 | pub name: String, 1613 | pub asset_platform_id: String, 1614 | pub platforms: Option>>, 1615 | pub block_time_in_minutes: i64, 1616 | pub hashing_algorithm: ::serde_json::Value, 1617 | pub categories: Vec, 1618 | pub public_notice: ::serde_json::Value, 1619 | pub additional_notices: Vec<::serde_json::Value>, 1620 | pub localization: Localization, 1621 | pub description: Description, 1622 | pub links: Links, 1623 | pub image: Image, 1624 | pub country_origin: String, 1625 | pub genesis_date: ::serde_json::Value, 1626 | pub contract_address: String, 1627 | pub sentiment_votes_up_percentage: Value, 1628 | pub sentiment_votes_down_percentage: Value, 1629 | pub market_cap_rank: Value, 1630 | pub coingecko_rank: i64, 1631 | pub coingecko_score: f64, 1632 | pub developer_score: Value, 1633 | pub community_score: f64, 1634 | pub liquidity_score: f64, 1635 | pub public_interest_score: f64, 1636 | pub market_data: MarketData, 1637 | pub community_data: CommunityData, 1638 | pub developer_data: DeveloperData, 1639 | pub public_interest_stats: PublicInterestStats, 1640 | pub status_updates: Vec<::serde_json::Value>, 1641 | pub last_updated: String, 1642 | pub tickers: Vec, 1643 | } 1644 | 1645 | // --------------------------------------------- 1646 | // /coins/categories/list 1647 | // --------------------------------------------- 1648 | #[derive(Serialize, Deserialize, Debug, Clone)] 1649 | pub struct CategoryId { 1650 | pub category_id: String, 1651 | pub name: String, 1652 | } 1653 | 1654 | // --------------------------------------------- 1655 | // /coins/categories 1656 | // --------------------------------------------- 1657 | #[derive(Serialize, Deserialize, Debug, Clone)] 1658 | pub struct Category { 1659 | pub id: String, 1660 | pub name: String, 1661 | pub market_cap: f64, 1662 | #[serde(rename = "market_cap_change_24h")] 1663 | pub market_cap_change24_h: f64, 1664 | #[serde(rename = "volume_24h")] 1665 | pub volume24_h: f64, 1666 | pub updated_at: String, 1667 | } 1668 | -------------------------------------------------------------------------------- /src/response/common.rs: -------------------------------------------------------------------------------- 1 | #![allow(missing_docs)] 2 | use serde::{Deserialize, Serialize}; 3 | use serde_json::Value; 4 | 5 | #[derive(Serialize, Deserialize, Debug, Clone)] 6 | pub struct Localization { 7 | pub en: Option, 8 | pub de: Option, 9 | pub es: Option, 10 | pub fr: Option, 11 | pub it: Option, 12 | pub pl: Option, 13 | pub ro: Option, 14 | pub hu: Option, 15 | pub nl: Option, 16 | pub pt: Option, 17 | pub sv: Option, 18 | pub vi: Option, 19 | pub tr: Option, 20 | pub ru: Option, 21 | pub ja: Option, 22 | pub zh: Option, 23 | #[serde(rename = "zh-tw")] 24 | pub zh_tw: Option, 25 | pub ko: Option, 26 | pub ar: Option, 27 | pub th: Option, 28 | pub id: Option, 29 | } 30 | 31 | #[derive(Serialize, Deserialize, Default, Debug, Clone)] 32 | pub struct Image { 33 | pub thumb: Option, 34 | pub small: Option, 35 | pub large: Option, 36 | } 37 | 38 | #[derive(Serialize, Deserialize, Debug, Clone)] 39 | pub struct CurrentPrice { 40 | pub aed: Option, 41 | pub ars: Option, 42 | pub aud: Option, 43 | pub bch: Option, 44 | pub bdt: Option, 45 | pub bhd: Option, 46 | pub bmd: Option, 47 | pub bnb: Option, 48 | pub brl: Option, 49 | pub btc: Option, 50 | pub cad: Option, 51 | pub chf: Option, 52 | pub clp: Option, 53 | pub cny: Option, 54 | pub czk: Option, 55 | pub dkk: Option, 56 | pub dot: Option, 57 | pub eos: Option, 58 | pub eth: Option, 59 | pub eur: Option, 60 | pub gbp: Option, 61 | pub hkd: Option, 62 | pub huf: Option, 63 | pub idr: Option, 64 | pub ils: Option, 65 | pub inr: Option, 66 | pub jpy: Option, 67 | pub krw: Option, 68 | pub kwd: Option, 69 | pub lkr: Option, 70 | pub ltc: Option, 71 | pub mmk: Option, 72 | pub mxn: Option, 73 | pub myr: Option, 74 | pub ngn: Option, 75 | pub nok: Option, 76 | pub nzd: Option, 77 | pub php: Option, 78 | pub pkr: Option, 79 | pub pln: Option, 80 | pub rub: Option, 81 | pub sar: Option, 82 | pub sek: Option, 83 | pub sgd: Option, 84 | pub thb: Option, 85 | #[serde(rename = "try")] 86 | pub try_field: Option, 87 | pub twd: Option, 88 | pub uah: Option, 89 | pub usd: Option, 90 | pub vef: Option, 91 | pub vnd: Option, 92 | pub xag: Option, 93 | pub xau: Option, 94 | pub xdr: Option, 95 | pub xlm: Option, 96 | pub xrp: Option, 97 | pub yfi: Option, 98 | pub zar: Option, 99 | pub bits: Option, 100 | pub link: Option, 101 | pub sats: Option, 102 | } 103 | 104 | #[derive(Serialize, Deserialize, Debug, Clone)] 105 | pub struct MarketCap { 106 | pub aed: Option, 107 | pub ars: Option, 108 | pub aud: Option, 109 | pub bch: Option, 110 | pub bdt: Option, 111 | pub bhd: Option, 112 | pub bmd: Option, 113 | pub bnb: Option, 114 | pub brl: Option, 115 | pub btc: Option, 116 | pub cad: Option, 117 | pub chf: Option, 118 | pub clp: Option, 119 | pub cny: Option, 120 | pub czk: Option, 121 | pub dkk: Option, 122 | pub dot: Option, 123 | pub eos: Option, 124 | pub eth: Option, 125 | pub eur: Option, 126 | pub gbp: Option, 127 | pub hkd: Option, 128 | pub huf: Option, 129 | pub idr: Option, 130 | pub ils: Option, 131 | pub inr: Option, 132 | pub jpy: Option, 133 | pub krw: Option, 134 | pub kwd: Option, 135 | pub lkr: Option, 136 | pub ltc: Option, 137 | pub mmk: Option, 138 | pub mxn: Option, 139 | pub myr: Option, 140 | pub ngn: Option, 141 | pub nok: Option, 142 | pub nzd: Option, 143 | pub php: Option, 144 | pub pkr: Option, 145 | pub pln: Option, 146 | pub rub: Option, 147 | pub sar: Option, 148 | pub sek: Option, 149 | pub sgd: Option, 150 | pub thb: Option, 151 | #[serde(rename = "try")] 152 | pub try_field: Option, 153 | pub twd: Option, 154 | pub uah: Option, 155 | pub usd: Option, 156 | pub vef: Option, 157 | pub vnd: Option, 158 | pub xag: Option, 159 | pub xau: Option, 160 | pub xdr: Option, 161 | pub xlm: Option, 162 | pub xrp: Option, 163 | pub yfi: Option, 164 | pub zar: Option, 165 | pub bits: Option, 166 | pub link: Option, 167 | pub sats: Option, 168 | } 169 | 170 | #[derive(Serialize, Deserialize, Debug, Clone)] 171 | pub struct TotalVolume { 172 | pub aed: Option, 173 | pub ars: Option, 174 | pub aud: Option, 175 | pub bch: Option, 176 | pub bdt: Option, 177 | pub bhd: Option, 178 | pub bmd: Option, 179 | pub bnb: Option, 180 | pub brl: Option, 181 | pub btc: Option, 182 | pub cad: Option, 183 | pub chf: Option, 184 | pub clp: Option, 185 | pub cny: Option, 186 | pub czk: Option, 187 | pub dkk: Option, 188 | pub dot: Option, 189 | pub eos: Option, 190 | pub eth: Option, 191 | pub eur: Option, 192 | pub gbp: Option, 193 | pub hkd: Option, 194 | pub huf: Option, 195 | pub idr: Option, 196 | pub ils: Option, 197 | pub inr: Option, 198 | pub jpy: Option, 199 | pub krw: Option, 200 | pub kwd: Option, 201 | pub lkr: Option, 202 | pub ltc: Option, 203 | pub mmk: Option, 204 | pub mxn: Option, 205 | pub myr: Option, 206 | pub ngn: Option, 207 | pub nok: Option, 208 | pub nzd: Option, 209 | pub php: Option, 210 | pub pkr: Option, 211 | pub pln: Option, 212 | pub rub: Option, 213 | pub sar: Option, 214 | pub sek: Option, 215 | pub sgd: Option, 216 | pub thb: Option, 217 | #[serde(rename = "try")] 218 | pub try_field: Option, 219 | pub twd: Option, 220 | pub uah: Option, 221 | pub usd: Option, 222 | pub vef: Option, 223 | pub vnd: Option, 224 | pub xag: Option, 225 | pub xau: Option, 226 | pub xdr: Option, 227 | pub xlm: Option, 228 | pub xrp: Option, 229 | pub yfi: Option, 230 | pub zar: Option, 231 | pub bits: Option, 232 | pub link: Option, 233 | pub sats: Option, 234 | } 235 | 236 | #[derive(Serialize, Deserialize, Debug, Clone)] 237 | pub struct CommunityData { 238 | pub facebook_likes: Option, 239 | pub twitter_followers: Option, 240 | #[serde(rename = "reddit_average_posts_48h")] 241 | pub reddit_average_posts48_h: Option, 242 | #[serde(rename = "reddit_average_comments_48h")] 243 | pub reddit_average_comments48_h: Option, 244 | pub reddit_subscribers: Option, 245 | #[serde(rename = "reddit_accounts_active_48h")] 246 | pub reddit_accounts_active48_h: Option, 247 | pub telegram_channel_user_count: Option, 248 | } 249 | 250 | #[derive(Serialize, Deserialize, Debug, Clone)] 251 | pub struct DeveloperData { 252 | pub forks: Option, 253 | pub stars: Option, 254 | pub subscribers: Option, 255 | pub total_issues: Option, 256 | pub closed_issues: Option, 257 | pub pull_requests_merged: Option, 258 | pub pull_request_contributors: Option, 259 | #[serde(rename = "code_additions_deletions_4_weeks")] 260 | pub code_additions_deletions4_weeks: CodeAdditionsDeletions4Weeks, 261 | #[serde(rename = "commit_count_4_weeks")] 262 | pub commit_count4_weeks: Option, 263 | #[serde(rename = "last_4_weeks_commit_activity_series")] 264 | pub last4_weeks_commit_activity_series: Option>, 265 | } 266 | 267 | #[derive(Serialize, Deserialize, Debug, Clone)] 268 | pub struct PublicInterestStats { 269 | pub alexa_rank: Option, 270 | pub bing_matches: Option, 271 | } 272 | 273 | #[derive(Serialize, Deserialize, Debug, Clone)] 274 | pub struct CodeAdditionsDeletions4Weeks { 275 | pub additions: Option, 276 | pub deletions: Option, 277 | } 278 | 279 | #[derive(Serialize, Deserialize, Default, Debug, Clone)] 280 | pub struct Links { 281 | pub homepage: Vec, 282 | pub blockchain_site: Vec, 283 | pub official_forum_url: Vec, 284 | pub chat_url: Vec, 285 | pub announcement_url: Vec, 286 | pub twitter_screen_name: Value, 287 | pub facebook_username: Value, 288 | pub bitcointalk_thread_identifier: Value, 289 | pub telegram_channel_identifier: Value, 290 | pub subreddit_url: Value, 291 | pub repos_url: ReposUrl, 292 | } 293 | 294 | #[derive(Serialize, Deserialize, Default, Debug, Clone)] 295 | pub struct ReposUrl { 296 | pub github: Vec, 297 | pub bitbucket: Vec, 298 | } 299 | 300 | #[derive(Serialize, Deserialize, Debug, Clone)] 301 | pub struct Tickers { 302 | pub name: String, 303 | pub tickers: Vec, 304 | } 305 | 306 | #[derive(Serialize, Deserialize, Debug, Clone)] 307 | pub struct Ticker { 308 | pub base: String, 309 | pub target: String, 310 | pub market: Market, 311 | pub last: f64, 312 | pub volume: f64, 313 | pub converted_last: ConvertedLast, 314 | pub converted_volume: ConvertedVolume, 315 | pub cost_to_move_up_usd: Option, 316 | pub cost_to_move_down_usd: Option, 317 | pub trust_score: Option, 318 | pub bid_ask_spread_percentage: Option, 319 | pub timestamp: Option, 320 | pub last_traded_at: Option, 321 | pub last_fetch_at: Option, 322 | pub is_anomaly: bool, 323 | pub is_stale: bool, 324 | pub trade_url: Option, 325 | pub token_info_url: Option, 326 | pub coin_id: String, 327 | pub target_coin_id: Option, 328 | } 329 | 330 | #[derive(Serialize, Deserialize, Debug, Clone)] 331 | pub struct Market { 332 | pub name: String, 333 | pub identifier: String, 334 | pub has_trading_incentive: bool, 335 | pub logo: Option, 336 | } 337 | 338 | #[derive(Serialize, Deserialize, Debug, Clone)] 339 | pub struct ConvertedLast { 340 | pub btc: f64, 341 | pub eth: f64, 342 | pub usd: f64, 343 | } 344 | 345 | #[derive(Serialize, Deserialize, Debug, Clone)] 346 | pub struct ConvertedVolume { 347 | pub btc: f64, 348 | pub eth: f64, 349 | pub usd: f64, 350 | } 351 | 352 | #[derive(Serialize, Deserialize, Debug, Clone)] 353 | pub struct StatusUpdates { 354 | pub status_updates: Vec, 355 | } 356 | 357 | #[derive(Serialize, Deserialize, Debug, Clone)] 358 | pub struct StatusUpdate { 359 | pub description: Option, 360 | pub category: Option, 361 | pub created_at: Option, 362 | pub user: Option, 363 | pub user_title: Option, 364 | pub pin: Option, 365 | pub project: Option, 366 | } 367 | 368 | #[derive(Serialize, Deserialize, Debug, Clone)] 369 | pub struct Project { 370 | #[serde(rename = "type")] 371 | pub type_field: Option, 372 | pub id: Option, 373 | pub name: Option, 374 | pub symbol: Option, 375 | pub image: Image, 376 | } 377 | -------------------------------------------------------------------------------- /src/response/companies.rs: -------------------------------------------------------------------------------- 1 | #![allow(missing_docs)] 2 | use serde::{Deserialize, Serialize}; 3 | 4 | // --------------------------------------------- 5 | // /companies/public_treasury/{coin_id} 6 | // --------------------------------------------- 7 | #[derive(Serialize, Deserialize, Debug, Clone)] 8 | pub struct CompaniesPublicTreasury { 9 | pub total_holdings: f64, 10 | pub total_value_usd: f64, 11 | pub market_cap_dominance: f64, 12 | pub companies: Vec, 13 | } 14 | 15 | #[derive(Serialize, Deserialize, Debug, Clone)] 16 | pub struct Company { 17 | pub name: String, 18 | pub symbol: String, 19 | pub country: String, 20 | pub total_holdings: f64, 21 | pub total_entry_value_usd: f64, 22 | pub total_current_value_usd: f64, 23 | pub percentage_of_total_supply: f64, 24 | } 25 | -------------------------------------------------------------------------------- /src/response/derivatives.rs: -------------------------------------------------------------------------------- 1 | #![allow(missing_docs)] 2 | use super::common::{ConvertedLast, ConvertedVolume}; 3 | use serde::{Deserialize, Serialize}; 4 | 5 | // --------------------------------------------- 6 | // /derivatives 7 | // --------------------------------------------- 8 | 9 | #[derive(Serialize, Deserialize, Debug, Clone)] 10 | pub struct Derivative { 11 | pub market: String, 12 | pub symbol: String, 13 | pub index_id: String, 14 | pub price: String, 15 | #[serde(rename = "price_percentage_change_24h")] 16 | pub price_percentage_change24_h: f64, 17 | pub contract_type: String, 18 | pub index: Option, 19 | pub basis: f64, 20 | pub spread: Option, 21 | pub funding_rate: f64, 22 | pub open_interest: Option, 23 | #[serde(rename = "volume_24h")] 24 | pub volume24_h: f64, 25 | pub last_traded_at: i64, 26 | pub expired_at: Option, 27 | } 28 | 29 | #[derive(Serialize, Deserialize, Debug, Clone)] 30 | pub struct DerivativeExchange { 31 | pub name: String, 32 | pub id: String, 33 | pub open_interest_btc: Option, 34 | #[serde(rename = "trade_volume_24h_btc")] 35 | pub trade_volume24_h_btc: Option, 36 | pub number_of_perpetual_pairs: Option, 37 | pub number_of_futures_pairs: Option, 38 | pub image: Option, 39 | pub year_established: Option, 40 | pub country: Option, 41 | pub description: Option, 42 | pub url: Option, 43 | } 44 | 45 | #[derive(Serialize, Deserialize, Debug, Clone)] 46 | pub struct DerivativeExchangeData { 47 | pub name: String, 48 | pub open_interest_btc: f64, 49 | #[serde(rename = "trade_volume_24h_btc")] 50 | pub trade_volume24_h_btc: String, 51 | pub number_of_perpetual_pairs: i64, 52 | pub number_of_futures_pairs: i64, 53 | pub image: String, 54 | pub year_established: Option, 55 | pub country: String, 56 | pub description: String, 57 | pub url: String, 58 | pub tickers: Vec, 59 | } 60 | 61 | #[derive(Serialize, Deserialize, Debug, Clone)] 62 | pub struct DerivativeExchangeTicker { 63 | pub symbol: String, 64 | pub base: String, 65 | pub target: String, 66 | pub trade_url: String, 67 | pub contract_type: String, 68 | pub last: f64, 69 | pub h24_percentage_change: f64, 70 | pub index: Option, 71 | pub index_basis_percentage: f64, 72 | pub bid_ask_spread: f64, 73 | pub funding_rate: f64, 74 | pub open_interest_usd: f64, 75 | pub h24_volume: f64, 76 | pub converted_volume: ConvertedVolume, 77 | pub converted_last: ConvertedLast, 78 | pub last_traded: i64, 79 | pub expired_at: Option, 80 | } 81 | 82 | #[derive(Serialize, Deserialize, Debug, Clone)] 83 | pub struct DerivativeExchangeId { 84 | pub name: String, 85 | pub id: String, 86 | } 87 | -------------------------------------------------------------------------------- /src/response/events.rs: -------------------------------------------------------------------------------- 1 | #![allow(missing_docs)] 2 | use serde::{Deserialize, Serialize}; 3 | 4 | // --------------------------------------------- 5 | // /events 6 | // --------------------------------------------- 7 | #[derive(Serialize, Deserialize, Debug, Clone)] 8 | pub struct Events { 9 | pub data: Vec, 10 | pub count: i64, 11 | pub page: i64, 12 | } 13 | #[derive(Serialize, Deserialize, Debug, Clone)] 14 | pub struct Event { 15 | #[serde(rename = "type")] 16 | pub type_field: String, 17 | pub title: String, 18 | pub description: String, 19 | pub organizer: String, 20 | pub start_date: String, 21 | pub end_date: String, 22 | pub website: String, 23 | pub email: String, 24 | pub venue: String, 25 | pub address: String, 26 | pub city: String, 27 | pub country: String, 28 | pub screenshot: String, 29 | } 30 | // --------------------------------------------- 31 | // /events/countries 32 | // --------------------------------------------- 33 | #[derive(Serialize, Deserialize, Debug, Clone)] 34 | pub struct EventCountries { 35 | pub data: Vec, 36 | pub count: i64, 37 | } 38 | 39 | #[derive(Serialize, Deserialize, Debug, Clone)] 40 | pub struct Country { 41 | pub country: Option, 42 | pub code: String, 43 | } 44 | 45 | // --------------------------------------------- 46 | // /events/types 47 | // --------------------------------------------- 48 | #[derive(Serialize, Deserialize, Debug, Clone)] 49 | pub struct EventTypes { 50 | pub data: Vec, 51 | pub count: i64, 52 | } 53 | -------------------------------------------------------------------------------- /src/response/exchange_rates.rs: -------------------------------------------------------------------------------- 1 | #![allow(missing_docs)] 2 | use serde::{Deserialize, Serialize}; 3 | use std::collections::HashMap; 4 | 5 | // --------------------------------------------- 6 | // /exchange_rates 7 | // --------------------------------------------- 8 | #[derive(Serialize, Deserialize, Debug, Clone)] 9 | pub struct ExchangeRates { 10 | pub rates: HashMap, 11 | } 12 | #[derive(Serialize, Deserialize, Debug, Clone)] 13 | pub struct ExchangeRateData { 14 | pub name: String, 15 | pub unit: String, 16 | pub value: f64, 17 | #[serde(rename = "type")] 18 | pub type_field: String, 19 | } 20 | -------------------------------------------------------------------------------- /src/response/exchanges.rs: -------------------------------------------------------------------------------- 1 | #![allow(missing_docs)] 2 | use serde::{Deserialize, Serialize}; 3 | 4 | // --------------------------------------------- 5 | // /exchanges 6 | // --------------------------------------------- 7 | #[derive(Serialize, Deserialize, Debug, Clone)] 8 | pub struct Exchange { 9 | pub id: String, 10 | pub name: String, 11 | pub year_established: Option, 12 | pub country: Option, 13 | pub description: Option, 14 | pub url: Option, 15 | pub image: Option, 16 | pub has_trading_incentive: Option, 17 | pub trust_score: Option, 18 | pub trust_score_rank: Option, 19 | #[serde(rename = "trade_volume_24h_btc")] 20 | pub trade_volume24_h_btc: Option, 21 | #[serde(rename = "trade_volume_24h_btc_normalized")] 22 | pub trade_volume24_h_btc_normalized: Option, 23 | } 24 | 25 | // --------------------------------------------- 26 | // /exchanges/list 27 | // --------------------------------------------- 28 | #[derive(Serialize, Deserialize, Debug, Clone)] 29 | pub struct ExchangeId { 30 | pub id: String, 31 | pub name: String, 32 | } 33 | 34 | // --------------------------------------------- 35 | // /exchanges/{id}/volume_chart 36 | // --------------------------------------------- 37 | pub type VolumeChartData = Vec<(i64, String)>; 38 | -------------------------------------------------------------------------------- /src/response/finance.rs: -------------------------------------------------------------------------------- 1 | #![allow(missing_docs)] 2 | use serde::{Deserialize, Serialize}; 3 | 4 | // --------------------------------------------- 5 | // /finance_platforms 6 | // --------------------------------------------- 7 | #[derive(Serialize, Deserialize, Debug, Clone)] 8 | pub struct FinancePlatform { 9 | pub name: String, 10 | pub facts: String, 11 | pub category: String, 12 | pub centralized: bool, 13 | pub website_url: String, 14 | } 15 | 16 | // --------------------------------------------- 17 | // /finance_products 18 | // --------------------------------------------- 19 | #[derive(Serialize, Deserialize, Debug, Clone)] 20 | pub struct FinanceProduct { 21 | pub platform: String, 22 | pub identifier: String, 23 | pub supply_rate_percentage: Option, 24 | pub borrow_rate_percentage: Option, 25 | pub number_duration: Option, 26 | pub length_duration: Option, 27 | pub start_at: i64, 28 | pub end_at: i64, 29 | pub value_at: i64, 30 | pub redeem_at: i64, 31 | } 32 | -------------------------------------------------------------------------------- /src/response/global.rs: -------------------------------------------------------------------------------- 1 | #![allow(missing_docs)] 2 | use serde::{Deserialize, Serialize}; 3 | use std::collections::HashMap; 4 | 5 | // --------------------------------------------- 6 | // /global 7 | // --------------------------------------------- 8 | #[derive(Serialize, Deserialize, Debug, Clone)] 9 | pub struct Global { 10 | pub data: GlobalData, 11 | } 12 | #[derive(Serialize, Deserialize, Debug, Clone)] 13 | pub struct GlobalData { 14 | pub active_cryptocurrencies: f64, 15 | pub upcoming_icos: f64, 16 | pub ongoing_icos: f64, 17 | pub ended_icos: f64, 18 | pub markets: f64, 19 | pub total_market_cap: HashMap, 20 | pub total_volume: HashMap, 21 | pub market_cap_percentage: HashMap, 22 | #[serde(rename = "market_cap_change_percentage_24h_usd")] 23 | pub market_cap_change_percentage24_h_usd: f64, 24 | pub updated_at: f64, 25 | } 26 | 27 | // --------------------------------------------- 28 | // /global/decentralized_finance_defi 29 | // --------------------------------------------- 30 | #[derive(Serialize, Deserialize, Debug, Clone)] 31 | pub struct GlobalDefi { 32 | pub data: GlobalDefiData, 33 | } 34 | #[derive(Serialize, Deserialize, Debug, Clone)] 35 | pub struct GlobalDefiData { 36 | pub defi_market_cap: String, 37 | pub eth_market_cap: String, 38 | pub defi_to_eth_ratio: String, 39 | #[serde(rename = "trading_volume_24h")] 40 | pub trading_volume24_h: String, 41 | pub defi_dominance: String, 42 | pub top_coin_name: String, 43 | pub top_coin_defi_dominance: f64, 44 | } 45 | -------------------------------------------------------------------------------- /src/response/indexes.rs: -------------------------------------------------------------------------------- 1 | #![allow(missing_docs)] 2 | use serde::{Deserialize, Serialize}; 3 | 4 | // --------------------------------------------- 5 | // /indexes 6 | // --------------------------------------------- 7 | #[derive(Serialize, Deserialize, Debug, Clone)] 8 | pub struct Index { 9 | pub name: String, 10 | pub id: String, 11 | pub market: String, 12 | pub last: Option, 13 | pub is_multi_asset_composite: Option, 14 | } 15 | 16 | // --------------------------------------------- 17 | // /index/{market_id}/{id} 18 | // --------------------------------------------- 19 | #[derive(Serialize, Deserialize, Debug, Clone)] 20 | pub struct MarketIndex { 21 | pub name: String, 22 | pub market: String, 23 | pub last: Option, 24 | pub is_multi_asset_composite: Option, 25 | } 26 | 27 | // --------------------------------------------- 28 | // /indexes/list 29 | // --------------------------------------------- 30 | #[derive(Serialize, Deserialize, Debug, Clone)] 31 | pub struct IndexId { 32 | pub name: String, 33 | pub id: String, 34 | } 35 | -------------------------------------------------------------------------------- /src/response/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod asset_platforms; 2 | pub mod coins; 3 | pub mod common; 4 | pub mod companies; 5 | pub mod derivatives; 6 | pub mod events; 7 | pub mod exchange_rates; 8 | pub mod exchanges; 9 | pub mod finance; 10 | pub mod global; 11 | pub mod indexes; 12 | pub mod ping; 13 | pub mod simple; 14 | pub mod trending; 15 | -------------------------------------------------------------------------------- /src/response/ping.rs: -------------------------------------------------------------------------------- 1 | #![allow(missing_docs)] 2 | use serde::{Deserialize, Serialize}; 3 | 4 | // --------------------------------------------- 5 | // /ping 6 | // --------------------------------------------- 7 | #[derive(Serialize, Deserialize, Debug, Clone)] 8 | pub struct SimplePing { 9 | pub gecko_says: String, 10 | } 11 | -------------------------------------------------------------------------------- /src/response/simple.rs: -------------------------------------------------------------------------------- 1 | #![allow(missing_docs)] 2 | use serde::{Deserialize, Serialize}; 3 | 4 | // --------------------------------------------- 5 | // /simple/price and /simple/token_price/{id} 6 | // --------------------------------------------- 7 | #[derive(Serialize, Deserialize, Debug, Clone)] 8 | pub struct Price { 9 | pub btc: Option, 10 | pub btc_market_cap: Option, 11 | #[serde(rename = "btc_24h_vol")] 12 | pub btc24_h_vol: Option, 13 | #[serde(rename = "btc_24h_change")] 14 | pub btc24_h_change: Option, 15 | pub eth: Option, 16 | pub eth_market_cap: Option, 17 | #[serde(rename = "eth_24h_vol")] 18 | pub eth24_h_vol: Option, 19 | #[serde(rename = "eth_24h_change")] 20 | pub eth24_h_change: Option, 21 | pub ltc: Option, 22 | pub ltc_market_cap: Option, 23 | #[serde(rename = "ltc_24h_vol")] 24 | pub ltc24_h_vol: Option, 25 | #[serde(rename = "ltc_24h_change")] 26 | pub ltc24_h_change: Option, 27 | pub bch: Option, 28 | pub bch_market_cap: Option, 29 | #[serde(rename = "bch_24h_vol")] 30 | pub bch24_h_vol: Option, 31 | #[serde(rename = "bch_24h_change")] 32 | pub bch24_h_change: Option, 33 | pub bnb: Option, 34 | pub bnb_market_cap: Option, 35 | #[serde(rename = "bnb_24h_vol")] 36 | pub bnb24_h_vol: Option, 37 | #[serde(rename = "bnb_24h_change")] 38 | pub bnb24_h_change: Option, 39 | pub eos: Option, 40 | pub eos_market_cap: Option, 41 | #[serde(rename = "eos_24h_vol")] 42 | pub eos24_h_vol: Option, 43 | #[serde(rename = "eos_24h_change")] 44 | pub eos24_h_change: Option, 45 | pub xrp: Option, 46 | pub xrp_market_cap: Option, 47 | #[serde(rename = "xrp_24h_vol")] 48 | pub xrp24_h_vol: Option, 49 | #[serde(rename = "xrp_24h_change")] 50 | pub xrp24_h_change: Option, 51 | pub xlm: Option, 52 | pub xlm_market_cap: Option, 53 | #[serde(rename = "xlm_24h_vol")] 54 | pub xlm24_h_vol: Option, 55 | #[serde(rename = "xlm_24h_change")] 56 | pub xlm24_h_change: Option, 57 | pub link: Option, 58 | pub link_market_cap: Option, 59 | #[serde(rename = "link_24h_vol")] 60 | pub link24_h_vol: Option, 61 | #[serde(rename = "link_24h_change")] 62 | pub link24_h_change: Option, 63 | pub dot: Option, 64 | pub dot_market_cap: Option, 65 | #[serde(rename = "dot_24h_vol")] 66 | pub dot24_h_vol: Option, 67 | #[serde(rename = "dot_24h_change")] 68 | pub dot24_h_change: Option, 69 | pub yfi: Option, 70 | pub yfi_market_cap: Option, 71 | #[serde(rename = "yfi_24h_vol")] 72 | pub yfi24_h_vol: Option, 73 | #[serde(rename = "yfi_24h_change")] 74 | pub yfi24_h_change: Option, 75 | pub usd: Option, 76 | pub usd_market_cap: Option, 77 | #[serde(rename = "usd_24h_vol")] 78 | pub usd24_h_vol: Option, 79 | #[serde(rename = "usd_24h_change")] 80 | pub usd24_h_change: Option, 81 | pub aed: Option, 82 | pub aed_market_cap: Option, 83 | #[serde(rename = "aed_24h_vol")] 84 | pub aed24_h_vol: Option, 85 | #[serde(rename = "aed_24h_change")] 86 | pub aed24_h_change: Option, 87 | pub ars: Option, 88 | pub ars_market_cap: Option, 89 | #[serde(rename = "ars_24h_vol")] 90 | pub ars24_h_vol: Option, 91 | #[serde(rename = "ars_24h_change")] 92 | pub ars24_h_change: Option, 93 | pub aud: Option, 94 | pub aud_market_cap: Option, 95 | #[serde(rename = "aud_24h_vol")] 96 | pub aud24_h_vol: Option, 97 | #[serde(rename = "aud_24h_change")] 98 | pub aud24_h_change: Option, 99 | pub bdt: Option, 100 | pub bdt_market_cap: Option, 101 | #[serde(rename = "bdt_24h_vol")] 102 | pub bdt24_h_vol: Option, 103 | #[serde(rename = "bdt_24h_change")] 104 | pub bdt24_h_change: Option, 105 | pub bhd: Option, 106 | pub bhd_market_cap: Option, 107 | #[serde(rename = "bhd_24h_vol")] 108 | pub bhd24_h_vol: Option, 109 | #[serde(rename = "bhd_24h_change")] 110 | pub bhd24_h_change: Option, 111 | pub bmd: Option, 112 | pub bmd_market_cap: Option, 113 | #[serde(rename = "bmd_24h_vol")] 114 | pub bmd24_h_vol: Option, 115 | #[serde(rename = "bmd_24h_change")] 116 | pub bmd24_h_change: Option, 117 | pub brl: Option, 118 | pub brl_market_cap: Option, 119 | #[serde(rename = "brl_24h_vol")] 120 | pub brl24_h_vol: Option, 121 | #[serde(rename = "brl_24h_change")] 122 | pub brl24_h_change: Option, 123 | pub cad: Option, 124 | pub cad_market_cap: Option, 125 | #[serde(rename = "cad_24h_vol")] 126 | pub cad24_h_vol: Option, 127 | #[serde(rename = "cad_24h_change")] 128 | pub cad24_h_change: Option, 129 | pub chf: Option, 130 | pub chf_market_cap: Option, 131 | #[serde(rename = "chf_24h_vol")] 132 | pub chf24_h_vol: Option, 133 | #[serde(rename = "chf_24h_change")] 134 | pub chf24_h_change: Option, 135 | pub clp: Option, 136 | pub clp_market_cap: Option, 137 | #[serde(rename = "clp_24h_vol")] 138 | pub clp24_h_vol: Option, 139 | #[serde(rename = "clp_24h_change")] 140 | pub clp24_h_change: Option, 141 | pub cny: Option, 142 | pub cny_market_cap: Option, 143 | #[serde(rename = "cny_24h_vol")] 144 | pub cny24_h_vol: Option, 145 | #[serde(rename = "cny_24h_change")] 146 | pub cny24_h_change: Option, 147 | pub czk: Option, 148 | pub czk_market_cap: Option, 149 | #[serde(rename = "czk_24h_vol")] 150 | pub czk24_h_vol: Option, 151 | #[serde(rename = "czk_24h_change")] 152 | pub czk24_h_change: Option, 153 | pub dkk: Option, 154 | pub dkk_market_cap: Option, 155 | #[serde(rename = "dkk_24h_vol")] 156 | pub dkk24_h_vol: Option, 157 | #[serde(rename = "dkk_24h_change")] 158 | pub dkk24_h_change: Option, 159 | pub eur: Option, 160 | pub eur_market_cap: Option, 161 | #[serde(rename = "eur_24h_vol")] 162 | pub eur24_h_vol: Option, 163 | #[serde(rename = "eur_24h_change")] 164 | pub eur24_h_change: Option, 165 | pub gbp: Option, 166 | pub gbp_market_cap: Option, 167 | #[serde(rename = "gbp_24h_vol")] 168 | pub gbp24_h_vol: Option, 169 | #[serde(rename = "gbp_24h_change")] 170 | pub gbp24_h_change: Option, 171 | pub hkd: Option, 172 | pub hkd_market_cap: Option, 173 | #[serde(rename = "hkd_24h_vol")] 174 | pub hkd24_h_vol: Option, 175 | #[serde(rename = "hkd_24h_change")] 176 | pub hkd24_h_change: Option, 177 | pub huf: Option, 178 | pub huf_market_cap: Option, 179 | #[serde(rename = "huf_24h_vol")] 180 | pub huf24_h_vol: Option, 181 | #[serde(rename = "huf_24h_change")] 182 | pub huf24_h_change: Option, 183 | pub idr: Option, 184 | pub idr_market_cap: Option, 185 | #[serde(rename = "idr_24h_vol")] 186 | pub idr24_h_vol: Option, 187 | #[serde(rename = "idr_24h_change")] 188 | pub idr24_h_change: Option, 189 | pub ils: Option, 190 | pub ils_market_cap: Option, 191 | #[serde(rename = "ils_24h_vol")] 192 | pub ils24_h_vol: Option, 193 | #[serde(rename = "ils_24h_change")] 194 | pub ils24_h_change: Option, 195 | pub inr: Option, 196 | pub inr_market_cap: Option, 197 | #[serde(rename = "inr_24h_vol")] 198 | pub inr24_h_vol: Option, 199 | #[serde(rename = "inr_24h_change")] 200 | pub inr24_h_change: Option, 201 | pub jpy: Option, 202 | pub jpy_market_cap: Option, 203 | #[serde(rename = "jpy_24h_vol")] 204 | pub jpy24_h_vol: Option, 205 | #[serde(rename = "jpy_24h_change")] 206 | pub jpy24_h_change: Option, 207 | pub krw: Option, 208 | pub krw_market_cap: Option, 209 | #[serde(rename = "krw_24h_vol")] 210 | pub krw24_h_vol: Option, 211 | #[serde(rename = "krw_24h_change")] 212 | pub krw24_h_change: Option, 213 | pub kwd: Option, 214 | pub kwd_market_cap: Option, 215 | #[serde(rename = "kwd_24h_vol")] 216 | pub kwd24_h_vol: Option, 217 | #[serde(rename = "kwd_24h_change")] 218 | pub kwd24_h_change: Option, 219 | pub lkr: Option, 220 | pub lkr_market_cap: Option, 221 | #[serde(rename = "lkr_24h_vol")] 222 | pub lkr24_h_vol: Option, 223 | #[serde(rename = "lkr_24h_change")] 224 | pub lkr24_h_change: Option, 225 | pub mmk: Option, 226 | pub mmk_market_cap: Option, 227 | #[serde(rename = "mmk_24h_vol")] 228 | pub mmk24_h_vol: Option, 229 | #[serde(rename = "mmk_24h_change")] 230 | pub mmk24_h_change: Option, 231 | pub mxn: Option, 232 | pub mxn_market_cap: Option, 233 | #[serde(rename = "mxn_24h_vol")] 234 | pub mxn24_h_vol: Option, 235 | #[serde(rename = "mxn_24h_change")] 236 | pub mxn24_h_change: Option, 237 | pub myr: Option, 238 | pub myr_market_cap: Option, 239 | #[serde(rename = "myr_24h_vol")] 240 | pub myr24_h_vol: Option, 241 | #[serde(rename = "myr_24h_change")] 242 | pub myr24_h_change: Option, 243 | pub ngn: Option, 244 | pub ngn_market_cap: Option, 245 | #[serde(rename = "ngn_24h_vol")] 246 | pub ngn24_h_vol: Option, 247 | #[serde(rename = "ngn_24h_change")] 248 | pub ngn24_h_change: Option, 249 | pub nok: Option, 250 | pub nok_market_cap: Option, 251 | #[serde(rename = "nok_24h_vol")] 252 | pub nok24_h_vol: Option, 253 | #[serde(rename = "nok_24h_change")] 254 | pub nok24_h_change: Option, 255 | pub nzd: Option, 256 | pub nzd_market_cap: Option, 257 | #[serde(rename = "nzd_24h_vol")] 258 | pub nzd24_h_vol: Option, 259 | #[serde(rename = "nzd_24h_change")] 260 | pub nzd24_h_change: Option, 261 | pub php: Option, 262 | pub php_market_cap: Option, 263 | #[serde(rename = "php_24h_vol")] 264 | pub php24_h_vol: Option, 265 | #[serde(rename = "php_24h_change")] 266 | pub php24_h_change: Option, 267 | pub pkr: Option, 268 | pub pkr_market_cap: Option, 269 | #[serde(rename = "pkr_24h_vol")] 270 | pub pkr24_h_vol: Option, 271 | #[serde(rename = "pkr_24h_change")] 272 | pub pkr24_h_change: Option, 273 | pub pln: Option, 274 | pub pln_market_cap: Option, 275 | #[serde(rename = "pln_24h_vol")] 276 | pub pln24_h_vol: Option, 277 | #[serde(rename = "pln_24h_change")] 278 | pub pln24_h_change: Option, 279 | pub rub: Option, 280 | pub rub_market_cap: Option, 281 | #[serde(rename = "rub_24h_vol")] 282 | pub rub24_h_vol: Option, 283 | #[serde(rename = "rub_24h_change")] 284 | pub rub24_h_change: Option, 285 | pub sar: Option, 286 | pub sar_market_cap: Option, 287 | #[serde(rename = "sar_24h_vol")] 288 | pub sar24_h_vol: Option, 289 | #[serde(rename = "sar_24h_change")] 290 | pub sar24_h_change: Option, 291 | pub sek: Option, 292 | pub sek_market_cap: Option, 293 | #[serde(rename = "sek_24h_vol")] 294 | pub sek24_h_vol: Option, 295 | #[serde(rename = "sek_24h_change")] 296 | pub sek24_h_change: Option, 297 | pub sgd: Option, 298 | pub sgd_market_cap: Option, 299 | #[serde(rename = "sgd_24h_vol")] 300 | pub sgd24_h_vol: Option, 301 | #[serde(rename = "sgd_24h_change")] 302 | pub sgd24_h_change: Option, 303 | pub thb: Option, 304 | pub thb_market_cap: Option, 305 | #[serde(rename = "thb_24h_vol")] 306 | pub thb24_h_vol: Option, 307 | #[serde(rename = "thb_24h_change")] 308 | pub thb24_h_change: Option, 309 | #[serde(rename = "try")] 310 | pub try_field: Option, 311 | pub try_market_cap: Option, 312 | #[serde(rename = "try_24h_vol")] 313 | pub try24_h_vol: Option, 314 | #[serde(rename = "try_24h_change")] 315 | pub try24_h_change: Option, 316 | pub twd: Option, 317 | pub twd_market_cap: Option, 318 | #[serde(rename = "twd_24h_vol")] 319 | pub twd24_h_vol: Option, 320 | #[serde(rename = "twd_24h_change")] 321 | pub twd24_h_change: Option, 322 | pub uah: Option, 323 | pub uah_market_cap: Option, 324 | #[serde(rename = "uah_24h_vol")] 325 | pub uah24_h_vol: Option, 326 | #[serde(rename = "uah_24h_change")] 327 | pub uah24_h_change: Option, 328 | pub vef: Option, 329 | pub vef_market_cap: Option, 330 | #[serde(rename = "vef_24h_vol")] 331 | pub vef24_h_vol: Option, 332 | #[serde(rename = "vef_24h_change")] 333 | pub vef24_h_change: Option, 334 | pub vnd: Option, 335 | pub vnd_market_cap: Option, 336 | #[serde(rename = "vnd_24h_vol")] 337 | pub vnd24_h_vol: Option, 338 | #[serde(rename = "vnd_24h_change")] 339 | pub vnd24_h_change: Option, 340 | pub zar: Option, 341 | pub zar_market_cap: Option, 342 | #[serde(rename = "zar_24h_vol")] 343 | pub zar24_h_vol: Option, 344 | #[serde(rename = "zar_24h_change")] 345 | pub zar24_h_change: Option, 346 | pub xdr: Option, 347 | pub xdr_market_cap: Option, 348 | #[serde(rename = "xdr_24h_vol")] 349 | pub xdr24_h_vol: Option, 350 | #[serde(rename = "xdr_24h_change")] 351 | pub xdr24_h_change: Option, 352 | pub xag: Option, 353 | pub xag_market_cap: Option, 354 | #[serde(rename = "xag_24h_vol")] 355 | pub xag24_h_vol: Option, 356 | #[serde(rename = "xag_24h_change")] 357 | pub xag24_h_change: Option, 358 | pub xau: Option, 359 | pub xau_market_cap: Option, 360 | #[serde(rename = "xau_24h_vol")] 361 | pub xau24_h_vol: Option, 362 | #[serde(rename = "xau_24h_change")] 363 | pub xau24_h_change: Option, 364 | pub bits: Option, 365 | pub bits_market_cap: Option, 366 | #[serde(rename = "bits_24h_vol")] 367 | pub bits24_h_vol: Option, 368 | #[serde(rename = "bits_24h_change")] 369 | pub bits24_h_change: Option, 370 | pub sats: Option, 371 | pub sats_market_cap: Option, 372 | #[serde(rename = "sats_24h_vol")] 373 | pub sats24_h_vol: Option, 374 | #[serde(rename = "sats_24h_change")] 375 | pub sats24_h_change: Option, 376 | pub last_updated_at: Option, 377 | } 378 | 379 | // --------------------------------------------- 380 | // /simple/supported_vs_currencies 381 | // --------------------------------------------- 382 | pub type SupportedVsCurrencies = Vec; 383 | -------------------------------------------------------------------------------- /src/response/trending.rs: -------------------------------------------------------------------------------- 1 | #![allow(missing_docs)] 2 | use serde::{Deserialize, Serialize}; 3 | use serde_json::Value; 4 | 5 | // --------------------------------------------- 6 | // /search/trending 7 | // --------------------------------------------- 8 | #[derive(Serialize, Deserialize, Debug, Clone)] 9 | pub struct Trending { 10 | pub coins: Vec, 11 | pub exchanges: Vec, 12 | } 13 | #[derive(Serialize, Deserialize, Debug, Clone)] 14 | pub struct TrendingCoin { 15 | pub item: TrendingCoinMarketData, 16 | } 17 | #[derive(Serialize, Deserialize, Debug, Clone)] 18 | pub struct TrendingCoinMarketData { 19 | pub id: String, 20 | pub coin_id: f64, 21 | pub name: String, 22 | pub symbol: String, 23 | pub market_cap_rank: f64, 24 | pub thumb: String, 25 | pub small: String, 26 | pub large: String, 27 | pub slug: String, 28 | pub price_btc: f64, 29 | pub score: f64, 30 | } 31 | --------------------------------------------------------------------------------