Comprehensive collection of practical examples demonstrating how to use the Wildberries TypeScript SDK.
- Quick Navigation
- Prerequisites
- Running Examples
- Getting Started
- Products Module
- Orders Module
- Supply Planning Module
- Finances Module
- Analytics Module
- Communications Module
- Other Modules
- Integration Examples
- Configuration
- Error Handling
- Best Practices
- Troubleshooting
Perfect for getting started with the SDK and understanding basic concepts.
| Example | Module | Time | Description |
|---|---|---|---|
| quickstart.ts | General | 5 min | SDK initialization and connectivity testing |
| general.ts | General | 10 min | General module endpoints and features |
| products-categories.ts | Products | 10 min | Navigate product category hierarchy |
| products-crud.ts | Products | 15 min | Basic product creation and management |
| orders-fbs-processing.ts | Orders FBS | 10 min | Fetch and process FBS orders |
| finances-balance-transactions.ts | Finances | 10 min | Check balance and transaction history |
| customer-support.ts | Communications | 15 min | Basic customer chat management |
| supply-cost-calculator.ts | Supply Planning | 10 min | Calculate FBW supply costs |
| tariff-comparison.ts | Supply Planning | 10 min | Compare inventory vs supply tariffs |
Build on basic knowledge with more complex workflows and multi-step processes.
| Example | Module | Time | Description |
|---|---|---|---|
| products-media-pricing.ts | Products | 20 min | Upload media and manage product pricing |
| products-warehouse-stock.ts | Products | 25 min | Complete inventory management workflow |
| complete-product-workflow.ts | Products | 30 min | End-to-end product creation workflow |
| orders-fbs-fulfillment.ts | Orders FBS | 25 min | Complete FBS order fulfillment process |
| orders-fbw-fulfillment.ts | Orders FBW | 30 min | FBW supply planning and management |
| supplies-planning.ts | Supply Planning | 25 min | Complete supply planning workflow |
| in-store-pickup-workflow.ts | In-Store Pickup | 25 min | Manage Click & Collect orders |
| finances-reports-payouts.ts | Finances | 20 min | Generate reports and track payouts |
| analytics-dashboard.ts | Analytics | 25 min | Build analytics dashboard with key metrics |
| reports-analytics.ts | Reports | 20 min | Generate advanced analytics reports |
| customer-engagement.ts | Communications | 25 min | Manage reviews, questions, and feedback |
| tariffs-pricing-calculator.ts | Tariffs | 20 min | Calculate costs and seller payouts |
| promotion-campaign-automation.ts | Promotion | 25 min | Automate advertising campaign management |
| communications-customer-engagement.ts | Communications | 30 min | Complete customer communications workflow |
Complex multi-module integrations and comprehensive business workflows.
| Example | Module | Time | Description |
|---|---|---|---|
| integration-product-order-finance.ts | Multi-Module | 45 min | Product β Order β Finance integration |
| business-dashboard.ts | Multi-Module | 50 min | Real-time business intelligence dashboard |
| financial-reconciliation.ts | Multi-Module | 40 min | Reconcile sales, returns, and payments |
| export-to-bi.ts | Multi-Module | 60 min | Export data to external BI platforms |
- products-categories.ts - Navigate category hierarchy (π’ 10 min)
- products-crud.ts - Create, update, delete products (π’ 15 min)
- products-media-pricing.ts - Manage media and pricing (π‘ 20 min)
- complete-product-workflow.ts - Complete product lifecycle (π‘ 30 min)
- products-warehouse-stock.ts - Warehouse and stock operations (π‘ 25 min)
- orders-fbw-fulfillment.ts - FBW supply planning (π‘ 30 min)
- supplies-planning.ts - Complete supply workflow (π‘ 25 min)
- supply-cost-calculator.ts - Calculate supply costs (π’ 10 min)
- tariff-comparison.ts - Compare tariff types (π’ 10 min)
- orders-fbs-processing.ts - FBS order processing (π’ 10 min)
- orders-fbs-fulfillment.ts - Complete FBS fulfillment (π‘ 25 min)
- orders-fbw-fulfillment.ts - FBW fulfillment (π‘ 30 min)
- in-store-pickup-workflow.ts - In-store pickup (π‘ 25 min)
- finances-balance-transactions.ts - Balance and transactions (π’ 10 min)
- finances-reports-payouts.ts - Reports and payouts (π‘ 20 min)
- financial-reconciliation.ts - Financial reconciliation (π΄ 40 min)
- tariffs-pricing-calculator.ts - Cost calculation (π‘ 20 min)
- analytics-dashboard.ts - Analytics dashboard (π‘ 25 min)
- reports-analytics.ts - Advanced reports (π‘ 20 min)
- business-dashboard.ts - Business intelligence (π΄ 50 min)
- export-to-bi.ts - BI tool export (π΄ 60 min)
- customer-support.ts - Chat and support (π’ 15 min)
- customer-engagement.ts - Reviews and Q&A (π‘ 25 min)
- communications-customer-engagement.ts - Complete communications (π‘ 30 min)
- promotion-campaign-automation.ts - Campaign automation (π‘ 25 min)
- integration-product-order-finance.ts - Product-Order-Finance flow (π΄ 45 min)
- business-dashboard.ts - Business dashboard (π΄ 50 min)
- financial-reconciliation.ts - Financial reconciliation (π΄ 40 min)
- export-to-bi.ts - BI export (π΄ 60 min)
| Module | Examples Count | Complexity Range |
|---|---|---|
| General | 2 | π’ Basic |
| Products | 5 | π’ Basic β π‘ Intermediate |
| Orders FBS | 2 | π’ Basic β π‘ Intermediate |
| Orders FBW | 1 | π‘ Intermediate |
| Supply Planning | 3 | π’ Basic β π‘ Intermediate |
| In-Store Pickup | 1 | π‘ Intermediate |
| Finances | 3 | π’ Basic β π΄ Advanced |
| Analytics | 2 | π‘ Intermediate |
| Reports | 1 | π‘ Intermediate |
| Communications | 3 | π’ Basic β π‘ Intermediate |
| Tariffs | 1 | π‘ Intermediate |
| Promotion | 1 | π‘ Intermediate |
| Multi-Module | 4 | π΄ Advanced |
Total: 27 examples covering all SDK modules and common business workflows.
- Get your API key from the Wildberries seller portal: https://seller.wildberries.ru/
- Set environment variable:
export WB_API_KEY="your-api-key-here"
- Node.js version: >= 20.0.0
- Install SDK:
npm install wb-api-sdk
All examples can be run using tsx (TypeScript execute):
# Install tsx globally (if not already installed)
npm install -g tsx
# Run any example
npx tsx examples/quickstart.tsComplexity: π’ Beginner | Time: 5 minutes
Purpose: Basic SDK usage and connectivity testing
Demonstrates:
- SDK initialization with API key
- Testing API connectivity (ping)
- Fetching seller information
- Retrieving news updates
- Proper error handling
Run it:
npx tsx examples/quickstart.tsExpected Output:
β
Connectivity OK
β
Seller: Example Company LLC
π° Latest News: 3 items
Complexity: π’ Beginner | Time: 10 minutes
Purpose: Comprehensive demonstration of General module endpoints
Demonstrates:
- Ping endpoint for connectivity testing
- News retrieval with pagination
- Seller information lookup
- All General module capabilities
Run it:
npx tsx examples/general.tsComplexity: π’ Beginner | Time: 10 minutes
Purpose: Navigate the Wildberries product category system
Demonstrates:
- Fetching parent categories (top-level)
- Getting subjects (subcategories)
- Retrieving product characteristics
- Understanding category hierarchy
Key Concepts:
- Parent Categories: Top-level (e.g., Electronics, Clothing)
- Subjects: Specific product types (e.g., Smartphones, T-Shirts)
- Characteristics: Required and optional product attributes
Run it:
npx tsx examples/products-categories.tsComplexity: π’ Beginner | Time: 15 minutes
Purpose: Complete product lifecycle management
Demonstrates:
- Creating product cards with characteristics
- Listing products with pagination and filters
- Updating product details
- Deleting products (moving to trash)
- Bulk operations handling
- Error handling for product operations
Key Operations:
- Create: Add new products to catalog
- Read: List and search products
- Update: Modify product information
- Delete: Soft delete (30-day auto-removal)
Run it:
npx tsx examples/products-crud.tsExpected Output:
β
Product created (ID: created)
β
Found 1 products
β
Product updated
β
Products moved to trash (auto-delete in 30 days)
Complexity: π‘ Intermediate | Time: 20 minutes
Purpose: Manage product images and pricing
Demonstrates:
- Uploading product images (files or URLs)
- Managing media gallery
- Setting product prices
- Bulk pricing updates
- Price task tracking (async operations)
- Handling pricing errors
Key Concepts:
- Media Upload: Support for file upload and URL import
- Pricing Tasks: Asynchronous pricing update operations
- Bulk Operations: Update prices for multiple SKUs
- Error Handling: Validation and rate limit management
Run it:
npx tsx examples/products-media-pricing.tsComplexity: π‘ Intermediate | Time: 25 minutes
Purpose: Complete inventory management workflow
Demonstrates:
- Getting available WB warehouses for FBS binding
- Creating seller warehouses bound to WB offices
- Managing stock levels (add, update, delete)
- Bulk stock operations (up to 1000 SKUs)
- Understanding warehouse restrictions
- WARNING: Stock deletion is irreversible!
Key Concepts:
- WB Offices: Wildberries pickup points for FBS
- Seller Warehouses: Your warehouses bound to WB offices
- Stock Operations: Add, update, delete stock levels
- Irreversible Actions: Stock deletion cannot be undone
Run it:
export WB_API_KEY="your-api-key"
npx tsx examples/products-warehouse-stock.tsPrerequisites:
# Required
export WB_API_KEY="your-api-key"
# Optional: For bulk operations demo
export WB_WAREHOUSE_ID="your-warehouse-id"Complexity: π‘ Intermediate | Time: 30 minutes
Purpose: Complete product creation workflow from category to stock
Demonstrates:
- Category navigation (parent β subject β characteristics)
- Product creation with required characteristics
- Product verification and listing
- Pricing configuration (async task-based)
- Stock level management
Complete Workflow Steps:
- Category Navigation: Browse hierarchy and select category
- Product Creation: Build product with characteristics and create card
- Verification: Confirm product creation via listing
- Pricing Setup: Configure prices for product sizes
- Stock Management: Set inventory levels for SKUs
Key Integration Points:
- Cross-module data flow (Categories β Products β Pricing β Stock)
- Async task-based operations (pricing)
- Dynamic product data from category characteristics
- Real product IDs across operations
Run it:
export WB_API_KEY="your-api-key"
npx tsx examples/complete-product-workflow.tsExpected Output:
=== Complete Product Workflow ===
π Step 1: Category Navigation
β
Retrieved 15 parent categories
β
Retrieved 25 subjects
β
Retrieved 42 characteristics
π¦ Step 2: Product Creation
β
Product created (ID: created)
π Step 3: Verify Product
β
Found 1 matching products
π° Step 4: Pricing
β
Pricing task created (Price: 1999β½)
π Step 5: Stock Management
β
Stock updated (Quantity: 100 units)
β
Complete Workflow Finished!
Complexity: π’ Beginner | Time: 10 minutes
Purpose: Handle FBS (Fulfillment by Seller) order processing
Demonstrates:
- Fetching new orders awaiting processing
- Retrieving orders with date filters
- Pagination handling for large result sets
- Order status checking (supplier & WB statuses)
- Status breakdown analysis
Key Concepts:
- FBS: Seller processes and ships orders from own warehouse
- Supplier Status: Seller-controlled (new β confirm β complete)
- WB Status: System-controlled (waiting β sorted β sold)
- Pagination: Using next cursor for large result sets
- Date Filters: Unix timestamps for date range queries
Run it:
npx tsx examples/orders-fbs-processing.tsComplexity: π‘ Intermediate | Time: 25 minutes
Purpose: End-to-end FBS order fulfillment process
Demonstrates:
- Fetching new orders
- Creating supply for grouping orders
- Adding orders to supply (new β confirm status)
- Generating shipping labels (PNG, SVG, ZPL formats)
- Delivering supply (confirm β complete status)
- Getting supply QR code for tracking
- Managing supplies and cancellations
Key Concepts:
- Supply Workflow: Create β Add orders β Get stickers β Deliver β Get QR
- Cargo Type Constraints: Orders in supply must have same cargo type
- Status Transitions: new β confirm (add to supply) β complete (deliver)
- Shipping Labels: Base64-encoded in multiple formats (PNG/SVG/ZPLV/ZPLH)
- Size Options: 580Γ400px or 400Γ300px
- Supply QR Code: Only available after delivery
- Auto-Removal: Canceled orders automatically removed from supply
Run it:
export WB_API_KEY="your-api-key"
npx tsx examples/orders-fbs-fulfillment.tsGenerates Files:
order-sticker.png- PNG shipping label (580Γ400px)order-sticker.svg- SVG shipping label (580Γ400px)supply-qrcode.png- Supply QR code (580Γ400px)
Complexity: π‘ Intermediate | Time: 30 minutes
Purpose: Complete FBW warehouse supply planning and management
Demonstrates:
- Getting available WB warehouses with addresses
- Checking acceptance coefficients (next 14 days)
- Validating acceptance options for goods
- Calculating transit tariffs for delivery costs
- Listing and filtering existing supplies
- Getting detailed supply information
- Tracking goods within supplies
- Retrieving package information for logistics
Key Concepts:
- FBW: Seller ships to WB warehouse, WB handles customer delivery
- Acceptance Coefficients: -1 (unavailable), 0 (free), >0 (paid with multiplier)
- Supply Statuses: Not Planned β Planned β Allow Unload β Accepting β Accepted β Unloaded
- Box Types: Boxes (1), Monopallet (2), Supersafe (3)
- Transit Tariffs: Cost calculation for transit warehouse delivery
- Package Codes: Logistics tracking identifiers
Run it:
export WB_API_KEY="your-api-key"
npx tsx examples/orders-fbw-fulfillment.tsBest Practices:
- Check acceptance coefficients before planning delivery
- Choose dates with coefficient = 0 for free acceptance
- Validate all goods can be accepted at target warehouse
- Calculate transit costs if using transit warehouses
- Monitor supply statuses to track acceptance progress
Complexity: π‘ Intermediate | Time: 25 minutes
Purpose: Manage in-store pickup orders (C&C - Click & Collect)
Demonstrates:
- Fetching new pickup orders
- Getting order details and customer info
- Order status management workflow
- Customer identity verification
- Order confirmation and preparation
- Metadata management (SGTIN, UIN, IMEI, GTIN codes)
- Handling pickup order lifecycle
Key Concepts:
- C&C Orders: Customer buys online, picks up at store
- Status Workflow: New β Confirmed β Prepared β Received
- Customer Verification: Identity check before handover
- Metadata Codes: Product identification (SGTIN, UIN, IMEI, GTIN)
- Order Lifecycle: 3-day pickup window
Run it:
export WB_API_KEY="your-api-key"
npx tsx examples/in-store-pickup-workflow.tsExpected Output:
=== In-Store Pickup Order Management ===
π¦ New Pickup Orders: 5
β
Order confirmed (ID: 12345)
β
Customer verified
β
Order prepared for pickup
β
Metadata set (SGTIN: 12345678)
β
Order received by customer
The Supply Planning module provides utilities for calculating costs and optimizing FBW (Fulfillment by Wildberries) supply operations using the new Epic 11 utilities.
Complexity: π‘ Intermediate | Time: 25 minutes
Purpose: Complete supply planning workflow with cost optimization
Demonstrates:
- Getting available WB warehouses
- Checking acceptance coefficients for next 14 days
- Finding free acceptance dates (coefficient = 0)
- Using calculateSupplyCost utility for accurate cost estimation
- Using compareTariffs utility for FBW vs FBS comparison
- Making data-driven supply decisions
Key Concepts:
- Acceptance Coefficients: -1 (unavailable), 0 (free), >0 (paid multiplier)
- Cost Components: Acceptance + Storage + Logistics = Total
- Tariff Comparison: Inventory storage vs supply acceptance costs
- Optimization Strategy: Plan supplies on free acceptance dates
Run it:
export WB_API_KEY="your-api-key"
npx tsx examples/supplies-planning.tsExpected Output:
=== Supply Planning Workflow ===
Step 1: Getting available warehouses...
Found 15 active warehouses
Step 2: Checking acceptance coefficients...
Warehouses with free acceptance: 5
Step 3: Calculating supply costs...
Supply Cost Breakdown:
Acceptance: 0.00 RUB (free)
Storage (30 days): 150.00 RUB
Logistics: 45.00 RUB
TOTAL: 195.00 RUB
Step 4: Comparing FBW vs FBS tariffs...
RECOMMENDATION: SUPPLY_CHEAPER
-> Use FBW supply for lower overall costs
Step 5: Supply strategy recommendations...
RECOMMENDED SUPPLY STRATEGY:
Warehouse: Koledino
Optimal Date: 2025-01-28
Acceptance: FREE (coefficient = 0)
Complexity: π’ Beginner | Time: 10 minutes
Purpose: Calculate and compare FBW supply costs across warehouses
Demonstrates:
- Using the calculateSupplyCost utility function
- Understanding cost breakdown (acceptance, storage, logistics)
- Calculating costs for different volumes
- Comparing costs across multiple warehouses
- Finding the cheapest warehouse for given parameters
- Analyzing volume and duration impact on costs
Key Concepts:
- Volume Scaling: How costs change with supply volume
- Storage Duration: Impact of storage days on total cost
- Cost Per Liter: Efficiency metric for comparing options
- Applied Coefficients: Understanding how coefficients affect costs
Run it:
export WB_API_KEY="your-api-key"
npx tsx examples/supply-cost-calculator.tsExpected Output:
=== Supply Cost Calculator ===
Parameters: 10L volume, 30 days storage, box type
Cost Breakdown for Warehouse: Koledino
Acceptance: 0.00 RUB
Storage: 150.00 RUB
Logistics: 45.00 RUB
TOTAL: 195.00 RUB
Cost Comparison Across Warehouses:
1. Koledino: 195.00 RUB (19.50 RUB/L) [FREE acceptance]
2. Kazan: 210.00 RUB (21.00 RUB/L)
3. Krasnodar: 225.00 RUB (22.50 RUB/L)
Volume Cost Scaling:
1L | 25.00 RUB | 25.00 RUB/L
5L | 110.00 RUB | 22.00 RUB/L
10L | 195.00 RUB | 19.50 RUB/L
25L | 450.00 RUB | 18.00 RUB/L
Complexity: π’ Beginner | Time: 10 minutes
Purpose: Compare inventory storage vs supply acceptance tariffs
Demonstrates:
- Using the compareTariffs utility function
- Understanding inventory vs supply tariff APIs
- Interpreting recommendation results
- Making data-driven fulfillment decisions
- Comparing multiple warehouses
Key Concepts:
- Inventory Storage (tariffs/box): Tariffs for goods already in WB warehouses
- Supply Acceptance (acceptance/coefficients): Tariffs for new shipments
- Recommendations: SUPPLY_CHEAPER, INVENTORY_CHEAPER, or EQUAL
- Decision Making: When to use each fulfillment method
Run it:
export WB_API_KEY="your-api-key"
npx tsx examples/tariff-comparison.tsExpected Output:
=== Tariff Comparison Tool ===
Warehouse: Koledino
==================================================
Inventory Storage Tariffs (tariffs/box API):
Delivery base: 45.00 RUB/L
Storage base: 5.00 RUB/L/day
Supply Acceptance Tariffs (acceptance/coefficients API):
Delivery base: 40.00 RUB/L
Storage base: 4.50 RUB/L/day
Difference (Supply vs Inventory):
Delivery base: -11.1% (supply cheaper)
Storage base: -10.0% (supply cheaper)
RECOMMENDATION: SUPPLY_CHEAPER
FBW supply has lower base costs. Consider sending new shipments via supply acceptance.
Summary:
Supply cheaper: 3 warehouses
Inventory cheaper: 1 warehouses
Equal costs: 1 warehouses
Complexity: π’ Beginner | Time: 10 minutes
Purpose: Monitor financial balance and transaction history
Demonstrates:
- Getting current account balance
- Fetching transaction history with filters
- Transaction detail retrieval
- Date range filtering
- Transaction type analysis
- Balance change tracking
Key Concepts:
- Balance Types: Available, Pending, Blocked
- Transaction Types: Sales, Returns, Fees, Payouts
- Date Filters: Unix timestamps for period selection
- Transaction Details: Full breakdown of each transaction
Run it:
export WB_API_KEY="your-api-key"
npx tsx examples/finances-balance-transactions.tsExpected Output:
=== Financial Balance & Transactions ===
π° Current Balance: 125,450.50β½
Available: 100,000β½
Pending: 25,450.50β½
π Recent Transactions (Last 30 days):
Sales: 50 transactions (+150,000β½)
Returns: 5 transactions (-15,000β½)
Fees: 10 transactions (-9,549.50β½)
Complexity: π‘ Intermediate | Time: 20 minutes
Purpose: Generate financial reports and track payouts
Demonstrates:
- Financial report generation (async workflow)
- Report status checking and downloading
- Payout history retrieval
- Payout detail analysis
- Report filtering by date and type
- Understanding payout schedule
Key Concepts:
- Report Types: Sales summary, Detailed transactions, Tax reports
- Async Reports: Generate β Poll status β Download
- Payout Schedule: Weekly or bi-weekly depending on contract
- Payout Details: Breakdown of amounts, fees, and deductions
- Report Formats: PDF, Excel, CSV
Run it:
export WB_API_KEY="your-api-key"
npx tsx examples/finances-reports-payouts.tsExpected Output:
=== Financial Reports & Payouts ===
π Generating Report: sales_summary
β³ Report status: processing...
β
Report completed
π₯ Download URL: https://...
πΈ Recent Payouts (Last 3 months):
2024-01: 95,000β½ (paid Jan 15)
2024-02: 105,000β½ (paid Feb 15)
2024-03: 110,000β½ (pending)
Complexity: π΄ Advanced | Time: 40 minutes
Purpose: Reconcile sales, returns, and payments for accounting
Demonstrates:
- Cross-module financial data aggregation
- Sales and returns reconciliation
- Fee calculation verification
- Payout matching with transactions
- Discrepancy detection
- Financial reporting for accounting
Key Concepts:
- Reconciliation: Matching orders, transactions, and payouts
- Fee Verification: Confirming commission and service fees
- Accounting Export: Preparing data for accounting systems
- Discrepancy Handling: Identifying and resolving mismatches
Run it:
export WB_API_KEY="your-api-key"
npx tsx examples/financial-reconciliation.tsComplexity: π‘ Intermediate | Time: 25 minutes
Purpose: Build comprehensive analytics dashboard with key metrics
Updated in v2.7.0: Now uses the v3 Sales Funnel methods (
getSalesFunnelProducts,getSalesFunnelProductsHistory,getSalesFunnelGroupedHistory) which replace the deprecated v2createNmReportDetail/createDetailHistory/createGroupedHistorymethods. See the Analytics v3 Migration Guide for details.
Demonstrates:
- Sales funnel analysis using v3 API (impressions β clicks β orders)
- Product performance metrics via
getSalesFunnelProducts() - Historical statistics over time periods via
getSalesFunnelProductsHistory() - Grouped analytics via
getSalesFunnelGroupedHistory() - Search query analysis
- Category performance tracking
- Stock history monitoring
- CSV report generation
Key Metrics:
- Sales Funnel: Conversion rates at each stage
- Product KPIs: Revenue, units sold, average price
- Search Performance: Query popularity and conversion
- Category Analysis: Best/worst performing categories
- Inventory Trends: Stock levels over time
Run it:
export WB_API_KEY="your-api-key"
npx tsx examples/analytics-dashboard.tsExpected Output:
=== Analytics Dashboard ===
π Sales Funnel (Last 30 days):
Impressions: 50,000
Clicks: 5,000 (10% CTR)
Add to Cart: 1,000 (20% conversion)
Orders: 500 (50% checkout rate)
π Top Products:
1. Product A: 150 units, 75,000β½
2. Product B: 120 units, 60,000β½
π Top Search Queries:
1. "wireless headphones" β 45 orders
2. "smart watch" β 32 orders
Complexity: π‘ Intermediate | Time: 20 minutes
Purpose: Generate advanced analytics reports
Demonstrates:
- Sales reports (incomes data)
- Stock reports (warehouse inventory)
- Order reports (fulfillment statistics)
- Sales analysis by period
- Custom report generation
- Warehouse remains reporting
Key Concepts:
- Report Types: Incomes, Stocks, Orders, Sales
- Time Periods: Daily, Weekly, Monthly aggregation
- Warehouse Data: Stock levels, movements, discrepancies
- Custom Reports: Flexible filtering and grouping
Run it:
export WB_API_KEY="your-api-key"
npx tsx examples/reports-analytics.tsComplexity: π’ Beginner | Time: 15 minutes
Purpose: Manage customer communications and support tickets
Demonstrates:
- Fetching customer chats
- Reading chat events and messages
- Sending messages to customers
- Event pagination handling
- Customer message filtering
- Chat event types (messages, attachments, system events)
Key Concepts:
- Chat Events: Messages, attachments, system notifications
- Event Types: Client messages, seller replies, system updates
- Pagination: Cursor-based event history navigation
- Reply Sign: Unique identifier for responding to chats
- Message Filtering: Separate customer vs seller messages
Run it:
export WB_API_KEY="your-api-key"
npx tsx examples/customer-support.tsExpected Output:
=== Customer Support ===
π¬ Active Chats: 15
π§ New Messages: 8
Recent Messages:
π€ Customer: "When will my order arrive?"
π’ You: "Your order is being processed..."
β
Message sent
Complexity: π‘ Intermediate | Time: 25 minutes
Purpose: Manage reviews, questions, and customer feedback
Demonstrates:
- Fetching product reviews
- Reading customer questions
- Responding to reviews
- Answering product questions
- Marking questions as viewed
- Review and question filtering
- Managing feedback workflow
Key Concepts:
- Reviews: Customer product reviews with ratings
- Questions: Product questions from customers
- Response Management: Answer questions, respond to reviews
- Moderation: Mark questions as viewed/answered
- Filtering: By product, rating, status, date
Run it:
export WB_API_KEY="your-api-key"
npx tsx examples/customer-engagement.tsComplexity: π‘ Intermediate | Time: 30 minutes
Purpose: End-to-end customer communications management
Demonstrates:
- Chat management (fetch, read, reply)
- Review management (read, respond, edit responses)
- Question management (answer, mark viewed)
- Event-driven communication handling
- Multi-channel customer engagement
Key Concepts:
- Multi-Channel: Chats, Reviews, Questions in one workflow
- Event-Driven: Real-time event processing
- Customer Journey: From question to review to support
- Response Templates: Standardized responses for common queries
Run it:
export WB_API_KEY="your-api-key"
npx tsx examples/communications-customer-engagement.tsComplexity: π‘ Intermediate | Time: 20 minutes
Purpose: Calculate total costs and seller payout for products
Demonstrates:
- Fetching commission rates by category
- Getting storage tariffs (daily rate per liter)
- Calculating logistics costs (delivery and return)
- Computing total fees breakdown
- Net seller payout calculation
- Cost analysis by fulfillment model
Key Concepts:
- Commission Rates: Category-specific percentages (FBS, FBW, DBS, C&C)
- Storage Fees: Daily cost per liter based on warehouse
- Logistics Costs: Delivery to customer + return handling
- Total Cost: Commission + Storage + Logistics
- Net Payout: Sale Price - Total Cost
Run it:
export WB_API_KEY="your-api-key"
npx tsx examples/tariffs-pricing-calculator.tsExpected Output:
=== Tariffs Pricing Calculator ===
Product: Wireless Headphones
Sale Price: 5,000β½
π° Cost Breakdown:
Commission (15%): 750β½
Storage (30 days): 45β½
Logistics: 150β½
βββββββββββββββββ
Total Fees: 945β½
π΅ Net Payout: 4,055β½ (81% of sale price)
Complexity: π‘ Intermediate | Time: 25 minutes
Purpose: Automate advertising campaign management
Demonstrates:
- Creating advertising campaigns
- Setting campaign budgets
- Configuring bids for products
- Campaign performance tracking
- Pausing and resuming campaigns
- Budget management
- Bid optimization
Key Concepts:
- Campaign Types: Search, Carousel, Banner, Catalog
- Bidding: CPC (Cost Per Click) bid management
- Budget Control: Daily budget limits and deposits
- Performance Metrics: Impressions, clicks, CTR, conversions
- Automation: Scheduled campaign management
Run it:
export WB_API_KEY="your-api-key"
npx tsx examples/promotion-campaign-automation.tsExpected Output:
=== Promotion Campaign Automation ===
π’ Campaign Created: "Spring Sale"
Budget: 10,000β½/day
Products: 50
Avg Bid: 15β½
π Performance (Last 7 days):
Impressions: 100,000
Clicks: 5,000 (5% CTR)
Orders: 250 (5% conversion)
ROAS: 3.2x
Complexity: π΄ Advanced | Time: 45 minutes
Purpose: Demonstrate cross-module data flow and integration
Demonstrates:
- Product creation β Order processing β Financial tracking
- Data flow across modules
- Asynchronous workflow coordination
- Transaction tracking from product to payout
- End-to-end business process automation
Complete Integration Flow:
- Product Module: Create product and set pricing
- Orders Module: Process orders for the product
- Finances Module: Track transactions and payouts
- Analytics Module: Monitor performance metrics
Key Integration Points:
- Product ID links to orders
- Order ID links to transactions
- Transaction ID links to payouts
- Cross-module data consistency
Run it:
export WB_API_KEY="your-api-key"
npx tsx examples/integration-product-order-finance.tsExpected Output:
=== Multi-Module Integration ===
π¦ Product Created: EXAMPLE-123
πΌ Orders Processing: 5 orders
π° Transactions: 5 sales totaling 25,000β½
π Analytics: 20% conversion rate
β
Complete integration cycle successful
Complexity: π΄ Advanced | Time: 50 minutes
Purpose: Real-time business metrics and KPI dashboard
Demonstrates:
- Aggregating data from multiple modules
- Calculating business KPIs
- Revenue and profit tracking
- Inventory turnover analysis
- Customer satisfaction metrics
- Real-time dashboard updates
Key KPIs:
- Revenue Metrics: Daily, weekly, monthly revenue
- Profit Margins: Gross and net profit calculations
- Inventory KPIs: Turnover rate, stock-out frequency
- Customer Metrics: Satisfaction score, repeat purchase rate
- Operational KPIs: Order fulfillment time, return rate
Run it:
export WB_API_KEY="your-api-key"
npx tsx examples/business-dashboard.tsComplexity: π΄ Advanced | Time: 60 minutes
Purpose: Export data for external BI tools and analytics platforms
Demonstrates:
- Exporting sales data in various formats
- Preparing data for BI tools (Power BI, Tableau, etc.)
- CSV/JSON export workflows
- Data transformation for analytics
- Scheduling data exports
Supported Formats:
- CSV: For Excel and spreadsheet tools
- JSON: For programmatic processing
- Parquet: For big data platforms
- Database: Direct SQL export
Integration Targets:
- Microsoft Power BI
- Tableau
- Google Data Studio
- Custom analytics platforms
Run it:
export WB_API_KEY="your-api-key"
npx tsx examples/export-to-bi.tsimport { WildberriesSDK } from 'wb-api-sdk';
const sdk = new WildberriesSDK({
apiKey: 'your-api-key'
});const sdk = new WildberriesSDK({
apiKey: 'your-api-key',
// Timeout configuration
timeout: 60000, // 60 seconds
// Retry configuration
retryConfig: {
maxRetries: 5,
retryDelay: 2000, // 2 seconds
exponentialBackoff: true,
},
// Rate limit configuration
rateLimitConfig: {
requestsPerSecond: 10,
requestsPerMinute: 100,
},
// Logging
logLevel: 'debug', // 'debug' | 'info' | 'warn' | 'error'
});All examples demonstrate comprehensive error handling patterns:
try {
const response = await sdk.general.ping();
console.log('Ping successful:', response.Status);
} catch (error) {
if (error instanceof AuthenticationError) {
console.error('β Invalid API key:', error.message);
} else if (error instanceof RateLimitError) {
console.error('β Rate limit exceeded');
console.log(`β³ Retry after: ${error.retryAfter}ms`);
} else if (error instanceof NetworkError) {
console.error('β Network error:', error.message);
} else if (error instanceof WBAPIError) {
console.error('β API error:', error.message);
}
}import { retry } from './utils/retry';
const result = await retry(
async () => await sdk.products.listProducts({ limit: 100 }),
{
maxAttempts: 3,
delayMs: 1000,
exponentialBackoff: true,
onRetry: (attempt, error) => {
console.log(`Retry attempt ${attempt}: ${error.message}`);
}
}
);async function handleRateLimiting() {
try {
const response = await sdk.products.createProduct(productData);
} catch (error) {
if (error instanceof RateLimitError) {
// Wait for retry-after period
await new Promise(resolve =>
setTimeout(resolve, error.retryAfter)
);
// Retry the operation
return await sdk.products.createProduct(productData);
}
throw error;
}
}// β
GOOD: Use environment variables
const apiKey = process.env.WB_API_KEY;
// β BAD: Hardcoded API keys
const apiKey = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';// β
GOOD: Specific error handling
try {
await sdk.products.createProduct(data);
} catch (error) {
if (error instanceof ValidationError) {
// Handle validation errors
} else if (error instanceof RateLimitError) {
// Handle rate limits
}
}
// β BAD: Generic error handling
try {
await sdk.products.createProduct(data);
} catch (error) {
console.error(error); // Too generic
}// β
GOOD: Paginate through results
let cursor: number | undefined;
const allOrders = [];
do {
const response = await sdk.ordersFBS.getOrders({ next: cursor });
allOrders.push(...response.data.orders);
cursor = response.data.next;
} while (cursor);// β
GOOD: Retry transient errors
const result = await retryWithBackoff(
() => sdk.products.updatePricing(data),
{ maxRetries: 3 }
);// β
GOOD: Pre-validation
if (!productData.vendorCode || productData.vendorCode.length > 75) {
throw new Error('Invalid vendor code');
}
await sdk.products.createProduct(productData);// β
GOOD: TypeScript provides autocomplete and type checking
import { CreateProductRequest } from 'wb-api-sdk';
const productData: CreateProductRequest = {
subjectID: 105,
variants: [{ /* ... */ }]
};// β
GOOD: Respect rate limits
const REQUESTS_PER_MINUTE = 60;
let requestCount = 0;
let resetTime = Date.now() + 60000;
async function rateLimitedRequest() {
if (Date.now() > resetTime) {
requestCount = 0;
resetTime = Date.now() + 60000;
}
if (requestCount >= REQUESTS_PER_MINUTE) {
await new Promise(resolve =>
setTimeout(resolve, resetTime - Date.now())
);
}
requestCount++;
return await sdk.products.listProducts();
}All examples can be tested end-to-end. Run the test suite:
# Test all examples
npm run test:examples
# Test specific module examples
npm run test:examples -- --grep "products"Problem: API key environment variable is missing or not exported.
Solution:
# Set environment variable (Linux/macOS)
export WB_API_KEY="your-api-key-here"
# Verify it's set
echo $WB_API_KEY
# Run example
npx tsx examples/quickstart.tsWindows (PowerShell):
$env:WB_API_KEY="your-api-key-here"
npx tsx examples/quickstart.tsProblem: API key is incorrect, expired, or has insufficient permissions.
Solution:
- Verify API key: Log into Wildberries seller portal and regenerate key
- Check permissions: Ensure API key has access to the required modules
- Test connectivity: Run
quickstart.tsto validate API key - Check for typos: Ensure no extra spaces or characters in the key
# Test your API key
export WB_API_KEY="your-new-api-key"
npx tsx examples/quickstart.tsProblem: Too many requests sent to the API in a short time period.
Solution:
- Wait for retry period: Error message includes
retryAftervalue in milliseconds - Implement delays: Add delays between batch operations
- Review rate limits: Each API module has different rate limits
Module-Specific Rate Limits:
- Products: 1 request per 10 seconds for creation
- Orders FBS: 5 requests per minute
- Communications: 1 request per minute for reviews/Q&A
- Analytics: 5 requests per minute for queries, 1 request per 2 minutes for CSV exports
// Example: Handle rate limit errors
try {
await sdk.products.createProduct(productData);
} catch (error) {
if (error instanceof RateLimitError) {
console.log(`β³ Waiting ${error.retryAfter}ms before retry...`);
await new Promise(resolve => setTimeout(resolve, error.retryAfter));
// SDK automatically retries, or retry manually here
}
}Problem: Cannot connect to Wildberries API servers.
Solution:
- Check internet connection: Verify you have connectivity
- Check firewall: Ensure outbound HTTPS (port 443) is allowed
- Verify API status: Check https://seller.wildberries.ru/ for service status
- Increase timeout: Configure longer timeout for slow connections
const sdk = new WildberriesSDK({
apiKey: process.env.WB_API_KEY!,
timeout: 60000, // 60 seconds (default: 30 seconds)
retryConfig: {
maxRetries: 5, // Retry up to 5 times
retryDelay: 2000, // 2 seconds between retries
exponentialBackoff: true // Increase delay exponentially
}
});Problem: Request data is missing required fields or has invalid values.
Solution:
- Check API requirements: Review example code for required fields
- Validate data types: Ensure correct data types (string, number, boolean)
- Review API docs: Check official Wildberries API documentation
- Use TypeScript: TypeScript will catch many validation errors at compile time
// Example: Proper validation
import { CreateProductRequest } from 'wb-api-sdk';
const productData: CreateProductRequest = {
subjectID: 105, // Required: Category subject ID
variants: [{
vendorCode: "PROD-001", // Required: Unique vendor code
barcode: "1234567890123", // Required: Valid barcode
// ... other required fields
}]
};
// TypeScript will show errors if required fields are missing
await sdk.products.createProduct(productData);Problem: SDK or dependencies not installed.
Solution:
# Install SDK (when published)
npm install wb-api-sdk
# For local development
npm install
# Build SDK
npm run build
# Install tsx for running examples
npm install -g tsxProblem: API call succeeds but returns no data.
Possible Causes:
- No data available: You may not have any orders, products, or transactions yet
- Incorrect filters: Date ranges or filters may be too restrictive
- Account setup: Seller account may not be fully configured
- Module access: API key may not have access to specific modules
Solution:
// Check response structure
const response = await sdk.products.listProducts({ limit: 10 });
if (!response.data || response.data.length === 0) {
console.log('βΉοΈ No products found. Have you created any products yet?');
console.log('Try running: npx tsx examples/products-crud.ts');
} else {
console.log(`β
Found ${response.data.length} products`);
}Problem: API request takes too long and times out.
Possible Causes:
- Large data set: Fetching too much data at once
- Slow connection: Network latency or bandwidth issues
- API performance: Wildberries API may be experiencing high load
- Report generation: Some reports take longer to generate
Solution:
// Increase timeout for large operations
const sdk = new WildberriesSDK({
apiKey: process.env.WB_API_KEY!,
timeout: 120000, // 2 minutes for large data sets
});
// Use pagination for large data sets
let cursor: number | undefined;
let allProducts = [];
do {
const response = await sdk.products.listProducts({
limit: 100, // Smaller batch size
next: cursor
});
allProducts.push(...response.data);
cursor = response.data.next;
} while (cursor);Problem: Trying to access properties on undefined or null values.
Solution:
// β BAD: No null checks
const productName = response.data.products[0].name; // Crashes if empty
// β
GOOD: Defensive programming
const products = response.data?.products || [];
if (products.length === 0) {
console.log('No products found');
return;
}
const productName = products[0]?.name || 'Unknown Product';
console.log(`Product: ${productName}`);Problem: Disk space full when downloading reports or media files.
Solution:
- Free up disk space: Delete unnecessary files
- Change download location: Use a different drive or directory
- Stream large files: Use streaming instead of loading entire file into memory
- Clean up temp files: Remove old report downloads
# Check disk space
df -h
# Clean up old reports
rm -rf /path/to/reports/old/*If you encounter an issue not listed here:
- Check Examples: Review similar examples for working patterns
- Check API Docs: https://dev.wildberries.ru/ for latest API documentation
- Enable Debug Logging: Set
logLevel: 'debug'in SDK configuration - Test with Minimal Example: Start with
quickstart.tsto isolate the issue - Check SDK Version: Ensure you're using the latest version
// Enable debug logging
const sdk = new WildberriesSDK({
apiKey: process.env.WB_API_KEY!,
logLevel: 'debug', // Shows detailed request/response logs
});- Report Issues: If you found a bug, report it at the SDK repository
- Wildberries API Documentation: https://dev.wildberries.ru/
- SDK Documentation Hub: ../docs/index.md
- Getting Started Guide: ../docs/getting-started/
- API Reference: ../docs/api/
- Best Practices: ../docs/guides/best-practices.md
- Troubleshooting: ../docs/guides/troubleshooting.md
- Type Definitions: Use your IDE's autocomplete (Ctrl+Space / Cmd+Space)
Have a useful example? Please submit a pull request!
- Focus: Keep examples focused on one topic or workflow
- Comments: Include clear comments explaining each step
- Error Handling: Add comprehensive error handling
- TypeScript: Use TypeScript for type safety
- Prerequisites: Document required setup and environment variables
- Expected Output: Show what users should expect to see
- Testing: Test your example before submitting
- Documentation: Update this README with your example
/**
* Example: [Your Example Name]
*
* Description: [What this example demonstrates]
*
* Prerequisites:
* - Wildberries API key
* - [Any other requirements]
*
* Expected Output:
* - [What users will see]
*
* @see {@link [API docs link]}
*/
import { WildberriesSDK } from '../src';
async function main() {
// 1. Initialize SDK
const sdk = new WildberriesSDK({
apiKey: process.env.WB_API_KEY!
});
try {
// 2. Your example code here
} catch (error) {
// 3. Error handling
}
}
main().catch(console.error);MIT License - see LICENSE for details