7 releases (breaking)

0.6.0 Dec 4, 2020
0.5.0 Mar 4, 2018
0.4.0 Feb 16, 2018
0.3.0 Jan 29, 2018
0.1.1 Jan 10, 2018

#216 in #api-wrapper


Used in zacli

MIT license

25KB
749 lines

zaif-api-rust Crates.io

Use Zaif-Api from Rust

Description

Zaif ApiのWrapperです。 reqwest crateを使って実装しています。

Zaif Web API Reference

Usage

extern crate zaif_api;

use zaif_api::AccessKey;
use zaif_api::public_api::*;
use zaif_api::trade_api::*;

fn main() {
    let api = CurrenciesBuilder::new().name("btc".to_string()).finalize();
    for currency in api.exec().unwrap() {
        println!("name: {} is_token: {}", currency.name, currency.is_token);
    }

    let access_key = AccessKey::new("YOUR_API_KEY", "YOUR_API_SECRET");

    let api = TradeBuilder::new()
        .access_key(access_key.clone())
        .currency_pair("zaif_jpy".to_string())
        .action(TradeAction::Bid)
        .price(1.0)
        .amount(0.1)
        .finalize();
    let _ = api.exec().and_then(|res| {
        println!(
            "received: {}, remains: {}, order_id: {}",
            res.received,
            res.remains,
            res.order_id
        );
        if res.order_id == 0 {
            panic!("Complete trade.");
        }
        Ok(res.order_id)
    });
}

Dependencies

~17–27MB
~479K SLoC