dominusnode -- Official Dominus Node Rust SDK
The official Rust SDK for the Dominus Node rotating proxy-as-a-service platform. Manage proxy connections, API keys, wallet balances, usage tracking, and more from Rust applications.
- Async by default -- powered by Tokio and reqwest
- Strongly typed -- every request and response has a dedicated type
- Auto token refresh -- JWT expiry handled transparently with async mutex
- Rate limit auto-retry -- 429 responses automatically retried with backoff
- Typed error hierarchy -- pattern-match on specific error variants
- URL-safe -- all proxy URL components are percent-encoded (RFC 3986)
Installation
Add to your Cargo.toml:
[]
= "1.0"
= { = "1", = ["full"] }
Feature Flags
| Feature | Default | Description |
|---|---|---|
async |
Yes | Async API using Tokio |
blocking |
No | Marker for future sync wrapper |
Quick Start
use ;
async
Authentication
API Key (Recommended for Proxy Usage)
let client = new?;
client.connect_with_key.await?;
Or provide in the config:
let client = new?;
// Note: API key auth happens lazily on first authenticated request
Email/Password
let client = new?;
let result = client.connect_with_credentials.await?;
if result.mfa_required
Pre-existing Tokens
let client = new?;
Resources
All API operations are accessed through public resource fields on the client.
Auth
// Register
let result = client.auth.register.await?;
// Login
let result = client.auth.login.await?;
// Change password
client.auth.change_password.await?;
// Logout (revokes all refresh tokens)
client.auth.logout.await?;
// Get current user
let user = client.auth.me.await?;
println!;
MFA
// Setup MFA
let setup = client.auth.mfa_setup.await?;
println!;
println!;
println!; // Save these!
// Enable MFA
client.auth.mfa_enable.await?;
// Check status
let status = client.auth.mfa_status.await?;
println!;
// Disable MFA
client.auth.mfa_disable.await?;
API Keys
// Create key (raw key only shown once)
let created = client.keys.create.await?;
println!; // dn_live_xxxx -- save this!
// List keys
let keys = client.keys.list.await?;
for key in &keys
// Revoke
client.keys.revoke.await?;
Wallet
// Balance
let balance = client.wallet.get_balance.await?;
println!;
// Transactions
let txs = client.wallet.get_transactions.await?;
for tx in &txs
// Stripe top-up
let checkout = client.wallet.topup_stripe.await?;
println!;
// Crypto top-up
let invoice = client.wallet.topup_crypto.await?;
Usage
// Usage records
let usage = client.usage.get.await?;
// Daily breakdown
let daily = client.usage.get_daily.await?;
for day in &daily
// Top hosts
let hosts = client.usage.get_top_hosts.await?;
for host in &hosts
// CSV export
let csv = client.usage.export_csv.await?;
Plans
// List plans
let plans = client.plans.list.await?;
for plan in &plans
// Current plan
let current = client.plans.get_user_plan.await?;
// Change plan
client.plans.change.await?;
Sessions
let sessions = client.sessions.get_active.await?;
for session in &sessions
Proxy
use ProxyUrlOptions;
// Default proxy URL
let url = client.proxy.build_url;
// With geo-targeting
let opts = ProxyUrlOptions ;
let geo_url = client.proxy.build_url;
// SOCKS5
let socks_opts = ProxyUrlOptions ;
let socks_url = client.proxy.build_url;
// Sticky session
let sticky_opts = ProxyUrlOptions ;
let sticky_url = client.proxy.build_url;
// Health check (no auth)
let health = client.proxy.get_health.await?;
println!;
// Detailed status
let status = client.proxy.get_status.await?;
// Configuration
let config = client.proxy.get_config.await?;
Admin
// List users
let users = client.admin.list_users.await?;
// User detail
let detail = client.admin.get_user.await?;
// Suspend/activate
client.admin.suspend_user.await?;
client.admin.activate_user.await?;
// Revenue
let revenue = client.admin.get_revenue.await?;
println!;
// System stats
let stats = client.admin.get_stats.await?;
println!;
Using Proxy URLs with reqwest
use ;
use ProxyUrlOptions;
use Proxy;
async
Error Handling
All errors are variants of DominusNodeError, implementing std::error::Error via thiserror:
use DominusNodeError;
match client.connect_with_key.await
| Variant | HTTP Status | When |
|---|---|---|
Authentication |
401 | Invalid credentials |
Authorization |
403 | Insufficient permissions |
InsufficientBalance |
402 | Low wallet balance |
RateLimit |
429 | Rate limit exceeded |
Validation |
400 | Invalid input |
NotFound |
404 | Resource not found |
Conflict |
409 | Duplicate resource |
Server |
500+ | Server error |
Network |
-- | Connection/timeout failure |
Proxy |
-- | Proxy URL building error |
Configuration
use Config;
let config = Config ;
All fields have sensible defaults via Config::default().
Security Notes
- Token storage: Tokens are stored in memory only (never written to disk)
- Token refresh: Uses
tokio::sync::Mutexto prevent concurrent refresh races - URL encoding: API keys and geo-targeting values are percent-encoded (RFC 3986)
- TLS: reqwest verifies TLS certificates by default
- Force refresh: On 401, the SDK forces a token refresh (bypasses expiry check) to handle stale-but-not-expired tokens
License
MIT