Limitless Exchange Rust SDK
v1.0.13 | Rust SDK parity with the existing Limitless SDK surface
Rust SDK for interacting with the Limitless Exchange API.
This crate is a parity-driven Rust port of the existing Limitless SDK surface. The current implementation includes:
- shared HTTP client with API key, identity-header, and HMAC auth support
- typed API errors and retry helpers
- root
Client - markets, portfolio, and market-pages services
- partner api-token, partner-account, and server-wallet services
- order builder, validator, EIP-712 signer, and order client
- delegated-order service
- websocket types and socket.io client surface
USE AT YOUR OWN RISK
This SDK is provided "as-is" without any warranties or guarantees. Trading on prediction markets involves financial risk. By using this SDK, you acknowledge that:
- You are responsible for testing the SDK thoroughly before using it in production
- The SDK authors are not liable for any financial losses or damages
- You should review and understand the code before executing any trades
- It is recommended to test all functionality on testnet or with small amounts first
- The SDK may contain bugs or unexpected behavior despite best efforts
ALWAYS TEST BEFORE USING IN PRODUCTION WITH REAL FUNDS
For production use, we strongly recommend:
- Running comprehensive tests with your specific use case
- Starting with small transaction amounts
- Monitoring all transactions carefully
- Having proper error handling and recovery mechanisms
Geographic Restrictions
Important: Limitless restricts order placement from US locations due to regulatory requirements and compliance with international sanctions. Before placing orders, builders should verify their location complies with applicable regulations.
Status
This is the first full-surface parity pass. The crate is implemented against the Go SDK shape and verified locally with:
cargo fmtcargo check --examplescargo test
Installation
[]
= "1.0.13"
Authentication Modes
- Public read-only endpoints: no authentication required. Use these for active markets, market pages, and orderbooks.
- API key authentication: required for portfolio and standard order-placement flows.
- HMAC-scoped authentication: used for partner/delegated/server-wallet flows and can also authenticate websocket position streams.
The SDK reads LIMITLESS_API_KEY automatically when present, or you can configure credentials explicitly with Client::builder().
Quick Start
Public Market Data
use ;
async
Authenticated Portfolio Access
use env;
use Client;
async
Signed Order Placement
use env;
use ;
async
Optional Receive Window
Order creation can opt into API receive-window freshness checks with ReceiveWindowOptions. These values are sent as top-level POST /orders fields named timestamp and recvWindow; they are not included in the signed EIP-712 order payload. Existing create_order calls are unchanged and omit both fields.
use ;
let order = order_client
.create_order_with_receive_window
.await?;
recv_window must be between 1 and 10000 milliseconds. When recv_window is supplied without timestamp, the SDK stamps the current Unix time in milliseconds. Keep trading hosts NTP-synced; server clock skew tolerance is about one second. Do not retry a 425 Too Early with the same payload; build a fresh order instead.
Workflow Guide
- Public market discovery: examples/active_markets.rs
- Custom client builder and logging: examples/custom_client.rs
- Market-page discovery and filtered browsing: examples/market_pages.rs
- Portfolio and cursor-based history: examples/portfolio.rs
- User-order retrieval and market cancel-all: examples/user_orders.rs
- Signed CLOB orders:
- NegRisk order flow: examples/negrisk_order.rs
- Delegated partner flows:
- delegated order: examples/delegated_order.rs
- delegated FOK order: examples/delegated_fok_order.rs
- Partner allowance recovery: examples/partner_account_allowances.rs
- API-token revoke flow: examples/api_token_revoke.rs
- Server-wallet redeem/withdraw flow: examples/server_wallet_redeem_withdraw.rs
- WebSocket subscriptions:
- orderbook: examples/websocket_orderbook.rs
- positions and transactions: examples/websocket_positions.rs
Partner Server-Wallet Allowances
Use partner_accounts.list_accounts to list partner-owned sub-accounts, or pass account to recover a specific child profile by address. This endpoint requires scoped HMAC credentials with the account_creation scope. The API caps limit at 25 and rejects x-on-behalf-of on this route.
use ;
let sdk = from_http_client?;
let accounts = sdk
.partner_accounts
.list_accounts
.await?;
let recovered = sdk
.partner_accounts
.list_accounts
.await?;
println!;
Use partner_accounts.check_allowances(profile_id) and partner_accounts.retry_allowances(profile_id) only for partner child profiles created with create_server_wallet = true. These endpoints require scoped HMAC credentials derived with SCOPE_ACCOUNT_CREATION and SCOPE_DELEGATED_SIGNING.
use ;
let sdk = from_http_client?;
let profile_id = 12345;
let mut allowances = sdk.partner_accounts.check_allowances.await?;
if !allowances.ready
println!;
Poll check_allowances first. If ready is false and one or more targets are missing or failed with retryable = true, call retry_allowances, then poll check_allowances again after a short delay. Retry 429 and 409 responses are returned as LimitlessError::Api; inspect err.status, and for 429 read retryAfterSeconds from err.data.
Server Wallet Redeem & Withdraw
Use server_wallets.redeem_positions and server_wallets.withdraw only for server-managed wallets created in delegated-signing partner flows with create_server_wallet = true.
redeem_positionscallsPOST /portfolio/redeemwithdrawcallsPOST /portfolio/withdraw- both operations require HMAC-scoped API-token auth
withdrawalso requires thewithdrawalscope- set
on_behalf_ofto the delegated child-profile id when withdrawing child server-wallet funds - omit
on_behalf_ofonly when withdrawing the authenticated caller's own server wallet to an explicitdestination - omit
destinationto use the API default: authenticated partner smart wallet when present, otherwise authenticated partner account - pass
destinationto withdraw directly to the authenticated partner account, authenticated partner smart wallet, or an active withdrawal address allowlisted on the authenticated partner profile partner_accounts.add_withdrawal_addressandpartner_accounts.delete_withdrawal_addressmanage the allowlist with Privy identity-token auth; API-token auth is not used for those allowlist endpoints
use ;
let sdk = from_http_client?;
let identity_token = var?;
let treasury_address = "0x0F3262730c909408042F9Da345a916dc0e1F9787";
sdk.partner_accounts
.add_withdrawal_address
.await?;
let child_withdraw = sdk
.server_wallets
.withdraw
.await?;
let own_wallet_withdraw = sdk
.server_wallets
.withdraw
.await?;
println!;