luno

Crates.ioluno
lib.rsluno
version0.3.0
sourcesrc
created_at2019-08-19 08:52:14.565327
updated_at2020-09-05 12:24:39.634522
descriptionAn unofficial Rust wrapper for the Luno API.
homepagehttps://github.com/duncandean/luno-rust
repositoryhttps://github.com/duncandean/luno-rust
max_upload_size
id158021
size117,353
dunxen (dunxen)

documentation

https://duncandean.github.io/luno-rust

README

(Unofficial) Luno Rust API Wrapper 🦀🚀

Rust codecov

A work-in-progress.

Please read the license. This software is by no means production ready and use of it is at your own risk!

Installation

In your Cargo.toml include:

[dependencies]
luno = "0.3.0"

Documentation

Documentation can be found here.

Examples

Examples of calls can be found in the examples/ directory. Clone this repository and run a specific example, such as get-trades.rs with:

cargo run --example get-trades

Example with list_trades():

use luno::{LunoClient, TradingPair};

#[tokio::main]
async fn main() {
    let key = String::from("LUNO_API_KEY");
    let secret = String::from("LUNO_API_SECRET");

    let client = LunoClient::new(key, secret);

    match client.list_trades(TradingPair::XBTZAR).await {
        Err(e) => eprintln!("{:?}", e),
        Ok(result) => {
            if let Some(trade) = result.trades {
                println!("{:?}", trade);
            }
        }
    }
}

Results:

Trade { volume: 0.005686, timestamp: 1561918948454, price: 173001.00, is_buy: false }
Trade { volume: 0.007, timestamp: 1561918942586, price: 173002.00, is_buy: true }
Trade { volume: 0.006936, timestamp: 1561918937500, price: 173002.00, is_buy: true }
Trade { volume: 0.006345, timestamp: 1561918911780, price: 173378.00, is_buy: true }
Trade { volume: 0.0005, timestamp: 1561918878415, price: 173585.00, is_buy: false }
Trade { volume: 0.00577, timestamp: 1561918867525, price: 173590.00, is_buy: false }
...

By default, all methods are asynchronous and return a Future wrapping Result<T, reqwest::Error>.

Commit count: 103

cargo fmt