Crates.io | btcturk_websockets |
lib.rs | btcturk_websockets |
version | 0.1.1 |
source | src |
created_at | 2023-08-22 09:07:04.141282 |
updated_at | 2024-05-04 11:47:32.883952 |
description | A Rust library for interacting with the BTCTurk Websockets API. |
homepage | |
repository | |
max_upload_size | |
id | 950825 |
size | 11,280 |
Add the following dependency to your Cargo.toml
file:
[dependencies]
btcturk_websockets = "0.0.1"
use btcturk_websockets::{Client, ApiKeys};
#[tokio::main]
async fn main() {
// Retrieve API keys and WebSocket address from environment variables
let btc_public_key = std::env::var("BTCTURK_PUBLIC_KEY").expect("BTCTURK_PUBLIC_KEY must be set.");
let btc_private_key = std::env::var("BTCTURK_PRIVATE_KEY").expect("BTCTURK_PRIVATE_KEY must be set.");
let connect_addr = std::env::var("BTCTURK_WEBSOCKET_ADDRESS").expect("BTCTURK_WEBSOCKET_ADDRESS must be set.");
// Initialize API keys
let api_keys = ApiKeys::new(btc_public_key, btc_private_key);
// Initialize WebSocket client
let client = Client::new(connect_addr, api_keys);
// Generate token message for authentication
let token = client.clone().generate_token_message();
// Create WebSocket connection
let connection = client.clone().create_connection().await;
// Retrieve ticker information
let ticker = client.clone().get_ticker().await;
}