UNPKG

opensea-js

Version:

TypeScript SDK for the OpenSea marketplace helps developers build new experiences using NFTs and our marketplace data

35 lines (34 loc) 1.52 kB
/** * Options for handling rate-limited operations with retries. * This is exported for SDK consumers who may want to use executeWithRateLimit * for their own OpenSea API integrations. */ export interface RateLimitOptions { /** Logger function for logging progress */ logger?: (message: string) => void; /** Maximum number of retry attempts for rate limit errors */ maxRetries?: number; /** Base delay in ms to wait after a rate limit error if retry-after header is not present */ baseRetryDelay?: number; } /** * Execute an async operation with automatic retry on rate limit errors. * Respects the retry-after header when present, otherwise uses exponential backoff. * * @param operation The async operation to execute * @param options Configuration for rate limit handling * @returns The result of the operation * @throws The last error encountered if all retries are exhausted */ export declare function executeWithRateLimit<T>(operation: () => Promise<T>, options?: RateLimitOptions): Promise<T>; /** * Execute an array of async operations sequentially with rate limit handling. * Logs progress after each operation. * * @param operations Array of async operations to execute * @param options Configuration for rate limit handling and progress logging * @returns Array of results from each operation */ export declare function executeSequentialWithRateLimit<T>(operations: Array<() => Promise<T>>, options?: RateLimitOptions & { operationName?: string; }): Promise<T[]>;