A strongly-typed Rust SDK for the Kraken WebSocket API.
This crate is an unofficial, community-driven effort.
toml
[dependencies]
kraken_ws_client = "0.23"
```rs use futures::StreamExt; use krakenwsclient::api::SubscribeTickerRequest;
async fn main() { let mut client = krakenwsclient::connect_public() .await .expect("cannot connect");
client
.send(SubscribeTickerRequest::symbol("BTC/USD"))
.await
.expect("cannot send request");
while let Some(event) = client.ticker_events().next().await {
dbg!(&event);
}
} ```
```rs use krakenrestclient::Client as RestClient;
let apikey = std::env::var("KRAKENAPIKEY").expect("api key not defined"); let apisecret = std::env::var("KRAKENAPISECRET").expect("api secret not defined");
let restclient = RestClient::new(apikey, apisecret); let resp = restclient.getwebsockets_token().send().await?; let token = resp.token;
let mut wsprivateclient = krakenwsclient::connect_private(token) .await .expect("cannot connect");
wsprivateclient .send(SubscribeExecutionsRequest::new()) .await .expect("cannot send request");
while let Ok(msg) = wsprivateclient.messages().recv().await { dbg!(msg); } ```
or run the example:
rs
cargo run --example ticker
The software is under active development and the API is expected to change.
Pull requests, issues and comments are welcome! Make sure to add tests for new features and bug fixes.
This work is licensed under the Apache-2.0 License. See LICENSE.txt or https://spdx.org/licenses/Apache-2.0.html for details.
Copyright © 2022 Georgios Moschovitis.