Skip to content

Wildberries API TypeScript SDK / validateBid

Function: validateBid() ​

ts
function validateBid(recommendations: BidsRecommendationsResponse, bidKopecks: number): void;

Defined in: utils/bid-validation.ts:86

Validate a desired bid against an article's recommendation range.

Throws BidOutOfRangeError (with parsed received / min / max) when the bid falls outside [min, max]. No-op (no throw) when the range can't be derived (extractBidRange returns null) — never fabricates a range from missing data.

Pure and network-free. Use this to fail fast before calling PromotionModule.updateBids, saving a rate-limit slot and avoiding a 400 round-trip. Strictly opt-in — NOT applied automatically inside updateBids.

Parameters ​

ParameterTypeDescription
recommendationsBidsRecommendationsResponseA getBidsRecommendations response for the article
bidKopecksnumberThe desired bid in kopecks (same unit as updateBids)

Returns ​

void

Throws ​

When bidKopecks is outside the recommendation range

Example ​

typescript
const reco = await sdk.promotion.getBidsRecommendations({ advertId: 1, nmId: 2 });
try {
  validateBid(reco, 150);
  await sdk.promotion.updateBids({
    bids: [{ advert_id: 1, nm_bids: [{ nm_id: 2, bid_kopecks: 150, placement: 'search' }] }],
  });
} catch (e) {
  if (e instanceof BidOutOfRangeError) console.warn(`floor is ${e.min}`);
}

Since ​

3.16.0

Made with ❤️ for the Wildberries developer community