Unofficial CoinAPI Rust SDK for the Coinapi.io
Welcome to the unofficial CoinAPI Rust SDK. This repository contain SDK for our CoinAPI's documented at https://docs.coinapi.io/
- 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
- General
- WebSocket API
- General
- Hello
- Messages
- Trades
- Quotes
- Book
- Book5
- Book20
- Book50
- Heartbeat
- General
- FIX API
- Login (A)
- Logout (5)
- Trades (X)
- Orderbooks (W)
- Heartbeat (0)
Add this to your Cargo.toml
[dependencies]
coinapi = { git = "https://github.com/soerenmartius/coinapi-rs.git" }
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)
}
}
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)
}
}
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)
}
}
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)
}
}
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)
}
}
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)
}
}
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)
}
}
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)