Skip to content

Returns Module

The Returns module (sdk.returns) is an aggregator introduced in v3.10.0 that unifies three separate Wildberries data sources — FBO analytics, FBS order history, and Finance reports — into a single ReturnItem[]. It handles deduplication by srid, partial-failure tolerance via Promise.allSettled, per-source telemetry, and automatic reason classification.


Overview

PropertyValue
Module Namereturns
SDK Namespacesdk.returns.*
Introducedv3.10.0
Sourcessdk.reports.getAnalyticsGoodsReturn() (FBO), sdk.ordersFBS status history (FBS — deferred to v3.10.1), sdk.finances.getSalesReportsDetailed() (Finance)
Methods3
AuthenticationDelegates to underlying modules

Purpose

sdk.returns is designed to:

  • Unify FBO + Finance return data — single ReturnItem[] with finance enrichment (returnAmount, returnAmountCurrency)
  • Classify return reasons — maps free-text Russian WB reasons to stable ReturnReasonCode enum via classifyReturnReason() (called internally)
  • Surface partial failures transparently — if one source is unavailable, other sources still return data; failures reported in partialFailures
  • Report per-source telemetry_meta.sources tells you exactly how many records each source fetched, filtered, and whether it was skipped

Quick Start

typescript
import { WildberriesSDK } from 'daytona-wildberries-typescript-sdk';

const sdk = new WildberriesSDK({ apiKey: process.env.WB_API_KEY! });

// Get all returns for April 2026
const result = await sdk.returns.getReturns({
  dateFrom: '2026-04-01',
  dateTo: '2026-04-30',
});

console.log(`Total returns: ${result.total}`);
console.log(`FBO fetched: ${result._meta.sources.fbo.fetched}`);

result.data.forEach((r) => {
  console.log(r.orderId, r.returnReasonCode, r.returnAmount ?? 'pending');
});

Methods

getReturns(params: ReturnsApiRequest): Promise<ReturnsApiResponse>

Primary aggregation method. Fetches FBO returns and Finance enrichment in parallel, merges by srid, applies optional filters, and returns results with full telemetry.

Parameters:

NameTypeRequiredDescription
dateFromstringYesISO date YYYY-MM-DD. Maximum 31-day range.
dateTostringYesISO date YYYY-MM-DD.
nmIdsnumber[]NoFilter by product article numbers.
orderType'fbo' | 'fbs'NoFilter by fulfilment type.
reasonCodesReturnReasonCode[]NoFilter by classified reason code.

See also: Full guide with 4 recipes →


getReturnByOrderId(orderId: string, params: ReturnByOrderIdParams): Promise<ReturnItem | null>

Convenience wrapper around getReturns() that filters to a single order. Returns null when no matching record is found in the date window.

Parameters:

NameTypeRequiredDescription
orderIdstringYesWB order ID (string, BigInt-safe).
params.dateFromstringYesSame semantics as getReturns().
params.dateTostringYesSame semantics as getReturns().
params.orderType'fbo' | 'fbs'NoNarrows which source to query.

getReturnStats(params: ReturnStatsParams): Promise<ReturnStatsResult>

Calls getReturns() once and post-processes all records into aggregation buckets in memory. Useful for dashboard KPIs without building your own grouping logic.

Parameters:

NameTypeRequiredDescription
dateFromstringYesISO date.
dateTostringYesISO date.
groupBy'nmId' | 'category' | 'orderType'YesAggregation dimension.
nmIdsnumber[]NoPre-filter passed to getReturns().
orderType'fbo' | 'fbs'NoPre-filter passed to getReturns().

Key Types

TypeKindDescription
ReturnIteminterfaceSingle unified return record
ReturnStatustype alias'initiated' | 'received' | 'processed'
ReturnCategorytype alias'cancel_before_shipment' | 'refusal_at_pvz' | 'return_after_receipt' | 'unknown'
FbsStatusEventinterfaceFBS status history event used by classifyFbsReturnCategory()
ReturnsApiRequestinterfaceInput params for getReturns()
ReturnsApiResponseinterfaceResponse from getReturns()
PartialFailureinterfaceDescribes a source that failed during aggregation
ReturnsMetainterfacePer-source telemetry in every response
ReturnByOrderIdParamsinterfaceParams for getReturnByOrderId()
ReturnStatsParamsinterfaceParams for getReturnStats()
ReturnStatsResultinterfaceAggregated stats with buckets
ReturnStatsBucketinterfaceSingle aggregation bucket (one nmId / category / orderType)

Helper Function

classifyFbsReturnCategory(statuses: FbsStatusEvent[]): ReturnCategory

Standalone helper (exported from root index) that analyzes a chronological FBS status event array and maps it to a stable ReturnCategory. Called internally by ReturnsModule for FBS records.

See also: API reference →


Known Limitations

LimitationDetails
No webhooksPoll getReturns() every 5–15 min
No in_transit statusReturnStatus excludes intermediate states
Free-text reasonsUse returnReasonCode (auto-classified) not returnReason
Weekly finance cadencereturnAmount may be undefined for returns within ~7 days
returnCategory: 'unknown' for FBOFBS implementation deferred to v3.10.1
31-day max date rangeChunk manually for longer periods
No vendorCode for FBOAlways undefined for FBO records

Made with ❤️ for the Wildberries developer community