Rust SDK

Encrypted Rust client for the GoDark API. Crate name: godark.

Requirements: Rust 2021, tokio
Status: Beta — contact GoDark for SDK access.

Installation

Public crates.io release is not yet available. Approved integrators receive distribution instructions directly.

When published:

cargo add godark

Quickstart

use godark::{GodarkRestClient, OrderType, Side, TimeInForce};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = GodarkRestClient::builder()
        .api_key_id(std::env::var("GDX_API_KEY_ID")?)
        .api_secret(std::env::var("GDX_API_SECRET")?)
        .build()?;

    client.connect().await?;
    let ack = client
        .place_order(
            "BTC-USDC-PERP",
            Side::Buy,
            OrderType::Limit,
            0.01,
            Some(95_000.0),
            TimeInForce::Gtc,
            false,
            None,
            None,
            Some("my-first-order".into()),
        )
        .await?;
    println!("placed {}", ack.order_id);
    client.disconnect().await?;
    Ok(())
}

See Place Order for all request fields.

Clients

TypeDescription
GodarkRestClientREST-only encrypted trading
GodarkClientWebSocket trading + streams
MarketDataClientExternal venue feeds

Build GodarkRestClient with the builder pattern: .api_key_id(), .api_secret(), .rest_base_url().

GodarkRestClient methods

MethodDocs reference
connect() / disconnect()Authentication, Encryption
place_order(...)Place Order
cancel_order(...)Cancel Order
cancel_order_by_client_id(...)Cancel Order
modify_order(...)Modify Order
get_order(...)Get Order
await_terminal_status(...)Poll until terminal order state

Enums

Side, OrderType, TimeInForce, OrderStatus, OrderUpdateType, PositionUpdateType, CancelReason.

Bundled examples

Run with cargo run --example quickstart_docs. Also includes full_trader_rest, full_trader_example, local_e2e, and market_data.

See also