Skip to content

About

Python automation tool that exports WooCommerce product inventory data through the REST API and generates formatted Excel reports.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

ย 

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ›’ WooCommerce Inventory Exporter

Python Version API Dependencies License

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.


๐Ÿ–ฅ๏ธ Pipeline Lifecycle & Live Demo

Execution Flow & Generated Output

Application logs Terminal Export Process

Generated Excel Report


๐ŸŽฏ Problem Solved

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

๐Ÿ’ผ Business Value

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

๐Ÿ”„ Automation Pipeline

WooCommerce REST API
          |
          โ†“
API Data Extraction
          |
          โ†“
JSON Validation & Processing
          |
          โ†“
Pagination Handling
          |
          โ†“
Excel Report Generation
          |
          โ†“
Workbook Formatting
          |
          โ†“
Logging & Output

๐Ÿง  Core Features & Architecture

๐Ÿ”Œ WooCommerce REST API Integration

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

๐Ÿ“Š Automated Excel Reporting

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

๐Ÿ“ฆ Example API Response

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.


๐Ÿ›ก๏ธ API Error Handling & Reliability

The exporter handles common API failures:

  • 401 Authentication failed
  • 403 Permission denied
  • 404 Endpoint not found
  • 429 Rate limiting
  • 500/502/503/504 Server errors
  • Connection failures
  • Request timeouts
  • Invalid JSON responses

Reliability features:

  • Connection timeout handling
  • Retry logic
  • Rate-limit waiting using Retry-After headers
  • Detailed logging
  • Response validation

๐Ÿ” Secure Credential Management

Sensitive credentials are stored outside the source code using environment variables.

The project uses:

  • python-dotenv
  • .env configuration
  • .env.example template

Example:

WC_KEY=your_consumer_key
WC_SECRET=your_consumer_secret
URL=https://yourstore.com/wp-json/wc/v3/products

Never upload:

  • .env
  • API keys
  • Consumer secrets

to GitHub.


๐Ÿ“ Logging System

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

๐Ÿ› ๏ธ Tech Stack

Language

  • Python 3.x

Libraries

  • requests โ€” REST API communication
  • openpyxl โ€” Excel creation and formatting
  • python-dotenv โ€” environment variable management

Concepts Demonstrated

  • REST APIs
  • HTTP authentication
  • JSON processing
  • Pagination
  • Retry handling
  • Exception handling
  • Logging
  • Excel automation

๐Ÿ“ Project Structure

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.

โš™๏ธ Installation

1. Clone the repository

git clone https://github.com/DevBlueprintLab/woocommerce-inventory-exporter.git

cd woocommerce-inventory-exporter

2. Create virtual environment

python -m venv venv

Activate environment:

Windows

venv\Scripts\activate

Mac/Linux

source venv/bin/activate

3. Install dependencies

pip install -r requirements.txt

๐Ÿ” Environment Setup

Create a .env file in the project root:

WC_KEY=ck_xxxxxxxxxxxxx
WC_SECRET=cs_xxxxxxxxxxxxx
URL=https://yourstore.com/wp-json/wc/v3/products

โ–ถ๏ธ Usage

Run the exporter:

python src/main.py

Example:

Started extracting data.

Finished extracting 35 products.

Report created:
output/products_report.xlsx

๐Ÿ“ˆ Generated Report

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

๐Ÿ”ฎ Future Improvements

Possible improvements:

  • Add automated tests using pytest
  • Add scheduled automatic exports
  • Add historical inventory tracking
  • Add email delivery of reports

โš ๏ธ Current Limitations

  • Currently exports products only
  • Requires WooCommerce REST API credentials
  • Excel output format is fixed
  • No database storage

๐Ÿ‘จโ€๐Ÿ’ป Author

DevBlueprint Lab

About

Python automation tool that exports WooCommerce product inventory data through the REST API and generates formatted Excel reports.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages