How to Use REST API with WooCommerce
Introduction: What is the WooCommerce REST API?
The WooCommerce REST API is a powerful tool that allows developers and store owners to interact with WooCommerce data from outside the WordPress dashboard. Using it, you can perform actions like retrieving products, creating orders, updating customer data, and integrating with third-party services—all without logging into wp-admin.
In this guide, you’ll learn everything from the basics of enabling the API to making advanced API calls using authentication and custom endpoints.
🚀 Why Use the WooCommerce REST API?
- 📦 Manage orders, products, and customers externally
- 🔄 Sync data with ERP/CRM tools
- 🛒 Build custom mobile or desktop applications
- 🤖 Automate tasks using scripts or webhooks
- 🔗 Integrate WooCommerce with third-party platforms like Zapier, Integromat, etc.
🛠️ Prerequisites Before Using the REST API
Before getting started, make sure you have:
- Admin access to your WordPress site
- WooCommerce installed and active
- Permalinks enabled (not set to “Plain”)
- Basic knowledge of HTTP, JSON, and API usage
📖 WooCommerce REST API documentation
📖 WordPress REST API basics
🔐 Step 1: Enable the REST API in WooCommerce
- Go to WooCommerce > Settings > Advanced > REST API
- Click Add Key
- Enter a description (e.g., “Mobile App Integration”)
- Choose a user with admin rights
- Set permissions:
- Read: View only
- Write: Create/Update/Delete
- Read/Write: Full access
- Click Generate API Key
📌 Note the Consumer Key and Consumer Secret—these are needed for authentication.
🌐 Step 2: Making Your First API Request
You can test the API using tools like:
Example: Get a list of products
curl https://yourdomain.com/wp-json/wc/v3/products \
-u consumer_key:consumer_secret
📥 Step 3: Authentication Methods
1. HTTP Basic Auth (Simplest for dev use)
- Use your consumer key and secret
2. OAuth 1.0a (Legacy method)
- Used in WooCommerce 2.x
3. Application Passwords (WordPress 5.6+)
- Use your WordPress user account’s App Passwords App Passwords Guide
4. JWT (JSON Web Tokens)
- Best for mobile apps or custom frontend apps JWT Authentication Plugin
🔄 Step 4: CRUD Operations with WooCommerce API
✅ GET (Read data)
GET /wp-json/wc/v3/products
➕ POST (Create data)
POST /wp-json/wc/v3/products
{
"name": "Test Product",
"type": "simple",
"price": "25.99"
}
✏️ PUT (Update data)
PUT /wp-json/wc/v3/products/123
{
"price": "29.99"
}
❌ DELETE (Remove data)
DELETE /wp-json/wc/v3/products/123?force=true
📊 Step 5: Useful API Endpoints
| Function | Endpoint |
|---|---|
| List Products | /wp-json/wc/v3/products |
| View Orders | /wp-json/wc/v3/orders |
| Create Customer | /wp-json/wc/v3/customers |
| Check Inventory | /wp-json/wc/v3/products?stock_status=instock |
| Update Shipping | /wp-json/wc/v3/orders/{id}/shipping_lines |
Full list 👉 WooCommerce REST API Reference
🧠 Advanced Use Cases
1. 📲 Build a Custom WooCommerce Mobile App
Use the REST API to fetch/store live data for customers, products, and checkout.
2. 🔗 Integrate with CRM/ERP
Sync orders with Zoho, Salesforce, or QuickBooks using automation tools or custom code.
3. 📩 Automate Workflows with Zapier
Trigger actions on new orders or abandoned carts. Zapier WooCommerce Integration
⚠️ Security Tips for API Usage
- Use HTTPS always 🔐
- Regenerate keys if you suspect a breach
- Set read-only permissions when possible
- Avoid exposing API credentials in client-side apps
- Use JWT or OAuth for secure integrations
🧰 Helpful Tools & Plugins
🧪 Testing & Debugging API Requests
- Use browser console or Postman
- Enable WordPress debugging
- Monitor network requests using Chrome DevTools
💡
The WooCommerce REST API is a gateway to limitless customizations, automations, and integrations. Whether you’re a developer looking to build a headless store, or a business automating backend processes, understanding how to interact with this API will give you superpowers.
Start small, test thoroughly, and always prioritize security.
