Skip to main content

Overview

The Rust SDK provides:
  • structured LimitlessError variants
  • HTTP ApiError details with status, method, URL, and response payload
  • reusable retry helpers via with_retry and RetryableClient
  • optional logging hooks for retry visibility

Error types

All SDK methods return:

LimitlessError

Inspecting API errors

Authentication-required errors

The SDK fails early for authenticated methods when no credentials are configured:

Raw HTTP responses

Every API-backed service method has a *_with_raw sibling that returns Result<SdkResponse<T>>. Use it when you need the HTTP status, response headers (rate-limit metadata, request IDs, content-type), or the exact response bytes alongside the decoded value. The base method (without the suffix) is unchanged and still returns just the decoded value. The raw variant still returns the same LimitlessError::Api(ApiError) on any response with status >= 400. It only exposes the raw response on success.

SdkResponse<T>

RawResponse

The *_with_raw variant is available on every API-backed method (markets, portfolio, orders, AMM, API tokens, delegated orders, partner accounts, and market pages). WebSocket subscriptions are not affected.

with_retry

Use with_retry() to wrap any async operation:
By default, retries are enabled for:
  • 429
  • 500
  • 502
  • 503
  • 504
  • connection failures
  • timeouts
425 Too Early is not retried by default. If the API body has a trading-mode code, refresh maintenance status and do not retry the same blocked action. Otherwise, treat POST /orders failures as receive-window failures and rebuild a fresh signed order.

RetryableClient

Use RetryableClient when you want a retrying HTTP transport wrapper:
You can still build the root Client from the same HttpClient:

Retry callbacks

Attach a callback to observe retry attempts:

Logging

Retry helpers accept an optional SharedLogger. Use ConsoleLogger during integration work:
For trading systems, treat InvalidInput and AuthenticationRequired as non-retryable. Retries are most useful for transient HTTP failures, rate limits, and network timeouts.