btcturk_websockets

Crates.iobtcturk_websockets
lib.rsbtcturk_websockets
version0.1.1
sourcesrc
created_at2023-08-22 09:07:04.141282
updated_at2024-05-04 11:47:32.883952
descriptionA Rust library for interacting with the BTCTurk Websockets API.
homepage
repository
max_upload_size
id950825
size11,280
Doğa Budak (dogabudak)

documentation

README

Rust WebSocket Crate

Rust Version WebSocket Version License

Installation

Add the following dependency to your Cargo.toml file:

[dependencies]
btcturk_websockets = "0.0.1"

Example

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;
}
Commit count: 0

cargo fmt