The SDK automatically retries on connection errors, timeouts, and HTTP 408/409/429/5xx
responses with exponential backoff (starting at 0.5s, max 8s, with jitter).
// Set max retriesconst client = new Rulebook({ apiKey: "your-key", maxRetries: 5 });// Disable retries for a single requestconst noRetryClient = client.withOptions({ maxRetries: 0 });await noRetryClient.exchanges.retrieve("nasdaq");
withOptions() — Client Overrides
Create a new client with overridden settings without mutating the original:
const client = new Rulebook({ apiKey: "your-key" });// Create a variant with different timeoutconst slowClient = client.withOptions({ timeout: 120000 });// Create a variant with extra headersconst debugClient = client.withOptions({ defaultHeaders: { "X-Debug": "true" } });// Original client is unmodified
Per-Request Overrides
Every resource method accepts an options object for single-request customization:
Accessing metadata not included in the typed model
Raw response methods bypass the SDK’s automatic retry logic. If a request made
via withRawResponse fails due to a transient error (timeout, 429, 5xx), it
will not be retried automatically. Handle retries manually when using raw responses.
Using Types Directly
All response models are available for import and type annotation: