Wildberries API TypeScript SDK / BaseClient
Class: BaseClient
Defined in: client/base-client.ts:60
Base HTTP client for all Wildberries API modules
This class provides a unified HTTP interface with:
- Automatic authentication header injection
- Configurable timeouts
- Typed error transformation
- Debug logging with PII sanitization
All API modules receive a BaseClient instance via dependency injection to ensure consistent behavior across the SDK.
Examples
const config: SDKConfig = {
apiKey: 'your-api-key',
timeout: 30000,
logLevel: 'debug'
};
const client = new BaseClient(config);
// Make GET request
const data = await client.get<ProductResponse>(
'https://content-api.wildberries.ru/api/v1/products'
);const data = await client.post<CreateProductResponse>(
'https://content-api.wildberries.ru/api/v1/products',
{ brandName: 'MyBrand', title: 'Product Title' },
{ headers: { 'X-Request-ID': '123' } }
);Constructors
Constructor
new BaseClient(config: SDKConfig): BaseClient;Defined in: client/base-client.ts:83
Creates a new BaseClient instance
Parameters
| Parameter | Type | Description |
|---|---|---|
config | SDKConfig | SDK configuration object |
Returns
BaseClient
Throws
If apiKey is not provided or invalid
Example
const client = new BaseClient({
apiKey: process.env.WB_API_KEY || '',
timeout: 60000,
logLevel: 'info'
});Methods
get()
get<T>(url: string, options?: RequestOptions): Promise<T>;Defined in: client/base-client.ts:135
Make a GET request with automatic retry on transient failures
Automatically retries on network errors, 5xx server errors, and 429 rate limits. Does NOT retry on authentication errors (401/403) or validation errors (400/422).
Type Parameters
| Type Parameter | Description |
|---|---|
T | Expected response type |
Parameters
| Parameter | Type | Description |
|---|---|---|
url | string | Full URL for the request |
options? | RequestOptions | Optional request options |
Returns
Promise<T>
Promise resolving to typed response data
Throws
On 401/403 responses
Throws
On 429 responses (after retries exhausted)
Throws
On 400/422 responses
Throws
On network failures or 5xx responses (after retries exhausted)
Example
interface Product {
id: string;
name: string;
}
const product = await client.get<Product>(
'https://content-api.wildberries.ru/api/v1/products/123'
);
console.log(product.name);post()
post<T>(
url: string,
data?: unknown,
options?: RequestOptions): Promise<T>;Defined in: client/base-client.ts:197
Make a POST request with automatic retry on transient failures
Automatically retries on network errors, 5xx server errors, and 429 rate limits. Does NOT retry on authentication errors (401/403) or validation errors (400/422).
Type Parameters
| Type Parameter | Description |
|---|---|
T | Expected response type |
Parameters
| Parameter | Type | Description |
|---|---|---|
url | string | Full URL for the request |
data? | unknown | Request body data |
options? | RequestOptions | Optional request options |
Returns
Promise<T>
Promise resolving to typed response data
Throws
On 401/403 responses
Throws
On 429 responses (after retries exhausted)
Throws
On 400/422 responses
Throws
On network failures or 5xx responses (after retries exhausted)
Example
interface CreateProductRequest {
brandName: string;
title: string;
}
interface CreateProductResponse {
id: string;
}
const result = await client.post<CreateProductResponse>(
'https://content-api.wildberries.ru/api/v1/products',
{ brandName: 'MyBrand', title: 'New Product' }
);put()
put<T>(
url: string,
data?: unknown,
options?: RequestOptions): Promise<T>;Defined in: client/base-client.ts:249
Make a PUT request with automatic retry on transient failures
Automatically retries on network errors, 5xx server errors, and 429 rate limits. Does NOT retry on authentication errors (401/403) or validation errors (400/422).
Type Parameters
| Type Parameter | Description |
|---|---|
T | Expected response type |
Parameters
| Parameter | Type | Description |
|---|---|---|
url | string | Full URL for the request |
data? | unknown | Request body data |
options? | RequestOptions | Optional request options |
Returns
Promise<T>
Promise resolving to typed response data
Throws
On 401/403 responses
Throws
On 429 responses (after retries exhausted)
Throws
On 400/422 responses
Throws
On network failures or 5xx responses (after retries exhausted)
Example
const updated = await client.put<ProductResponse>(
'https://content-api.wildberries.ru/api/v1/products/123',
{ title: 'Updated Title' }
);patch()
patch<T>(
url: string,
data?: unknown,
options?: RequestOptions): Promise<T>;Defined in: client/base-client.ts:301
Make a PATCH request with automatic retry on transient failures
Automatically retries on network errors, 5xx server errors, and 429 rate limits. Does NOT retry on authentication errors (401/403) or validation errors (400/422).
Type Parameters
| Type Parameter | Description |
|---|---|
T | Expected response type |
Parameters
| Parameter | Type | Description |
|---|---|---|
url | string | Full URL for the request |
data? | unknown | Request body data |
options? | RequestOptions | Optional request options |
Returns
Promise<T>
Promise resolving to typed response data
Throws
On 401/403 responses
Throws
On 429 responses (after retries exhausted)
Throws
On 400/422 responses
Throws
On network failures or 5xx responses (after retries exhausted)
Example
const patched = await client.patch<ProductResponse>(
'https://content-api.wildberries.ru/api/v1/products/123',
{ stock: 100 }
);delete()
delete<T>(
url: string,
data?: unknown,
options?: RequestOptions): Promise<T>;Defined in: client/base-client.ts:359
Make a DELETE request with automatic retry on transient failures
Automatically retries on network errors, 5xx server errors, and 429 rate limits. Does NOT retry on authentication errors (401/403) or validation errors (400/422).
Type Parameters
| Type Parameter | Description |
|---|---|
T | Expected response type |
Parameters
| Parameter | Type | Description |
|---|---|---|
url | string | Full URL for the request |
data? | unknown | Optional request body data (RFC 7231 allows DELETE with body) |
options? | RequestOptions | Optional request options |
Returns
Promise<T>
Promise resolving to typed response data
Throws
On 401/403 responses
Throws
On 429 responses (after retries exhausted)
Throws
On 400/422 responses
Throws
On network failures or 5xx responses (after retries exhausted)
Example
// DELETE without body
await client.delete<void>(
'https://content-api.wildberries.ru/api/v1/products/123'
);
// DELETE with body (RFC 7231 allows this)
await client.delete<void>(
'https://marketplace-api.wildberries.ru/api/v3/stocks/123',
{ skus: ['SKU123', 'SKU456'] }
);