Module signed_request

Module signed_request 

Source
Expand description

Signed request builder for OKX API.

This module provides a builder pattern for creating authenticated OKX API requests, encapsulating the common signing workflow used across all authenticated endpoints.

§Overview

The OkxSignedRequestBuilder eliminates code duplication by centralizing:

  • Credential validation
  • ISO 8601 timestamp generation
  • Parameter signing with HMAC-SHA256
  • Authentication header injection
  • HTTP request execution

§Example

let okx = Okx::new(ExchangeConfig::default())?;

// Simple GET request
let data = okx.signed_request("/api/v5/account/balance")
    .execute()
    .await?;

// POST request with parameters
let data = okx.signed_request("/api/v5/trade/order")
    .method(HttpMethod::Post)
    .param("instId", "BTC-USDT")
    .param("tdMode", "cash")
    .param("side", "buy")
    .execute()
    .await?;

Structs§

OkxSignedRequestBuilder
Builder for creating authenticated OKX API requests.

Enums§

HttpMethod
HTTP request methods supported by the signed request builder.