A Python automation tool that connects to the WooCommerce REST API, extracts product inventory data, and generates a structured Excel inventory report.
The application automates the process of collecting product information from an online store and transforming it into a ready-to-use Excel report.
Store owners and teams often need inventory data exported from WooCommerce for reporting, analysis, or operational tasks.
Manually exporting and formatting product information can be repetitive and time-consuming.
This tool automates the workflow by:
- Connecting to WooCommerce through its REST API
- Retrieving product inventory data
- Validating API responses
- Handling paginated responses
- Generating a formatted Excel report automatically
This automation reduces manual inventory reporting work by automatically:
- Extracting WooCommerce product data
- Creating consistent Excel reports
- Reducing copy/paste errors
- Providing reusable reporting workflows
WooCommerce REST API
|
โ
API Data Extraction
|
โ
JSON Validation & Processing
|
โ
Pagination Handling
|
โ
Excel Report Generation
|
โ
Workbook Formatting
|
โ
Logging & Output
The exporter connects to WooCommerce using REST API authentication and retrieves product inventory information.
Features include:
- WooCommerce REST API integration
- Consumer key and secret authentication
- Page-based pagination handling
- API response validation
- JSON data processing
- Product extraction automation
The application generates a formatted Excel inventory report containing:
| Field | Description |
|---|---|
| ID | Product identifier |
| Name | Product name |
| SKU | Product SKU code |
| Price | Product price |
| Stock | Available quantity |
| Status | Inventory status |
The generated workbook includes:
- Styled headers
- Automatic column sizing
- Currency formatting
- Cell alignment
- Frozen header row
- Excel filters
- Table borders
WooCommerce returns product information as JSON:
[
{
"id": 101,
"name": "Example Product",
"sku": "SKU001",
"price": "25.00",
"stock_quantity": 15,
"stock_status": "instock"
}
]The exporter processes this data and converts it into an Excel report.
The exporter handles common API failures:
401Authentication failed403Permission denied404Endpoint not found429Rate limiting500/502/503/504Server errors- Connection failures
- Request timeouts
- Invalid JSON responses
Reliability features:
- Connection timeout handling
- Retry logic
- Rate-limit waiting using
Retry-Afterheaders - Detailed logging
- Response validation
Sensitive credentials are stored outside the source code using environment variables.
The project uses:
python-dotenv.envconfiguration.env.exampletemplate
Example:
WC_KEY=your_consumer_key
WC_SECRET=your_consumer_secret
URL=https://yourstore.com/wp-json/wc/v3/productsNever upload:
.env- API keys
- Consumer secrets
to GitHub.
The application includes logging to track execution and failures.
The logging system records:
- API extraction progress
- Product export count
- Report generation status
- API errors
- Workbook processing status
- Exceptions
- Python 3.x
requestsโ REST API communicationopenpyxlโ Excel creation and formattingpython-dotenvโ environment variable management
- REST APIs
- HTTP authentication
- JSON processing
- Pagination
- Retry handling
- Exception handling
- Logging
- Excel automation
woocommerce-inventory-exporter/
โโโ src/
โ โโโ main.py # Application entry point
โ โโโ api.py # WooCommerce API communication
โ โโโ reports.py # Excel report creation and formatting
โ โโโ config.py # Environment configuration
โ โโโ logging_config.py # Logging setup
|
|
โโโ images/
โ โโโ terminal-output.png
โ โโโ excel-report.png
โ โโโ logs-output.png
โ
โ
โโโ .env.example # Environment template
โโโ requirements.txt # Dependencies
โโโ README.md
โโโ .gitignore
โโโ LICENSE
Runtime-generated folders:
- `output/` โ generated Excel reports
- `logs/` โ application logs
These folders are created automatically when the application runs and are excluded from GitHub.
git clone https://github.com/DevBlueprintLab/woocommerce-inventory-exporter.git
cd woocommerce-inventory-exporterpython -m venv venvActivate environment:
venv\Scripts\activatesource venv/bin/activatepip install -r requirements.txtCreate a .env file in the project root:
WC_KEY=ck_xxxxxxxxxxxxx
WC_SECRET=cs_xxxxxxxxxxxxx
URL=https://yourstore.com/wp-json/wc/v3/productsRun the exporter:
python src/main.pyExample:
Started extracting data.
Finished extracting 35 products.
Report created:
output/products_report.xlsx
The exporter creates:
output/products_report.xlsx
Example:
| ID | Name | SKU | Price | Stock | Status |
|---|---|---|---|---|---|
| 101 | Product A | SKU001 | 25.00 | 15 | instock |
| 102 | Product B | SKU002 | 40.00 | 8 | outofstock |
Possible improvements:
- Add automated tests using
pytest - Add scheduled automatic exports
- Add historical inventory tracking
- Add email delivery of reports
- Currently exports products only
- Requires WooCommerce REST API credentials
- Excel output format is fixed
- No database storage
DevBlueprint Lab


