banner-img

WooCommerce REST API: Everything You Need to Know

April 8, 2025

Managing a WooCommerce store is not easy, especially when it scales. You can’t go on updating products, orders, and other information manually. That’s when WooCommerce REST API comes like a genie, eliminating all the manual, repetitive tasks.

Using REST API, you can update products, customer information, and more in bulk. It saves you time and reduces the chances of error when changes are made.

In this blog, we’ll cover how you can integrate the WooCommerce REST API. We’ll cover how you can manage products, orders, and customers. Plus, we’ll understand the endpoints you can use for handling the WooCommerce store. With that said, let’s begin.

Understanding WooCommerce REST API

If you run a WooCommerce store, you’ve probably heard about the REST API. But what exactly is it, and how can it help you? Let’s break it down in simple terms.

The WooCommerce REST API lets your store communicate with other apps and systems. Instead of manually updating products or orders, you can automate things.

Think of it like a messenger:

  • Your store sends and receives data (like orders or product details).
  • Other apps (like CRMs, mobile apps, or inventory tools) can “talk” to WooCommerce without you doing everything by hand.

How Does the WooCommerce REST API Work?

The API works through HTTP requests—the same way your browser loads websites. Here’s a quick rundown:

You Send a Request:

  • Need to fetch all products? Send a GET request.
  • Adding a new order? Use POST.
  • Updating stock? PUT or PATCH does the job.

WooCommerce Processes It:

  • The API checks if you have permission (using API keys or OAuth).
  • If everything’s good, it performs the action.

You Get a Response:

  • Success? You’ll see the data (like order details) in JSON format.
  • Error? It’ll tell you what went wrong (like “404 Not Found”).

The WooCommerce REST API isn’t just for developers. If you run a store and hate manual work, this can save you hours. If you want to build a custom e-store using WooCommerce, get services from our WordPress development company. We will use the best coding practices and tools to provide you with optimal web solutions.

Prerequisites for Using WooCommerce REST API

Before diving into the WooCommerce REST API, you’ll need a few things set up. Let’s keep it simple.

  • WooCommerce installed (3.5+): Obviously, your store must be running WooCommerce.
  • SSL (HTTPS) enabled: The API requires a secure connection.
  • API keys generated: Found under WooCommerce > Settings > Advanced > REST API.
  • Basic coding knowledge: Helpful if you’re making custom requests (but tools like Postman work too).

That’s it! Once these are ready, you’re good to start with the setup of WooCommerce REST API.

Steps to Integrate WooCommerce REST API

Want to connect apps or automate your WooCommerce store? Follow these simple steps to set up the REST API.

1. Generate Your API Keys

First, we need to create the access keys that will let external apps talk to your store.

Step 1: Log in to your WordPress admin dashboard.

Step 2: Go to WooCommerce > Settings > Advanced > REST API.

Generate Your API Keys

Step 3: Click the “Add Key” button.

Step 4: Fill in the details:

  • Description: Name your key (like “Mobile App” or “Inventory Sync”).
  • User: Select an administrator account.
  • Permissions: Choose “Read/Write” for full access.
Name your key

Step 5: Click “Generate API Key”.

We created unique access credentials that will authenticate API requests to your store.

2. Test the Connection with Postman

Now let’s verify everything works before coding. Postman makes this easy.

Step 1: Download and install Postman (a free tool for API testing).

Step 2: Create a new request and set it to the GET method.

Step 3: Enter this URL (replace with your store URL):

https://yourstore.com/wp-json/wc/v3/products

Step 4: Go to the Authorization tab.

Step 5: Select the Basic Auth type.

Step 6: Now enter the ‘Consumer Key’ and ‘Consumer Secret’ that we generated in the first step.

Step 7: Click on the ‘Send’ button to verify that the connection with the REST API works properly.

With that, we successfully fetched your product data through the API – if you see JSON product data, it’s working!

3. Connect with Code (PHP Example)

Time to use the API in your actual applications. Here’s how in PHP.

Step 1: Set up a PHP file on your server.

Step 2: Use this code (replace placeholders):

<?php
$api_url = 'https://yourstore.com/wp-json/wc/v3/products';
$args = array(
    'headers' => array(
        'Authorization' => 'Basic '. base64_encode('YOUR_KEY:YOUR_SECRET'),
    ),
);
$response = wp_remote_get($api_url, $args);
$products = json_decode(wp_remote_retrieve_body($response));
// Display products
echo "<pre>";
print_r($products);
echo "</pre>";
?>

Step 3: Save and run the file.

We created a simple PHP script that pulls product data from your WooCommerce store using the API.

We created a simple PHP script that pulls product data from your WooCommerce store using the API.

4. Start Automating Tasks

Now that it’s working, let’s do something simple and useful with it.

Example 1: Add a New Product

$data = array(
    'name' => 'New API Product',
    'type' => 'simple',
    'regular_price' => '19.99',
    'description' => 'Created via API'
);
$response = wp_remote_post($api_url, array(
    'headers' => array(
        'Authorization' => 'Basic '. base64_encode('KEY:SECRET'),
    ),
    'body' => json_encode($data)
));

Example 2: Update Product Stock

$update_data = array(
    'stock_quantity' => 50
);
$response = wp_remote_request($api_url.'/PRODUCT_ID', array(
    'method' => 'PUT',
    'headers' => array(
        'Authorization' => 'Basic '. base64_encode('KEY:SECRET'),
    ),
    'body' => json_encode($update_data)
));

Here we used the API to automatically add products and manage WooCommerce inventory – no manual work needed!

Start with small tasks first. Once comfortable, you can connect your store to CRMs, mobile apps, or custom dashboards.

Using WooCommerce REST API for Managing Products

The WooCommerce REST API lets you add, edit, and delete products programmatically. It is perfect for bulk imports, inventory syncs, or automating your product management.

How to Add Products?

Need to add products in bulk or from an external system? Here’s how.

Step 1: Use a POST request to the products endpoint:

POST https://yourstore.com/wp-json/wc/v3/products

Step 2: Authenticate with your API keys (use OAuth 2.0).

Step 3: Include product details in the request body (JSON format):

{
    "name": "Premium Quality T-Shirt",
    "type": "simple",
    "regular_price": "21.99",
    "description": "A nice print casual t-shirt with charming colours and trending sizes",
    "short_description": "T-shirts that is cool to wear.",
    "categories": [
        {
            "id": 17
        }
    ],
    "images": [
        {
            "id": 58
        },
        {
            "src": "http://localhost/local-wordpress/wp-content/uploads/2025/04/t-shirt-with-logo-1.jpg"
        }
    ]
}

Step 4: Check the products section in the WordPress admin panel; our newly added product will appear in the list.

With that done, a new product will appear in your store.

How to Edit Products?

If you want to update the product, its price, or descriptions, here is how you can do it:

Step 1: Find the product ID (check in WooCommerce or fetch via API).

Step 2: Send a PUT/PATCH request to the product’s endpoint:

PUT https://yourstore.com/wp-json/wc/v3/products/123

Step 3: Pass the updated fields (e.g., price or stock):

{
  "regular_price": "15.99",
  "stock_quantity": 50
}

The changes we make will be made instantly as you update the details.

How to Delete Products?

When you want to remove old products or the ones out of stock, you can follow the steps below:

Step 1: Get the product ID you want to remove.

Step 2: Send a DELETE request:

DELETE https://yourstore.com/wp-json/wc/v3/products/123

Step 3: Add force=true to skip the trash (optional):

DELETE https://yourstore.com/wp-json/wc/v3/products/123?force=true

This will delete the product you selected. The command can be used for deleting products in bulk, saving your time.

With that, we have learned how to add, edit, and delete products using REST API. Now let’s learn how to manage the orders using the same.

Using WooCommerce REST API for Managing Orders

Tired of manually checking orders? The WooCommerce REST API lets you fetch and update orders automatically. Here is how you can fetch and update the status of the order.

How to Fetch Orders?

If you need to pull recent orders for reporting or processing, here’s how you can do it:

Send a GET request to the orders endpoint:

GET https://yourstore.com/wp-json/wc/v3/orders

Add filters if needed (example for the last 30 days):

?after=2023-01-01T00:00:00Z 

Include your API keys in the authorization header.

You’ll get back a clean list of all orders in JSON format, ready to use.

How to Update Order Status?

Need to mark orders as completed or update tracking info? No more manual edits.

Step 1: Find the order ID (from WooCommerce or your API response).

Step 2: Send a PUT request to the specific order:

PUT https://yourstore.com/wp-json/wc/v3/orders/66

Step 3: Pass the new status in the request body:

{  
  "status": "completed"  
}

The order updates instantly – your customers get notifications automatically!

Now you can automate your order workflow and say goodbye to manual updates. Start small with fetching orders, then explore adding notes or custom fields.

Using WooCommerce REST API for Managing Customers

The WooCommerce REST API lets you add and retrieve customer details without touching your admin dashboard. Here is how you can use it.

How to Add Customers?

To create and add customers manually, follow the steps:

Step 1: Send a POST request to the customer’s endpoint:

POST https://yourstore.com/wp-json/wc/v3/customers

Step 2: Include customer details in the request body:

{  
  "email": "[email protected]",  
  "first_name": "John",  
  "last_name": "Doe",  
  "username": "john.doe",  
  "password": "securepassword123"  
}

Step 3: Authenticate with your API keys.

Customer added! They’ll receive a welcome email if your store is set up for it.

How to Fetch Customer Info by ID?

To retrieve a customer’s information, you can use the customer ID. Here is how you can fetch all the info:

Step 1: Get the customer ID (from an order or your database).

Step 2: Send a GET request:

GET https://yourstore.com/wp-json/wc/v3/customers/789

Step 3: Add your API authentication.

With this, you’ll get everything – name, email, order history, and more—in a clean JSON format.

Now you can sync customer data across systems effortlessly. Start with these basics, then explore updating addresses or fetching customer lists.

What are the Available Endpoints in the WooCommerce REST API?

The WooCommerce REST API gives you powerful endpoints to manage every part of your store. Here’s what you can control and how to use each one.

1. Products (/wp-json/wc/v3/products)

Manages your store’s products – create, read, update, or delete items in your catalog.

Example code (GET all products):

$response = wp_remote_get('https://yourstore.com/wp-json/wc/v3/products', [
    'headers' => [
        'Authorization' => 'Basic '. base64_encode('ck_yourkey:cs_yoursecret')
    ]
]);

2. Orders (/wp-json/wc/v3/orders)

Handles everything about orders – processing, status updates, and customer details.

Example code (Create new order):

$data = [
    'payment_method' => 'bacs',
    'billing' => [
        'first_name' => 'John',
        'last_name' => 'Doe',
        'email' => '[email protected]'
    ],
    'line_items' => [
        [
            'product_id' => 93,
            'quantity' => 2
        ]
    ]
];
wp_remote_post('https://yourstore.com/wp-json/wc/v3/orders', [
    'headers' => [
        'Authorization' => 'Basic '. base64_encode('ck_yourkey:cs_yoursecret')
    ],
    'body' => json_encode($data)
]);

3. Coupons (/wp-json/wc/v3/coupons)

This endpoint lets you create and manage discount codes for your store.

Example code (Create 10% off coupon):

$coupon_data = [
    'code' => 'SUMMER10',
    'discount_type' => 'percent',
    'amount' => '10',
    'individual_use' => true
];
wp_remote_post('https://yourstore.com/wp-json/wc/v3/coupons', [
    'headers' => [
        'Authorization' => 'Basic '. base64_encode('ck_yourkey:cs_yoursecret')
    ],
    'body' => json_encode($coupon_data)
]);

4. Taxes (/wp-json/wc/v3/taxes)

It controls tax rates and settings for different regions. Plus, it can calculate taxes when the checkout is made.

Example code (Get all tax rates):

$response = wp_remote_get('https://yourstore.com/wp-json/wc/v3/taxes', [
    'headers' => [
        'Authorization' => 'Basic '. base64_encode('ck_yourkey:cs_yoursecret')
    ]
]);

5. Customers (/wp-json/wc/v3/customers)

This endpoint is used to manage customer accounts and their information.

Example code (Get customer by ID):

$response = wp_remote_get('https://yourstore.com/wp-json/wc/v3/customers/123', [
    'headers' => [
        'Authorization' => 'Basic '. base64_encode('ck_yourkey:cs_yoursecret')
    ]
]);

6. Statuses (/wp-json/wc/v3/statuses)

To retrieve, or say, fetch the available order status, you can use the statuses endpoint of the REST API.

Example code (Get all statuses):

$response = wp_remote_get('https://yourstore.com/wp-json/wc/v3/statuses', [
    'headers' => [
        'Authorization' => 'Basic '. base64_encode('ck_yourkey:cs_yoursecret')
    ]
]);

These endpoints cover most store operations. Refer to WooCommerce’s official REST API doc for full details on each one.

FAQs About Using WooCommerce REST API

What’s the API request limit in WooCommerce?

By default, WooCommerce allows 60 requests per minute per user. If you hit this, you’ll get a 429 error. Need more? Consider using rate-limiting plugins.

How to use the Legacy REST API?

The legacy API (v2) still works, but isn’t recommended. Just replace /wc/v3/ with /wc/v2/ in your endpoints. But upgrade to v3 for better features.

What’s WooCommerce’s API structure?

It follows REST standards – use HTTP methods (GET/POST/PUT/DELETE) on endpoints like /products or /orders. All responses come in JSON format for easy use.

Wrapping Up

The WooCommerce REST API opens up a world of possibilities for store owners tired of manual updates. Whether you’re syncing inventory, automating orders, or connecting to external tools, these API calls can turn hours of repetitive work into seamless automation.

Start small—try fetching products or updating a test order first. Once comfortable, you’ll find countless ways to streamline operations, from bulk imports to real-time CRM syncs. The official WooCommerce documentation is your friend for diving deeper into specific endpoints and features.

If you are looking to build a WooCommerce store that is well-designed and robust, consult with us today!

Henry Taylor

Henry Taylor is a WooCommerce expert at WPPluginExperts. Using his technical knowledge, he helps readers with practical insights, guiding them to optimize their online stores and boost eCommerce performance.

Leave a Comment

30 days Money Back Guarantee

Secure Online Payment

1 Year of Updates & Support