Giter VIP home page Giter VIP logo

coingecko-rs's Introduction

CoinGecko Rust

Rust crate for interacting with the CoinGecko v3 API.

At this time, async support is provided by isahc. I would like to have generic HTTP client support, but surf is currently unsuitable for user in a library due to it's error type not being compatible with std::Error. The isahc crate is suitable for now and ideal on Linux systems since it takes advantage of the system libcurl for HTTPS support.

Supported APIs

  • /ping
  • /simple/price
  • /coins/list
  • /coins/{id}
  • /coins/markets

Example

use coingecko::{Client, SimplePriceReq};

pub fn main() {
    smol::block_on(async {
        let http = isahc::HttpClient::new().unwrap();

        let client = Client::new(http);

        let req = SimplePriceReq::new("ethereum,algorand,tezos".into(), "usd".into())
            .include_market_cap()
            .include_24hr_vol()
            .include_24hr_change()
            .include_last_updated_at();

        println!("{:#?}", client.simple_price(req).await);
    })
}
Ok(
    {
        "ethereum": {
            "usd": 374.01,
            "usd_24h_change": 0.6764058401035155,
            "usd_24h_vol": 9235228681.348743,
            "usd_market_cap": 42251015530.714905,
            "last_updated_at": 1602472941,
        },
        "algorand": {
            "usd_market_cap": 266053358.9639521,
            "last_updated_at": 1602472968,
            "usd": 0.331298,
            "usd_24h_change": 4.2444465005613035,
            "usd_24h_vol": 140788809.28500596,
        },
        "tezos": {
            "last_updated_at": 1602472989,
            "usd_market_cap": 1651035262.3629265,
            "usd_24h_vol": 90234644.31549962,
            "usd": 2.27,
            "usd_24h_change": 3.1493641962253895,
        },
    },
)

coingecko-rs's People

Contributors

0xdewy avatar chipshort avatar mmstick avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.