asterdex_sdk/lib.rs
1//! # asterdex-sdk
2//!
3//! Async Rust client for the [AsterDex](https://github.com/seltosoj/asterdex_sdk_v3_rust) Futures API v3.
4//!
5//! Supports REST endpoints and WebSocket market/user-data streams,
6//! with EIP-712 request signing via the [alloy](https://github.com/alloy-rs/alloy) crate.
7//!
8//! ## Quick start
9//!
10//! ```rust,no_run
11//! use asterdex_sdk::{Credentials, FuturesClient};
12//!
13//! #[tokio::main]
14//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
15//! let creds = Credentials::from_env()?;
16//! let client = FuturesClient::new("https://fapi.asterdex.com", creds)?;
17//!
18//! let resp = client.get_server_time().await?;
19//! println!("Server time: {}", resp.data.server_time);
20//! Ok(())
21//! }
22//! ```
23//!
24//! ## Environment variables
25//!
26//! | Variable | Required | Description |
27//! |---|---|---|
28//! | `ASTERDEX_PRIVATE_KEY` | Yes | Hex-encoded private key for EIP-712 signing |
29//! | `ASTERDEX_BASE_URL` | No | Override base URL (defaults to mainnet) |
30//! | `ASTERDEX_CHAIN_ID` | No | Chain ID (defaults to `1666`) |
31
32// US-001: SDK crate root — public re-exports
33
34mod auth;
35mod rest;
36mod ws;
37pub mod futures;
38pub mod spot;
39/// Backward-compatibility re-export of futures::models — use futures::models directly.
40pub mod models;
41pub(crate) mod endpoints;
42
43pub use auth::Credentials;
44pub use rest::client::RestClient;
45pub use futures::FuturesClient;
46pub use rest::error::AsterDexError;
47pub use rest::response::ApiResponse;
48pub use ws::client::{UserDataStream, WebSocketClient, WebSocketStream};
49
50// Re-export key model types at crate root for convenience
51pub use futures::models::trading::{
52 CancelOrderParams, CancelOrderResponse, EmptyResponse, ListenKeyResponse, ModifyOrderParams,
53 OrderResponse, PlaceOrderParams, PositionResponse,
54};
55pub use futures::models::market::{
56 AggTrade, BookTickerResponse, BookTickerShape, DepthResponse, ExchangeAsset,
57 ExchangeInfoResponse, FundingInfoResponse, IndexReference, IndexReferencesResponse, Kline,
58 KlineInterval, MarkPriceResponse, MarkPriceShape, PingResponse, ServerTimeResponse,
59 SymbolInfo, Ticker24hrResponse, Ticker24hrShape, TickerPriceResponse, TickerPriceShape,
60 TradeRecord,
61};
62pub use futures::models::account::{
63 AccountAsset, AccountInfoResponse, AccountPosition, Balance, LeverageBracket,
64 PositionMarginHistoryRecord, SetLeverageResponse,
65};
66pub use futures::models::websocket::WebSocketMessage;
67pub use futures::models::user_data::{
68 ListenKeyExpiredEvent, MarginCallEvent, MarginCallPosition, TradeProEvent, UserDataEvent,
69};