Python SDK: Yandex Market: configured products and search
ctx.yandex_market() is the ready-made source for a Yandex Market site. Configure the permitted products, regions, scenario kind, and page limit first. Source settings and the platform handler decide which requests are allowed; arbitrary URLs do not bypass these checks.
products
ctx.yandex_market().products() -> list[str]
No arguments.
Result: list[str].
Configured product identifiers or URLs; local, no request.
result = ctx.yandex_market().products()
regions
ctx.yandex_market().regions() -> list[str]
No arguments.
Result: list[str].
Configured region identifiers as strings. Pass a permitted value to card/search.
result = ctx.yandex_market().regions()
query
ctx.yandex_market().query() -> str
No arguments.
Result: str.
Configured search query; an empty string means no query was supplied.
result = ctx.yandex_market().query()
max_pages
ctx.yandex_market().max_pages() -> int
No arguments.
Result: int.
Configured depth constrained to 1–30 pages; default 3.
result = ctx.yandex_market().max_pages()
card
ctx.yandex_market().card(product, region_id) -> dict[str, Any]
| Argument | Type | Required | Purpose |
|---|---|---|---|
product |
str |
Yes | Product from the configured ready-made source. |
region_id |
str |
Yes | Permitted region identifier, not its display name. |
Result: dict[str, Any].
Request one configured product in the selected region. Returns the first normalized card, or an empty dictionary if absent.
market = ctx.yandex_market()
products = market.products()
regions = market.regions()
if not products or not regions:
ctx.abort('Configure products and regions')
result = market.card(products[0], regions[0])
search
ctx.yandex_market().search(region_id, page) -> dict[str, Any]
| Argument | Type | Required | Purpose |
|---|---|---|---|
region_id |
str |
Yes | Permitted region identifier, not its display name. |
page |
int |
Yes | Page number within the configured bound. |
Result: dict[str, Any].
Request a page of the configured query. Region and depth are checked by the platform. Inspect cards and page metadata before continuing.
market = ctx.yandex_market()
regions = market.regions()
if not regions:
ctx.abort('Configure a region')
result = market.search(regions[0], 1)
record
ctx.yandex_market().record(card) -> dict[str, Any]
| Argument | Type | Required | Purpose |
|---|---|---|---|
card |
dict[str, Any] |
Yes | An already fetched source card. |
Result: dict[str, Any].
Select the fields required by the configured scenario from an already fetched card. Local; does not emit automatically. Price/availability/rating scenarios keep their respective fields.
result = ctx.yandex_market().record({'ym_id': '123', 'title': 'Product'})
Network operations can fail because of source limits or unavailable browser service. Do not treat missing cards as successful complete collection. Use the run log and a trial. This helper is not an unrestricted public Market API.
Errors and execution context
All calls are synchronous. Invalid arguments or malformed source data can raise ValueError/TypeError; a platform refusal or unavailable service raises RuntimeError. Missing elements/values return None or an empty collection only where explicitly documented. Do not convert every exception into an empty successful result. External-service methods are unavailable in export transformations; see transformation limits and environment.