import requests from requests.auth import HTTPBasicAuth # Configuration CK = 'ck_d60ea51ceb4a399d3dadd6307d1227a8768f3317' CS = 'cs_df2615caa97a4ca1c1a02f1b512c10d9770fb625' BASE_URL = 'https://kellcreations.com/wp-json/wc/v3' def get_products(): endpoint = f'{BASE_URL}/products' # Try fetching up to 20 products params = { 'per_page': 20 } print(f"Connecting to {endpoint}...") try: response = requests.get( endpoint, auth=HTTPBasicAuth(CK, CS), params=params ) print(f"Status Code: {response.status_code}") if response.status_code == 200: products = response.json() print(f"Found {len(products)} products:") print("-" * 50) for product in products: name = product.get('name', 'N/A') stock_status = product.get('stock_status', 'N/A') stock_quantity = product.get('stock_quantity', 'N/A') price = product.get('price', 'N/A') print(f"Name: {name}") print(f" Price: {price}") print(f" Stock: {stock_status} ({stock_quantity})") print("-" * 50) else: print("Failed to retrieve products.") print(f"Response: {response.text}") except Exception as e: print(f"An error occurred: {e}") if __name__ == "__main__": get_products()