/** * Wildberries Seller API HTTP client. * * The Wildberries Seller API is split across several per-category hosts * (content, marketplace, statistics, prices, feedbacks, analytics, common, * returns, advert). `https://seller.wildberries.ru` is the *web cabinet*, NOT * an API gateway — calls must be routed to the correct category host. Every * request therefore takes an explicit `host` (see {@link HOSTS}). * * Features: per-category rate limiting (token bucket + 409 penalty handling), * per-request timeouts (AbortController), and structured WB error parsing. */ import { type RateLimitConfig } from "./rate-limiter.js"; /** Per-category API host domains. */ export declare const HOSTS: { readonly content: "content-api.wildberries.ru"; readonly prices: "discounts-prices-api.wildberries.ru"; readonly marketplace: "marketplace-api.wildberries.ru"; readonly statistics: "statistics-api.wildberries.ru"; readonly feedbacks: "feedbacks-api.wildberries.ru"; readonly analytics: "seller-analytics-api.wildberries.ru"; readonly common: "common-api.wildberries.ru"; readonly returns: "returns-api.wildberries.ru"; readonly advert: "advert-api.wildberries.ru"; }; export type WBHostKey = keyof typeof HOSTS; export type WBHost = (typeof HOSTS)[WBHostKey]; /** Finer-grained limiter keys for endpoints with their own strict caps. */ export declare const LIMITER_KEYS: { readonly paidStorageCreate: "paid_storage:create"; readonly paidStorageStatus: "paid_storage:status"; readonly paidStorageDownload: "paid_storage:download"; readonly advertBalance: "advert:balance"; }; /** * Conservative per-category rate limits. Only the strict per-endpoint caps * (paid-storage 1/min create+download, 1/5s status; prices ~10/6s) are * documented by WB; the rest are deliberately cautious and safe to tune up * after live observation. Unknown keys fall back to 300/min + 200ms. */ export declare const HOST_LIMITS: Record; export interface WBClientOptions { token: string; maxRetries?: number; /** Per-request timeout in ms (default 30000, or WB_TIMEOUT_MS env). */ timeoutMs?: number; /** Override a host domain -> domain (sandbox/testing). */ hostOverrides?: Record; } export interface RequestOptions { query?: Record; /** Rate-limiter key override (defaults to the host). */ limiterKey?: string; /** How to decode a successful body (default "json"). "text" for barcodes. */ responseType?: "json" | "text"; /** Per-call timeout override in ms. */ timeoutMs?: number; } export declare class WBClient { private readonly token; private readonly pool; private readonly maxRetries; private readonly timeoutMs; private readonly hostOverrides; constructor(options: WBClientOptions); private headers; request(method: string, host: WBHost, path: string, body?: unknown, opts?: RequestOptions): Promise; /** Parse a WB error body into a concise, human-readable message. */ private extractError; /** * Poll `fn` until `done` returns true, or `timeoutMs` elapses. Used for the * async report endpoints (e.g. paid storage: create -> poll status -> download). */ pollUntil(opts: { fn: () => Promise; done: (result: T) => boolean; intervalMs?: number; timeoutMs?: number; label?: string; }): Promise; private sleep; get(host: WBHost, path: string, query?: Record, opts?: Omit): Promise; post(host: WBHost, path: string, body?: unknown, query?: Record, opts?: Omit): Promise; put(host: WBHost, path: string, body?: unknown, query?: Record, opts?: Omit): Promise; patch(host: WBHost, path: string, body?: unknown, query?: Record, opts?: Omit): Promise; } //# sourceMappingURL=client.d.ts.map