Giter VIP home page Giter VIP logo

coinapi-rs's Introduction

coinapi-rs

Unofficial CoinAPI Rust SDK for the Coinapi.io

Build Status MIT licensed

Welcome to the unofficial CoinAPI Rust SDK. This repository contain SDK for our CoinAPI's documented at https://docs.coinapi.io/

To-Do

General

  • Error handling with Failure
  • Implement Log
  • Lazy load collections
  • Implement tests

API Implementation Status

  • REST API
    • General
      • Authorization
      • Output data format
    • Metadata
      • List all exchanges
      • List all assets
      • List all symbols
    • Exchanges rates
      • Get specific rate
      • Get all current rates
    • OHLCV
      • List all periods
      • Latest data
      • Historical Data
    • Trades
      • Current data
      • Latest data
      • Historical data
    • Quotes
      • Current data
      • Latest data
      • Historical data
    • Order book
      • Current data
      • Latest data
      • Historical data
    • Subscription
  • WebSocket API
    • General
      • Hello
    • Messages
      • Trades
      • Quotes
      • Book
      • Book5
      • Book20
      • Book50
      • Heartbeat
  • FIX API
    • Login (A)
    • Logout (5)
    • Trades (X)
    • Orderbooks (W)
    • Heartbeat (0)

Usage

Add this to your Cargo.toml

[dependencies]
coinapi = { git = "https://github.com/soerenmartius/coinapi-rs.git" }

Metadata

List all exchanges

use coinapi_rs::metadata::*;

fn main() {
    let metadata: MetaData = Coinapi::new(String::from("YOUR_API_KEY_HERE"));
    let data = metadata.get_all_exchanges();

    match data {
        Ok(r) => println!("{:#?}", r),
        Err(e) => println!("Error: {:?}", e)
    }
}

List all assets

use coinapi_rs::metadata::*;

fn main() {
    let metadata: MetaData = Coinapi::new(String::from("YOUR_API_KEY_HERE"));
    let assets = metadata.get_all_assets();

    match assets {
        Ok(r) => println!("{:#?}", r),
        Err(e) => println!("Error: {:?}", e)
    }
}

List all symbols

use coinapi_rs::metadata::*;

fn main() {
    let metadata: MetaData = Coinapi::new(String::from("YOUR_API_KEY_HERE"));
    let data = metadata.get_all_symbols(None);
    //let data = metadata.get_all_symbols(Some("BITSTAMP_SPOT_BTC_USD,HITBTC_SPOT_BTS_BTC")); // with filter

    match data {
        Ok(r) => println!("{:#?}", r),
        Err(e) => println!("Error: {:?}", e)
    }
}

Exchange rates

Get specific rate

use coinapi_rs::exchangerate::*;
use chrono::Utc;

fn main() {
    let exchangerate: ExchangeRate = Coinapi::new(String::from("YOUR_API_KEY_HERE"));
    let time = Utc.ymd(2018, 7, 8).and_hms(9, 10, 11);
    let data = exchangerate.get_specific_rate("BTC", "USDT", Some(time));

    match data {
        Ok(r) => println!("{:#?}", r),
        Err(e) => println!("Error: {:?}", e)
    }
}

Get all current rates

use coinapi_rs::exchangerate::*;

fn main() {
    let exchangerate: ExchangeRate = Coinapi::new(String::from("YOUR_API_KEY_HERE"));
    let data = exchangerate.get_all_rates("BTC");

        match data {
        Ok(r) => println!("{:#?}", r),
        Err(e) => println!("Error: {:?}", e)
    }
}

OHLCV

List all periods

use coinapi_rs::ohlcv::*;

fn main() {
    let ohlcv: OHLCV = Coinapi::new(String::from
    ("YOUR_API_KEY_HERE"));
    let data = ohlcv.list_all_periods();

    match data {
      Ok(r)  => println!("{:#?}", r),
      Err(e) => println!("Error: {:?}", e)
    }
}

Latest data

use coinapi_rs::ohlcv::*;
use chrono::Utc;

fn main() {
    let ohlcv: OHLCV = Coinapi::new(String::from
    ("YOUR_API_KEY_HERE"));
    let data = ohlcv.latest_data("BITSTAMP_SPOT_BTC_USD", "1MIN", Some(false), Some(100i32));

    match data {
      Ok(r)  => println!("{:#?}", r),
      Err(e) => println!("Error: {:?}", e)
    }
}

Historical data

use coinapi_rs::ohlcv::*;
use chrono::Utc;

fn main() {
    let ohlcv: OHLCV = Coinapi::new(String::from
    ("YOUR_API_KEY_HERE"));
    let start_time = Utc.ymd(2020, 8, 20).and_hms(5, 55, 55);
    let end_time = Utc.ymd(2020, 8, 27).and_hms(5, 55, 55);
    let data = ohlcv.historical_data("BITSTAMP_SPOT_BTC_USD", "1MIN", start_time, Some(time_end), None, Some(100i32));

    match data {
      Ok(r)  => println!("{:#?}", r),
      Err(e) => println!("Error: {:?}", e)
    }
}

## Contributors

- [Blake Willoughby](https://github.com/byblakeorriver)
- [Soren Martius](https://github.com/soerenmartius)

coinapi-rs's People

Contributors

byblakeorriver avatar soerenmartius avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

byblakeorriver

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.