The `woocommerce` library is an official Python wrapper for the WooCommerce REST API, enabling developers to easily interact with WooCommerce stores. It is currently at version 3.0.0, released in March 2021, and its development cadence is generally infrequent, tied to significant updates or changes in the core WooCommerce REST API.
pip install woocommerceVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the `woocommerce.API` client and fetch products from your store. Remember to replace the placeholder URL and API keys with your actual store details, preferably by loading them from environment variables for security.
Upgrade your Python environment to 3.6+ before installing or upgrading `woocommerce` to 3.0.0.
Use HTTPS for your WooCommerce store. If not possible, initialize `API(..., query_string_auth=True)`.
For `version='wc/v3'`, omit the `wp_api` parameter or ensure `wp_api` is not explicitly set to `True` unless you are specifically targeting a very old WooCommerce API.
Set `verify_ssl=False` during development/testing with self-signed certificates. For production, use valid SSL certificates and keep `verify_ssl=True` (the default).
Verify that your `url` points to the correct WooCommerce store base URL (e.g., `https://your-store.com`), and that your consumer key and secret are correct and have the necessary permissions. Also, ensure your endpoint is a valid REST API path (e.g., 'products' not a regular product page URL). Check `response.text` for the actual HTML content to debug. If using HTTP, try `query_string_auth=True`.
Double-check your `consumer_key` and `consumer_secret`. Ensure the keys generated in WooCommerce admin have 'Read' or 'Read/Write' permissions as required. If using HTTP, try `query_string_auth=True`. Make sure the user associated with the API key still exists.
Consult the WooCommerce REST API documentation for the specific endpoint you are using (e.g., `/customers`, `/products`) to identify all required fields for creation/update and ensure they are present in your `data` payload. For customers, a password is often a critical missing field.
Run `pip install woocommerce` in your terminal. If using a virtual environment, ensure it's activated before installation and script execution.