@sudowealth/schwab-api
Version:
TypeScript client for Charles Schwab API with OAuth support, market data, trading functionality, and complete type safety
36 lines (35 loc) • 1.06 kB
TypeScript
import { type Middleware } from './compose.js';
export interface RateLimitOptions {
/**
* Maximum number of requests allowed in the time window
* @default 120
*/
maxRequests: number;
/**
* Time window in milliseconds
* @default 60000 (1 minute)
*/
windowMs: number;
/**
* Advanced rate limiting options
*/
advanced?: {
/**
* Whether to apply rate limiting to retry attempts
* When false, retry attempts will skip rate limiting to avoid double counting
* @default true
*/
applyToRetries?: boolean;
};
}
/**
* Creates middleware that implements client-side rate limiting
*
* This middleware prevents your application from exceeding API rate limits
* by queueing requests that would exceed the limit, then processing them
* when the rate limit window resets.
*
* @param options Rate limit configuration options
* @returns Middleware function
*/
export declare function withRateLimit(options?: Partial<RateLimitOptions>): Middleware;