Flask-WooCommerce
A Flask extension that integrates the WooCommerce REST API into your application.
Installation
pip install flask-woocommerce
Usage
Configuration
Add your WooCommerce credentials to the Flask app config:
app.config["WOOCOMMERCE"] = {
"url": "https://your-store.com",
"consumer_key": "ck_...",
"consumer_secret": "cs_...",
}
Optional settings
| Key | Type | Description |
|---|---|---|
wp_api |
bool |
Enable the WP REST API integration |
version |
str |
API version (e.g. wc/v3) |
timeout |
float |
Request timeout in seconds |
verify_ssl |
bool |
Verify SSL certificates |
query_string_auth |
bool |
Use query string auth instead of HTTP Basic |
user_agent |
str |
Custom User-Agent header value |
Initialisation
Eager:
from flask import Flask
from flask_woocommerce import WooCommerce
app = Flask(__name__)
app.config["WOOCOMMERCE"] = { ... }
wc = WooCommerce(app)
Deferred (application factory pattern):
wc = WooCommerce()
def create_app():
app = Flask(__name__)
app.config["WOOCOMMERCE"] = { ... }
wc.init_app(app)
return app
Making requests
Access the underlying API client via the client property:
# Get all products
response = wc.client.get("products")
# Create a product
response = wc.client.post("products", {"name": "New Product", "regular_price": "9.99"})
# Update a product
response = wc.client.put("products/123", {"regular_price": "12.99"})
# Delete a product
response = wc.client.delete("products/123")
Multiple stores
To connect to more than one WooCommerce store, use a dict-of-dicts config:
app.config["WOOCOMMERCE"] = {
"default": {
"url": "https://main-store.com",
"consumer_key": "ck_...",
"consumer_secret": "cs_...",
},
"wholesale": {
"url": "https://wholesale-store.com",
"consumer_key": "ck_...",
"consumer_secret": "cs_...",
},
}
wc = WooCommerce(app)
# Access clients by name
main_products = wc.client.get("products") # "default" client
wholesale_products = wc.clients["wholesale"].get("products")
Logging
Flask-WooCommerce uses Python's standard logging module to provide visibility into extension initialization and configuration. This can be helpful for debugging configuration issues.
Enable debug logging to see detailed information:
import logging
# Enable debug logging for Flask-WooCommerce
logging.getLogger('flask_woocommerce').setLevel(logging.DEBUG)
# Or configure via Flask's logging
app.logger.setLevel(logging.DEBUG)
Log levels used:
- DEBUG: Configuration validation, client creation details
- INFO: Extension initialization summary
- ERROR: Configuration errors with full traceback
Security note: Sensitive credentials (consumer_key, consumer_secret) are automatically masked in debug logs.
Example Application
A complete example application is available in the example/ directory. It demonstrates:
- Basic setup and configuration
- Making API requests
- Error handling
- Multiple endpoint examples
See example/README.md for setup instructions.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
License
MIT
Metadata
Release files for Flask-WooCommerce 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| flask_woocommerce-0.1.0.tar.gz | 5.8 kB | Without provenance | Details for flask_woocommerce-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flask_woocommerce-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for flask_woocommerce-0.1.0-py3-none-any.whl |
Total release size: 12.4 kB
Release files / flask_woocommerce-0.1.0.tar.gz
| Download URL | flask_woocommerce-0.1.0.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a378d61efb096c0042de6f73f625d1f49664a52c0264547d097d98f7ab40b71f
|
|
BLAKE2b-256 checksum How to use checksums |
947cc82d4260ee3edeee556133086a06ee3cb60c59664a701845583df2438254
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.2 CPython/3.10.19 Linux/6.12.48+deb13-cloud-amd64
|
Release files / flask_woocommerce-0.1.0-py3-none-any.whl
| Download URL | flask_woocommerce-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d6ebf706ad8cd9fd3b29f0df4e516f8a23538bd128c0aad16f62621696fa6f0a
|
|
BLAKE2b-256 checksum How to use checksums |
7734b53c38065ad50316788feca38aca1a79ac6ce8f8179f02200a67ca2e3b75
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.2 CPython/3.10.19 Linux/6.12.48+deb13-cloud-amd64
|
Security for Flask-WooCommerce 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.