TypeScript SDK: Yandex Market: Products and Search
ctx.yandexMarket() uses the current scenario's selected products, phrase and cities. Result fields and price conditions match PHP. Network methods require await.
products
products() → string[] returns selected keys such as card:103324529910.
regions
regions() → string[] returns selected city codes.
query
query() → string returns the configured search phrase.
maxPages
maxPages() → number returns a depth from 1 to 30 pages.
card
card(product, regionId) → Promise<Record> retrieves a selected product. price_rub is the price without the Yandex Pay card; pay_price_rub is the card price. Missing values are null. Failed pages raise errors rather than implying that a product is unavailable.
const source = ctx.yandexMarket();
for (const region of source.regions()) {
for (const product of source.products()) {
const card = await source.card(product, region);
ctx.emit(source.record(card), `${card.ym_kind}:${card.ym_id}:${region}`);
}
}
search
search(regionId, page) → Promise<{ cards, page, total, has_next }> retrieves a configured search page. Follow has_next. Page sizes vary and total can be null. search_page and position_on_page describe an observed page position, not a universal ranking. Compare product properties and payment conditions before comparing prices.
record
record(card) → Record selects the current template's fields while retaining identifiers, city, title, link and images.