Crate gecko

Source
Expand description

§gecko

The gecko crate provides convenient access coingeckos api. The focus of this crate is on access/retreival of data from coingecko api endpoints and not on convenience or manipulating reponses/data. Although, if raw text reponses are not desired, the crate has funcitonality to provide coingeckos api response in json objects.

Note: Coingeckos api has a limit of 100 requests per minute.

§Examples

§Default
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
   let gecko_client = gecko::CoinGeckoAPI::default();
   let coins_list = gecko::coins::List::required();
   let response = gecko_client.get_json(&coins_list).await.unwrap();
   println!("{:?}", response);
   Ok(())
}
§Custom
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
   let gecko_client = gecko::CoinGeckoAPI::default();
   let mut coins_list = gecko::coins::Info::required("premia".to_string());
   coins_list.tickers = false;
   let response = gecko_client.get_json(&coins_list).await.unwrap();
   println!("{:?}", response["id"]);
   Ok(())
}

Or if you do not want the request object to be a mutable variable…

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
   let gecko_client = gecko::CoinGeckoAPI::default();
   let coins_list = {
      let mut _tmp = gecko::coins::Info::required("premia".to_string());
      _tmp.tickers = false;
      _tmp
   };
   let response = gecko_client.get_json(&coins_list).await.unwrap();
   println!("{:?}", response["id"]);
   Ok(())
}

For more information about CoinGecko API can be found here

Modules§

asset_platforms
/asset_platforms
categories
/categories
coins
/coins
companies
/companies
contract
/contract
derivatives
/derivatives
events
/events
exchange_rates
/exchange_rates
exchanges
/exchange
finance
/finance
global
/global
indexes
/indexes
simple
/simple
status_updates
/status_updates
trending
/trending

Structs§

CoinGeckoAPI

Traits§

Route
The Route trait can be implented to give a struct the ability to be used by CoinGeckoAPI