Skip to content

Products & Barcodes

Look up products by EAN barcode and generate QR codes.

ProductsClient

Sub-client for barcode / QR-code product lookup endpoints.

Accessed via HomeboxClient.products.

Source code in homebox/client.py
class ProductsClient:
    """Sub-client for barcode / QR-code product lookup endpoints.

    Accessed via ``HomeboxClient.products``.
    """

    def __init__(self, client: HomeboxClient):
        """Initialise the products sub-client with the shared root client."""
        self.client = client

    def search_ean_from_barcode(self, data: str | None = None) -> list[BarcodeProduct]:
        """Look up product information by EAN/barcode string.

        Queries external product databases and returns matching product details
        that can be used to pre-fill a new item.

        Args:
            data: EAN-13 or other barcode string to look up.

        Returns:
            list[BarcodeProduct]: Matching products from one or more search
                engines.  Each result may include manufacturer, model number,
                notes, an image, and a pre-populated :class:`ItemCreate` payload.
        """
        params = {}
        if data:
            params["data"] = data
        resp = self.client._request("get", "/v1/products/search-from-barcode", params=params)
        return [BarcodeProduct(**item) for item in resp.get("data", [])]

    def create_qr_code(self, data: str | None = None) -> bytes:
        """Generate a QR code image for an arbitrary string.

        Args:
            data: The string to encode in the QR code (e.g. a URL or asset ID).

        Returns:
            bytes: QR code image content (SVG or PNG depending on server config).
        """
        params = {}
        if data:
            params["data"] = data
        return self.client._get("/v1/qrcode", params=params, binary=True)

__init__

__init__(client: HomeboxClient)

Initialise the products sub-client with the shared root client.

Source code in homebox/client.py
def __init__(self, client: HomeboxClient):
    """Initialise the products sub-client with the shared root client."""
    self.client = client

search_ean_from_barcode

search_ean_from_barcode(data: str | None = None) -> list[BarcodeProduct]

Look up product information by EAN/barcode string.

Queries external product databases and returns matching product details that can be used to pre-fill a new item.

Parameters:

Name Type Description Default
data str | None

EAN-13 or other barcode string to look up.

None

Returns:

Type Description
list[BarcodeProduct]

list[BarcodeProduct]: Matching products from one or more search engines. Each result may include manufacturer, model number, notes, an image, and a pre-populated :class:ItemCreate payload.

Source code in homebox/client.py
def search_ean_from_barcode(self, data: str | None = None) -> list[BarcodeProduct]:
    """Look up product information by EAN/barcode string.

    Queries external product databases and returns matching product details
    that can be used to pre-fill a new item.

    Args:
        data: EAN-13 or other barcode string to look up.

    Returns:
        list[BarcodeProduct]: Matching products from one or more search
            engines.  Each result may include manufacturer, model number,
            notes, an image, and a pre-populated :class:`ItemCreate` payload.
    """
    params = {}
    if data:
        params["data"] = data
    resp = self.client._request("get", "/v1/products/search-from-barcode", params=params)
    return [BarcodeProduct(**item) for item in resp.get("data", [])]

create_qr_code

create_qr_code(data: str | None = None) -> bytes

Generate a QR code image for an arbitrary string.

Parameters:

Name Type Description Default
data str | None

The string to encode in the QR code (e.g. a URL or asset ID).

None

Returns:

Name Type Description
bytes bytes

QR code image content (SVG or PNG depending on server config).

Source code in homebox/client.py
def create_qr_code(self, data: str | None = None) -> bytes:
    """Generate a QR code image for an arbitrary string.

    Args:
        data: The string to encode in the QR code (e.g. a URL or asset ID).

    Returns:
        bytes: QR code image content (SVG or PNG depending on server config).
    """
    params = {}
    if data:
        params["data"] = data
    return self.client._get("/v1/qrcode", params=params, binary=True)