### Installation Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Install the Supermarket Connector library using pip. ```APIDOC ## Installation ```bash pip install supermarktconnector ``` ``` -------------------------------- ### Install SupermarketConnector Package Source: https://github.com/bartmachielsen/supermarktconnector/blob/master/README.md Install the SupermarketConnector Python package using pip. This is the first step to using the library. ```bash pip install supermarktconnector ``` -------------------------------- ### GET /jumbo/products/{barcode} Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Look up a product using its barcode. ```APIDOC ## GET /jumbo/products/{barcode} ### Description Retrieve product information by its unique barcode. ### Method GET ### Parameters #### Path Parameters - **barcode** (string) - Required - The product barcode. ``` -------------------------------- ### Get Jumbo product by barcode Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Retrieves product information using a specific barcode. ```python from supermarktconnector.jumbo import JumboConnector connector = JumboConnector() # Search by barcode barcode = '8410031965902' product = connector.get_product_by_barcode(barcode) if product: print(f"Found: {product['title']}") print(f"ID: {product['id']}") print(f"Price: €{product['prices']['price']['amount'] / 100:.2f}") else: print("Product not found") ``` -------------------------------- ### AHConnector - Get Product by Barcode Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Look up a product using its GTIN/EAN barcode. ```APIDOC ## Get Product by Barcode Look up a product using its GTIN/EAN barcode. ### Method ```python connector.get_product_by_barcode(barcode: str) ``` ### Parameters #### Query Parameters - **barcode** (str) - Required - The GTIN/EAN barcode of the product. ### Request Example ```python from supermarktconnector.ah import AHConnector connector = AHConnector() # Search by barcode (GTIN/EAN) barcode = '8410031965902' product = connector.get_product_by_barcode(barcode) print(f"Product: {product['title']}") print(f"Brand: {product.get('brand', 'N/A')}") print(f"WebshopId: {product['webshopId']}") ``` ### Response #### Success Response (200) - **title** (str) - The name of the product. - **brand** (str) - The brand of the product. - **webshopId** (int) - The unique identifier for the product on the webshop. #### Response Example ```json { "title": "Smint Mint", "brand": "Smint", "webshopId": 12345 } ``` ``` -------------------------------- ### Get Product by Barcode (AHConnector) Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Look up a product using its GTIN/EAN barcode. Retrieves basic product information. ```python from supermarktconnector.ah import AHConnector connector = AHConnector() # Search by barcode (GTIN/EAN) barcode = '8410031965902' product = connector.get_product_by_barcode(barcode) print(f"Product: {product['title']}") print(f"Brand: {product.get('brand', 'N/A')}") print(f"WebshopId: {product['webshopId']}") ``` -------------------------------- ### GET /ah/bonus-products Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Retrieves all bonus products for a specific date or the current date. ```APIDOC ## GET /ah/bonus-products ### Description Iterates through all bonus products available for a specific date. ### Method GET ### Parameters #### Query Parameters - **date** (datetime) - Optional - The specific date to retrieve bonus products for. ``` -------------------------------- ### Get Jumbo product details Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Retrieves detailed information for a product using its ID or a product object. ```python from supermarktconnector.jumbo import JumboConnector connector = JumboConnector() # Get details by product ID product_id = '70942PAK' details = connector.get_product_details(product_id) product_data = details['product']['data'] print(f"Title: {product_data['title']}") print(f"Quantity: {product_data['quantity']}") print(f"Available: {product_data['available']}") # Or pass a product object from search results results = connector.search_products(query='butter', size=1) if results['products']['data']: product = results['products']['data'][0] details = connector.get_product_details(product) print(f"Details for: {details['product']['data']['title']}") ``` -------------------------------- ### GET /jumbo/categories Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Retrieve all product categories from Jumbo. ```APIDOC ## GET /jumbo/categories ### Description Retrieve a list of all available product categories from the Jumbo API. ### Method GET ``` -------------------------------- ### GET /jumbo/products Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Search for products in the Jumbo catalog with pagination support. ```APIDOC ## GET /jumbo/products ### Description Search for products in the Jumbo catalog using a query string. ### Method GET ### Parameters #### Query Parameters - **query** (string) - Required - The search term. - **page** (integer) - Optional - Page number for pagination. - **size** (integer) - Optional - Number of items per page. ``` -------------------------------- ### Get Product Details (AHConnector) Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Retrieve detailed information about a specific product by its ID (webshopId) or by passing a product object obtained from a search. ```python from supermarktconnector.ah import AHConnector connector = AHConnector() # Get details by product ID (webshopId) product_id = 177119 details = connector.get_product_details(product_id) print(f"Title: {details['title']}") print(f"Description: {details.get('summary', 'N/A')}") print(f"Unit size: {details.get('unitSize', 'N/A')}") # Or pass a product object directly search_results = connector.search_products(query='milk', size=1) if search_results['products']: product = search_results['products'][0] details = connector.get_product_details(product) print(f"Detailed info for: {details['title']}") ``` -------------------------------- ### AHConnector - Get Product Details Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Retrieve detailed information about a specific product by ID or product object. ```APIDOC ## Get Product Details Retrieve detailed information about a specific product by ID or product object. ### Method ```python connector.get_product_details(product_id_or_object: Union[int, dict]) ``` ### Parameters #### Query Parameters - **product_id_or_object** (Union[int, dict]) - Required - The webshopId of the product or a product dictionary object. ### Request Example ```python from supermarktconnector.ah import AHConnector connector = AHConnector() # Get details by product ID (webshopId) product_id = 177119 details = connector.get_product_details(product_id) print(f"Title: {details['title']}") print(f"Description: {details.get('summary', 'N/A')}") print(f"Unit size: {details.get('unitSize', 'N/A')}") # Or pass a product object directly search_results = connector.search_products(query='milk', size=1) if search_results['products']: product = search_results['products'][0] details = connector.get_product_details(product) print(f"Detailed info for: {details['title']}") ``` ### Response #### Success Response (200) - **title** (str) - The title of the product. - **summary** (str) - A brief description of the product. - **unitSize** (str) - The unit size of the product (e.g., '100g'). #### Response Example ```json { "title": "Product Title", "summary": "Detailed product description.", "unitSize": "100g" } ``` ``` -------------------------------- ### AHConnector - Get Bonus Periods Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Retrieve information about current bonus/promotional periods. ```APIDOC ## Get Bonus Periods Retrieve information about current bonus/promotional periods. ### Method ```python connector.get_bonus_periods() ``` ### Response #### Success Response (200) - **bonusPeriodId** (int) - The ID of the bonus period. - **name** (str) - The name or description of the bonus period. - **startDate** (str) - The start date of the bonus period (YYYY-MM-DD). - **endDate** (str) - The end date of the bonus period (YYYY-MM-DD). ### Request Example ```python from supermarktconnector.ah import AHConnector connector = AHConnector() # Get current bonus periods bonus_periods = connector.get_bonus_periods() for period in bonus_periods: print(f"Bonus Period: {period['name']} ({period['startDate']} to {period['endDate']})") ``` #### Response Example ```json [ { "bonusPeriodId": 123, "name": "Weekaanbieding", "startDate": "2023-10-26", "endDate": "2023-11-01" } ] ``` ``` -------------------------------- ### Get Jumbo sub-categories Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Retrieves sub-categories for a specific category. ```python from supermarktconnector.jumbo import JumboConnector connector = JumboConnector() # Get main categories categories = connector.get_categories() ``` -------------------------------- ### AHConnector - Get Sub-Categories Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Retrieve sub-categories for a specific category. ```APIDOC ## Get Sub-Categories Retrieve sub-categories for a specific category. ### Method ```python connector.get_sub_categories(category: Union[dict, int]) ``` ### Parameters #### Query Parameters - **category** (Union[dict, int]) - Required - A category dictionary object or the category ID. ### Request Example ```python from supermarktconnector.ah import AHConnector connector = AHConnector() # Get main categories first categories = connector.get_categories() # Get sub-categories for the first category if categories: sub_categories = connector.get_sub_categories(categories[0]) print(f"Sub-categories for '{categories[0]['name']}':") for sub in sub_categories: print(f" - {sub['name']} (ID: {sub['id']})") # You can also pass just the category ID sub_categories = connector.get_sub_categories(6401) ``` ### Response #### Success Response (200) - **id** (int) - The unique identifier for the sub-category. - **name** (str) - The name of the sub-category. #### Response Example ```json [ { "id": 6402, "name": "Aardappelen, groenten & salades" } ] ``` ``` -------------------------------- ### GET /ah/bonus-periods Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Retrieves all active bonus periods from Albert Heijn. ```APIDOC ## GET /ah/bonus-periods ### Description Retrieves a list of all active bonus periods, including start/end dates and associated metadata. ### Method GET ### Response #### Success Response (200) - **bonusStartDate** (string) - Start date of the bonus period - **bonusEndDate** (string) - End date of the bonus period - **urlMetadataList** (array) - List of metadata objects containing titles and URLs ``` -------------------------------- ### Get All Jumbo Promotions Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Retrieves a list of all current promotions and deals from Jumbo. The output is grouped by promotion tabs, and only the first 3 items per tab are displayed. ```python from supermarktconnector.jumbo import JumboConnector connector = JumboConnector() # Get all current promotions promotions = connector.get_all_promotions() for tab in promotions: print(f"Promotion Tab: {tab.get('title', 'Promotions')}") if 'items' in tab: for item in tab['items'][:3]: # Show first 3 print(f" - {item.get('title', 'Item')}") print("---") ``` -------------------------------- ### Get Store Details by Object or ID Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Retrieves detailed information for a specific store. Can accept a store object (e.g., from get_all_stores) or a store ID string. ```python from supermarktconnector.jumbo import JumboConnector connector = JumboConnector() # Get all stores first stores = connector.get_all_stores() if stores: # Get details for a specific store store_details = connector.get_store(stores[0]) print(f"Store: {store_details.get('name', 'N/A')}") print(f"ID: {store_details['id']}") if 'openingTimes' in store_details: print("Opening times available") # Or pass a store ID directly store_details = connector.get_store('store-id-here') ``` -------------------------------- ### AHConnector - Get Categories Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Retrieve all top-level product categories from Albert Heijn. ```APIDOC ## Get Categories Retrieve all top-level product categories from Albert Heijn. ### Method ```python connector.get_categories() ``` ### Response #### Success Response (200) - **id** (int) - The unique identifier for the category. - **name** (str) - The name of the category. - **nix18** (bool) - Indicates if the category is restricted to 18+. - **images** (list) - A list of image objects for the category. ### Request Example ```python from supermarktconnector.ah import AHConnector connector = AHConnector() # Get all main categories categories = connector.get_categories() for category in categories: print(f"ID: {category['id']}") print(f"Name: {category['name']}") print(f"18+ restricted: {category['nix18']}") if category.get('images'): print(f"Image: {category['images'][0]['url']}") print("---") ``` #### Response Example ```json [ { "id": 1, "name": "Groente & Fruit", "nix18": false, "images": [ { "url": "http://example.com/image.jpg" } ] } ] ``` ``` -------------------------------- ### Get Jumbo categories Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Retrieves the full list of product categories available at Jumbo. ```python from supermarktconnector.jumbo import JumboConnector connector = JumboConnector() # Get all categories categories = connector.get_categories() for category in categories: print(f"ID: {category['id']}") print(f"Title: {category['title']}") if category.get('image'): print(f"Image: {category['image']['url']}") print("---") ``` -------------------------------- ### Get Bonus Periods (AHConnector) Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Retrieve information about current bonus/promotional periods from Albert Heijn. This snippet initializes the connector but the actual retrieval logic is not shown. ```python from supermarktconnector.ah import AHConnector connector = AHConnector() ``` -------------------------------- ### Get All Jumbo Stores Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Retrieves a list of all Jumbo store locations. The connector must be instantiated first. Limited to the first 5 stores for display. ```python from supermarktconnector.jumbo import JumboConnector connector = JumboConnector() # Get all Jumbo stores stores = connector.get_all_stores() for store in stores[:5]: # Show first 5 print(f"Store: {store.get('name', store['id'])}") print(f"ID: {store['id']}") if 'address' in store: addr = store['address'] print(f"Address: {addr.get('street', '')} {addr.get('houseNumber', '')}, {addr.get('city', '')}") print("---") print(f"Total stores: {len(stores)}") ``` -------------------------------- ### Get Store-Specific Promotions Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Retrieves promotions available at a specific Jumbo store. Requires fetching store IDs first, then passing a store object to the function. ```python from supermarktconnector.jumbo import JumboConnector connector = JumboConnector() # Get stores stores = connector.get_all_stores() if stores: # Get promotions for a specific store store_promotions = connector.get_promotions_store(stores[0]) print(f"Promotions for store {stores[0]['id']}:") for tab in store_promotions: print(f" Category: {tab.get('title', 'N/A')}") ``` -------------------------------- ### Get Sub-Categories for a Category Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Retrieves sub-categories for a given category object or category ID. Ensure the category object has a 'title' key for display. ```python if categories: sub_categories = connector.get_sub_categories(categories[0]) print(f"Sub-categories for '{categories[0]['title']}':") for sub in sub_categories: print(f" - {sub['title']} (ID: {sub['id']})") # Or pass just the category ID sub_categories = connector.get_sub_categories('some-category-id') ``` -------------------------------- ### Get Categories from Albert Heijn Source: https://github.com/bartmachielsen/supermarktconnector/blob/master/README.md Import the AHConnector and use it to retrieve a list of product categories available at Albert Heijn. The response includes category IDs, names, and image information. ```python from supermarktconnector.ah import AHConnector connector = AHConnector() connector.get_categories() ``` ```json [ { "id": 6401, "name": "Aardappel, groente, fruit", "images": [ { "height": 400, "width": 600, "url": "https://static.ahold.com//cmgtcontent/media//002304400/000/002304468_001_groenten-fruit.png" } ], "nix18": false } ] ``` -------------------------------- ### Get Categories (AHConnector) Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Retrieve all top-level product categories from Albert Heijn. Displays category ID, name, 18+ restriction status, and image URL if available. ```python from supermarktconnector.ah import AHConnector connector = AHConnector() # Get all main categories categories = connector.get_categories() for category in categories: print(f"ID: {category['id']}") print(f"Name: {category['name']}") print(f"18+ restricted: {category['nix18']}") if category.get('images'): print(f"Image: {category['images'][0]['url']}") print("---") ``` -------------------------------- ### Get Sub-Categories (AHConnector) Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Retrieve sub-categories for a specific Albert Heijn category, either by passing the category object or its ID. Demonstrates fetching sub-categories for the first main category and by ID. ```python from supermarktconnector.ah import AHConnector connector = AHConnector() # Get main categories first categories = connector.get_categories() # Get sub-categories for the first category if categories: sub_categories = connector.get_sub_categories(categories[0]) print(f"Sub-categories for '{categories[0]['name']}':") for sub in sub_categories: print(f" - {sub['name']} (ID: {sub['id']})") # You can also pass just the category ID sub_categories = connector.get_sub_categories(6401) ``` -------------------------------- ### Initialize Jumbo Connector Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Creates a new instance of the Jumbo connector; no authentication is required. ```python from supermarktconnector.jumbo import JumboConnector # Initialize connector connector = JumboConnector() ``` -------------------------------- ### Search Products on Jumbo Source: https://github.com/bartmachielsen/supermarktconnector/blob/master/README.md Import the JumboConnector and use it to search for products. Specify the query, desired number of results (size), and page number. ```python from supermarktconnector.jumbo import JumboConnector connector = JumboConnector() connector.search_products(query='Smint', size=1, page=0) ``` ```json { "products": { "data": [ { "id": "70942PAK", "title": "Smint Peppermint Sugarfree 100 Stuks 2 x 35g", "quantityOptions": [ { "defaultAmount": 1, "minimumAmount": 1, "amountStep": 1, "unit": "pieces", "maximumAmount": 99 } ], "prices": { "price": { "currency": "EUR", "amount": 365 }, "unitPrice": { "unit": "kg", "price": { "currency": "EUR", "amount": 5214 } } }, "available": true, "productType": "Product", "quantity": "2 x 35 g", "imageInfo": { "primaryView": [ { "url": "https://ish-images-static.prod.cloud.jumbo.com/product_images/240420200540_70942PAK-1_360x360.png", "height": 360, "width": 360 } ] } } ] } } ``` -------------------------------- ### AHConnector - Search All Products (Generator) Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Iterate through all products matching a query across all pages using a generator, which is memory efficient. ```APIDOC ## Search All Products (Generator) Iterate through all products matching a query across all pages using a generator. ### Method ```python connector.search_all_products(query: str) ``` ### Parameters #### Query Parameters - **query** (str) - Required - The search term for products. ### Request Example ```python from supermarktconnector.ah import AHConnector connector = AHConnector() # Generator that yields all products across all pages all_products = connector.search_all_products(query='chocolate') # Process products one by one (memory efficient) count = 0 for product in all_products: print(f"{product['title']} - €{product.get('priceBeforeBonus', 0) / 100:.2f}") count += 1 if count >= 50: # Limit for demo break print(f"Processed {count} products") ``` ``` -------------------------------- ### Retrieve bonus products Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Iterates through bonus products for the current date or a specified date. ```python from supermarktconnector.ah import AHConnector from datetime import datetime connector = AHConnector() # Get all bonus products for today print("Today's bonus products:") count = 0 for product in connector.get_all_bonus_products(): bonus_info = product.get('discount', {}) print(f"- {product['title']}") print(f" Regular: €{product.get('priceBeforeBonus', 0) / 100:.2f}") print(f" Bonus: {bonus_info.get('text', 'N/A')}") count += 1 if count >= 10: # Limit for demo break # Get bonus products for a specific date specific_date = datetime(2024, 1, 15) for product in connector.get_all_bonus_products(date=specific_date): print(f"Bonus: {product['title']}") ``` -------------------------------- ### Search All Products Generator (AHConnector) Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Iterate through all products matching a query across all pages using a memory-efficient generator. Useful for processing large numbers of products. ```python from supermarktconnector.ah import AHConnector connector = AHConnector() # Generator that yields all products across all pages all_products = connector.search_all_products(query='chocolate') # Process products one by one (memory efficient) count = 0 for product in all_products: print(f"{product['title']} - €{product.get('priceBeforeBonus', 0) / 100:.2f}") count += 1 if count >= 50: # Limit for demo break print(f"Processed {count} products") ``` -------------------------------- ### Handle Jumbo PaginationLimitReached and HTTPError Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Demonstrates error handling for Jumbo connector, specifically catching `PaginationLimitReached` for large result sets and `requests.HTTPError` for network issues. ```python from supermarktconnector.jumbo import JumboConnector from supermarktconnector.errors import PaginationLimitReached import requests jumbo = JumboConnector() try: # This may raise PaginationLimitReached for large result sets results = jumbo.search_products(query='a', page=10, size=30) except PaginationLimitReached as e: print(f"Pagination limit exceeded: {e}") except requests.HTTPError as e: print(f"HTTP error occurred: {e}") ``` -------------------------------- ### Initialize AHConnector Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Creates a new Albert Heijn connector instance. Automatic anonymous authentication is handled. ```python from supermarktconnector.ah import AHConnector # Initialize connector (automatically obtains anonymous access token) connector = AHConnector() ``` -------------------------------- ### Search all products via generator Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Uses a generator to iterate through all products matching a query, handling pagination automatically. Note that Jumbo has a pagination limit of 30 items. ```python from supermarktconnector.jumbo import JumboConnector from supermarktconnector.errors import PaginationLimitReached connector = JumboConnector() # Generator that handles pagination automatically # Note: Jumbo has a pagination limit of 30 items try: all_products = connector.search_all_products(query='cheese') count = 0 for product in all_products: print(f"{product['title']} - €{product['prices']['price']['amount'] / 100:.2f}") count += 1 if count >= 20: break except PaginationLimitReached as e: print(f"Pagination limit reached: {e}") ``` -------------------------------- ### Retrieve active bonus periods Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Fetches all currently active bonus periods and iterates through their metadata sections. ```python periods = connector.get_bonus_periods() for period in periods: print(f"Period: {period['bonusStartDate']} to {period['bonusEndDate']}") print(f"Sections available: {len(period['urlMetadataList'])}") for meta in period['urlMetadataList']: print(f" - {meta.get('title', 'Section')}: {meta['url']}") print("---") ``` -------------------------------- ### AHConnector - Initialize Albert Heijn Connector Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Creates a new Albert Heijn connector instance with automatic anonymous authentication. ```APIDOC ## Initialize Albert Heijn Connector Creates a new Albert Heijn connector instance with automatic anonymous authentication. ### Method ```python AHConnector() ``` ### Example ```python from supermarktconnector.ah import AHConnector # Initialize connector (automatically obtains anonymous access token) connector = AHConnector() ``` ``` -------------------------------- ### Search Products (AHConnector) Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Search for products in the Albert Heijn catalog with pagination and sorting options. Access product data and pagination information from the results. ```python from supermarktconnector.ah import AHConnector connector = AHConnector() # Search for products by query results = connector.search_products(query='Smint', page=0, size=10, sort='RELEVANCE') # Access product data for product in results['products']: print(f"Product: {product['title']}") print(f"Price: €{product['priceBeforeBonus'] / 100:.2f}") print(f"WebshopId: {product['webshopId']}") print("---") # Pagination info print(f"Total pages: {results['page']['totalPages']}") print(f"Total products: {results['page']['totalElements']}") ``` -------------------------------- ### Search Jumbo products Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Performs a product search in the Jumbo catalog with pagination support. ```python from supermarktconnector.jumbo import JumboConnector connector = JumboConnector() # Search for products results = connector.search_products(query='Smint', page=0, size=10) # Access product data for product in results['products']['data']: print(f"ID: {product['id']}") print(f"Title: {product['title']}") print(f"Price: €{product['prices']['price']['amount'] / 100:.2f}") print(f"Available: {product['available']}") print(f"Quantity: {product['quantity']}") print("---") # Total count print(f"Total products found: {results['products']['total']}") ``` -------------------------------- ### Handle Albert Heijn HTTPError and SupermarktConnectorException Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Shows error handling for the Albert Heijn connector, catching `requests.HTTPError` for API errors and `SupermarktConnectorException` for connector-specific issues. ```python from supermarktconnector.ah import AHConnector from supermarktconnector.errors import SupermarktConnectorException import requests ah = AHConnector() try: product = ah.get_product_by_barcode('invalid-barcode') except requests.HTTPError as e: print(f"Product not found or API error: {e.response.status_code}") except SupermarktConnectorException as e: print(f"Connector error: {e}") ``` -------------------------------- ### AHConnector - Search Products Source: https://context7.com/bartmachielsen/supermarktconnector/llms.txt Search for products in the Albert Heijn catalog with pagination and sorting options. ```APIDOC ## Search Products Search for products in the Albert Heijn catalog with pagination and sorting options. ### Method ```python connector.search_products(query: str, page: int = 0, size: int = 10, sort: str = 'RELEVANCE') ``` ### Parameters #### Query Parameters - **query** (str) - Required - The search term for products. - **page** (int) - Optional - The page number to retrieve (default: 0). - **size** (int) - Optional - The number of products per page (default: 10). - **sort** (str) - Optional - The sorting order (e.g., 'RELEVANCE', 'PRICE_ASC', 'PRICE_DESC', default: 'RELEVANCE'). ### Request Example ```python from supermarktconnector.ah import AHConnector connector = AHConnector() # Search for products by query results = connector.search_products(query='Smint', page=0, size=10, sort='RELEVANCE') # Access product data for product in results['products']: print(f"Product: {product['title']}") print(f"Price: €{product['priceBeforeBonus'] / 100:.2f}") print(f"WebshopId: {product['webshopId']}") print("---") # Pagination info print(f"Total pages: {results['page']['totalPages']}") print(f"Total products: {results['page']['totalElements']}") ``` ### Response #### Success Response (200) - **products** (list) - A list of product dictionaries. - **page** (dict) - Information about the current page and total results. #### Response Example ```json { "products": [ { "title": "Smint Mint", "priceBeforeBonus": 120, "webshopId": 12345, "brand": "Smint" } ], "page": { "totalPages": 5, "totalElements": 50 } } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.