Expand description
§polyoxide-core
Core utilities and shared types for Polyoxide Polymarket API clients.
This crate provides common functionality used across polyoxide-clob, polyoxide-gamma, polyoxide-data, and polyoxide-relay:
- Shared error types and error handling
- HTTP client configuration
- Request builder utilities
- HMAC API-credential signing (
Signer) - One send loop,
HttpClient::send, with the hooks a venue supplies (Throttle,RetryPolicy,Authenticator), and one health ping on it,HttpClient::health - Per-endpoint window quotas (
WindowQuotaTable, which builds aRateLimiter), token-cost buckets (CapacityBucket), theHoldtheir layers share, and the retry schedule (RetryConfig) - Optional OS keychain credential storage (behind the
keychainfeature)
§HTTP Client
Use HttpClientBuilder to create configured HTTP clients:
use polyoxide_core::HttpClientBuilder;
let client = HttpClientBuilder::new("https://api.example.com")
.timeout_ms(60_000)
.build()
.unwrap();§Error Handling
An unsuccessful response is ApiError::Response, carrying an
ErrorResponse: its status, headers, body, message and Retry-After.
A venue’s error type wraps ApiError, and its From<ApiError> is its
one decode, so a ? on core’s error anywhere reads the venue’s body.
Re-exports§
pub use auth::current_timestamp;pub use auth::Base64Format;pub use auth::Signer;pub use capacity::CapacityBucket;pub use client::retry_after_header;pub use client::HttpClient;pub use client::HttpClientBuilder;pub use client::DEFAULT_POOL_SIZE;pub use client::DEFAULT_TIMEOUT_MS;pub use config::ClientConfig;pub use error::ApiError;pub use error::ErrorResponse;pub use health::Pong;pub use hold::Hold;pub use hooks::AttemptInfo;pub use hooks::Authenticator;pub use hooks::Charge;pub use hooks::Cost;pub use hooks::Decision;pub use hooks::DefaultRetryPolicy;pub use hooks::DynAuthenticator;pub use hooks::DynRetryPolicy;pub use hooks::DynThrottle;pub use hooks::LayerCharge;pub use hooks::LayerId;pub use hooks::NoThrottle;pub use hooks::Outcome;pub use hooks::Refused;pub use hooks::RequestMeta;pub use hooks::RequestParts;pub use hooks::ResponseMeta;pub use hooks::RetryPolicy;pub use hooks::Throttle;pub use rate_limit::BucketId;pub use rate_limit::EffectiveQuota;pub use rate_limit::Matching;pub use rate_limit::QuotaRow;pub use rate_limit::RateLimiter;pub use rate_limit::RetryConfig;pub use rate_limit::WindowQuotaTable;pub use request::QueryBuilder;pub use request::Request;pub use request::RequestError;pub use send::decode_json;pub use session_signer::DepositWalletRole;pub use session_signer::SessionSignerScope;pub use signer_limit::BurstCapacityExceeded;pub use signer_limit::RateLimitStatus;pub use signer_limit::SignerLimiter;pub use signer_limit::Tier;pub use signer_limit::TradingBucket;pub use signer_limit::TradingRequest;pub use reqwest;
Modules§
- auth
- Authentication utilities for Polymarket API clients
- capacity
CapacityBucket: a token bucket that holds a published burst, charges integer costs, and can be resized in place.- client
- config
- The transport settings every client builder holds.
- error
- health
- One health ping, on the send loop.
- hold
Hold: what the server said, shared by every layer of a throttle.- hooks
- The hooks a venue gives
HttpClient::send. - macros
- Macros for reducing boilerplate in API client implementations
- polymarket
- Polymarket’s hooks for core’s send loop: its retry policy, its rate limit tables, and the CLOB’s composed throttle.
- rate_
limit - Window quotas:
WindowQuotaTablebuilds aRateLimiter, which counts requests against the buckets a request’s method and path resolve to. - request
- send
HttpClient::send: core’s one send loop.- session_
signer - Venue scopes a Deposit Wallet session key can be authorized for.
- signer_
limit - Per-signer token-bucket limits for CLOB trading.
Macros§
- client_
config_ setters - Generates a client builder’s five transport setters over a
ClientConfigfield:base_url,timeout_ms,pool_size,with_retry_configandmax_concurrent. - namespaces
- Generates a client’s namespace accessors: each clones the listed client fields into the same-named fields of its namespace struct.
- query_
setters - Generates a request builder’s query-parameter setters.
Functions§
- csv
- Comma-joins a multi-value query parameter;
Nonewhen the joined value is empty, so the parameter is omitted rather than sent empty. - truncate_
for_ log - Truncate a string for safe inclusion in log output.