Skip to main content

Crate monaco_sdk

Crate monaco_sdk 

Source
Expand description

§Monaco SDK

Typed Rust client for the Monaco DEX REST API — auto-generated from the OpenAPI specification via progenitor.

§Quick start

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = monaco_sdk::Client::new("https://develop.apimonaco.xyz");

    // Public endpoints (no auth required)
    let health = client.health_check().await?.into_inner();
    println!("Status: {:?}", health.status);

    let pairs = client
        .list_trading_pairs(None, Some(true), None, None, None, None)
        .await?
        .into_inner();
    println!("Trading pairs: {:?}", pairs.trading_pairs);

    Ok(())
}

§Authentication

Authenticated endpoints require a Bearer token obtained through the challenge → sign → verify flow. Pass it via a custom reqwest::Client:

use reqwest::header::{HeaderMap, HeaderValue, AUTHORIZATION};

let mut headers = HeaderMap::new();
headers.insert(
    AUTHORIZATION,
    HeaderValue::from_str("Bearer <your-jwt>").unwrap(),
);
let http = reqwest::ClientBuilder::new()
    .default_headers(headers)
    .build()
    .unwrap();
let client = monaco_sdk::Client::new_with_client("https://develop.apimonaco.xyz", http);

§API coverage

The client exposes every operation from the Monaco REST API:

CategoryMethods
Market datalist_trading_pairs, get_trading_pair_by_id, get_market_metadata, get_candles
Orderbookget_orderbook_snapshot
Tradesget_trades
Orderscreate_order, replace_order, cancel_order, get_orders, get_order_by_id
Batch ordersbatch_create_orders, batch_replace_orders, batch_cancel_orders, batch_cancel_all, batch_cancel_all_by_pair
Accountsget_user_profile, get_user_balances, get_user_balance_by_asset, get_user_movements
Sub-accountslist_sub_accounts_with_balances, create_sub_account_limit, get_sub_account_limits, update_sub_account_limit, delete_sub_account_limit
Authcreate_challenge, verify_signature, refresh_token, revoke_session, authenticate_backend
Feessimulate_fees
Whitelistsubmit_whitelist
Faucetmint_tokens
Healthhealth_check

All request/response types live in the types module.

Modules§

prelude
Items consumers will typically use such as the Client.
types
Types used as operation parameters and responses.

Structs§

ByteStream
Untyped byte stream used for both success and error responses.
Client
Client for Monaco Protocol API
ResponseValue
Typed value returned by generated client methods.

Enums§

Error
Error produced by generated client methods.

Traits§

ClientInfo
Interface for which an implementation is generated for all clients.