Skip to content

Catalog provider

Store Catalog - Lookup Product Information

pythonxbox.api.provider.catalog.CatalogProvider(client)

Bases: BaseProvider

Source code in src/pythonxbox/api/provider/baseprovider.py
def __init__(self, client: "XboxLiveClient") -> None:
    """
    Initialize an the BaseProvider

    Args:
        client (:class:`XboxLiveClient`): Instance of XboxLiveClient
    """
    self.client = client

CATALOG_URL = 'https://displaycatalog.mp.microsoft.com' class-attribute instance-attribute

SEPERATOR = ',' class-attribute instance-attribute

get_products(big_ids, fields=FieldsTemplate.DETAILS, **kwargs) async

Lookup product by Big IDs.

Source code in src/pythonxbox/api/provider/catalog/__init__.py
async def get_products(
    self,
    big_ids: list[str],
    fields: FieldsTemplate = FieldsTemplate.DETAILS,
    **kwargs,
) -> CatalogResponse:
    """Lookup product by Big IDs."""
    ids = self.SEPERATOR.join(big_ids)
    params = {
        "actionFilter": "Browse",
        "bigIds": ids,
        "fieldsTemplate": fields.value,
        "languages": self.client.language.locale,
        "market": self.client.language.short_id,
    }
    url = f"{self.CATALOG_URL}/v7.0/products"
    resp = await self.client.session.get(
        url, params=params, include_auth=False, **kwargs
    )
    resp.raise_for_status()
    return CatalogResponse.model_validate_json(resp.text)

get_product_from_alternate_id(id, id_type, fields=FieldsTemplate.DETAILS, top=25, **kwargs) async

Lookup product by Alternate ID.

Source code in src/pythonxbox/api/provider/catalog/__init__.py
async def get_product_from_alternate_id(
    self,
    id: str,  # noqa: A002
    id_type: AlternateIdType,
    fields: FieldsTemplate = FieldsTemplate.DETAILS,
    top: int = 25,
    **kwargs,
) -> CatalogResponse:
    """Lookup product by Alternate ID."""
    params = {
        "top": top,
        "alternateId": id_type.value,
        "fieldsTemplate": fields.value,
        "languages": self.client.language.locale,
        "market": self.client.language.short_id,
        "value": id,
    }
    url = f"{self.CATALOG_URL}/v7.0/products/lookup"
    resp = await self.client.session.get(
        url, params=params, include_auth=False, **kwargs
    )
    resp.raise_for_status()
    return CatalogResponse.model_validate_json(resp.text)

Search for products by name.

Source code in src/pythonxbox/api/provider/catalog/__init__.py
async def product_search(
    self,
    query: str,
    platform: PlatformType = PlatformType.XBOX,
    top: int = 5,
    **kwargs,
) -> CatalogSearchResponse:
    """Search for products by name."""
    params = {
        "languages": self.client.language.locale,
        "market": self.client.language.short_id,
        "platformdependencyname": platform.value,
        "productFamilyNames": "Games,Apps",
        "query": query,
        "topProducts": top,
    }
    url = f"{self.CATALOG_URL}/v7.0/productFamilies/autosuggest"
    resp = await self.client.session.get(
        url, params=params, include_auth=False, **kwargs
    )
    resp.raise_for_status()
    return CatalogSearchResponse.model_validate_json(resp.text)