Getting started overview

WooCommerce operates as a plugin for WordPress, extending its content management capabilities into a full-fledged e-commerce platform. The initial setup involves installing the WooCommerce plugin on an existing or new WordPress installation. Once active, the platform provides administrative interfaces for store management and offers a REST API for programmatic interaction.

The WooCommerce REST API enables developers to build integrations and custom applications that interact with store data, including products, orders, customers, and coupons. Authentication for the REST API relies on OAuth 1.0a, requiring the generation of Consumer Key and Consumer Secret credentials from the WordPress admin panel. These keys are fundamental for making authenticated requests to the API.

This guide outlines the process from plugin installation to making a successful first API call, providing a foundational understanding for developers aiming to integrate with or build upon a WooCommerce store.

Create an account and get keys

Beginning with WooCommerce requires a WordPress website as its underlying platform. If a WordPress site is not already in place, setting one up is the prerequisite step. The WooCommerce core plugin is available for free through the WordPress plugin directory.

Step 1: Install the WooCommerce Plugin

  1. Log in to your WordPress admin dashboard.
  2. Navigate to Plugins > Add New.
  3. Search for "WooCommerce" in the search bar.
  4. Locate the "WooCommerce" plugin by Automattic and click Install Now.
  5. Once installed, click Activate.
  6. Follow the WooCommerce Setup Wizard prompts to configure basic store settings (store location, currency, product types, etc.). This wizard is optional but recommended for initial configuration assistance, as detailed in the WooCommerce setup wizard guide.

Step 2: Generate API Keys

After the WooCommerce plugin is installed and active, API keys can be generated to authenticate external applications.

  1. From your WordPress admin dashboard, navigate to WooCommerce > Settings.
  2. Click on the Advanced tab.
  3. Select REST API from the sub-menu.
  4. Click the Add Key button.
  5. On the "Key Details" screen, provide the following information:
    • Description: A descriptive name for the API key (e.g., "My Application Integration").
    • User: Select a user with appropriate permissions. An Administrator user typically has full access.
    • Permissions: Choose the desired level of access. For most integrations, "Read/Write" is suitable, as explained in the WooCommerce REST API authentication documentation.
  6. Click Generate API Key.
  7. The Consumer Key and Consumer Secret will be displayed. Copy these values immediately, as the Consumer Secret will only be shown once. Treat these keys as sensitive credentials.

Your first request

With WooCommerce installed and API keys generated, the next step is to make an authenticated request to the REST API. A common first request is to retrieve a list of products from the store. The WooCommerce REST API uses a base URL structure of [your-wordpress-site-url]/wp-json/wc/v3/.

API Request Details

  • Endpoint: /products
  • Method: GET
  • Authentication: OAuth 1.0a (Consumer Key and Consumer Secret)

Here's an example using curl, demonstrating how to make an authenticated request. Replace your_consumer_key, your_consumer_secret, and your_wordpress_site_url with your actual credentials and site URL.

curl -X GET "https://your_wordpress_site_url/wp-json/wc/v3/products"
  -u "your_consumer_key:your_consumer_secret"

This curl command uses basic authentication syntax (-u), which curl automatically converts into the necessary OAuth 1.0a headers for WooCommerce. The response will be a JSON array containing product data, similar to the structure documented in the WooCommerce REST API products endpoint documentation.

Expected Response (excerpt)

[
  {
    "id": 79,
    "name": "Woo Album #1",
    "slug": "woo-album-1",
    "permalink": "https://your_wordpress_site_url/product/woo-album-1/",
    "date_created": "2023-01-01T12:00:00",
    "type": "simple",
    "status": "publish",
    "price": "9.00",
    "regular_price": "9.00",
    "description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>",
    "short_description": "<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>",
    "images": [
      {
        "id": 80,
        "src": "https://your_wordpress_site_url/wp-content/uploads/2023/01/woo-album.jpg",
        "name": "woo-album",
        "alt": ""
      }
    ]
  }
]

A successful response with a 200 OK status code and a JSON array of product objects indicates that your API keys are correctly configured and your request was successfully authenticated and processed.

Common next steps

After successfully retrieving product data, developers often proceed with more advanced integrations. Common next steps include:

  • Creating Products: Use the POST /products endpoint to programmatically add new products to your store. This is useful for inventory management systems or bulk product uploads.
  • Managing Orders: Integrate with the /orders endpoints to retrieve, update, or create orders. This is crucial for order fulfillment, shipping integrations, and customer service applications.
  • Handling Customers: The /customers endpoints allow for managing customer accounts, retrieving customer details, and associating orders with specific users.
  • Webhooks: Configure webhooks to receive real-time notifications about events in your store, such as new orders or product updates. This push-based model reduces the need for constant API polling and improves efficiency. Details on setting up webhooks are available in the WooCommerce webhooks documentation.
  • Exploring Extensions: WooCommerce offers a wide range of extensions for functionalities like payments (e.g., PayPal for WooCommerce), shipping, marketing, and subscriptions. These can be integrated via their own APIs or through the WooCommerce core API.
  • Advanced Authentication: For more complex applications or those requiring higher security, consider implementing OAuth 2.0 or other advanced authentication mechanisms as supported by WordPress and its plugins, such as the OAuth 2.0 framework.

Quick Reference: WooCommerce Getting Started

Step What to do Where
1. WordPress Base Ensure a WordPress site is active. Your hosting provider / WordPress.org
2. Install Plugin Install and activate the WooCommerce plugin. WordPress Admin > Plugins > Add New
3. Initial Setup Run the WooCommerce Setup Wizard (optional but recommended). WordPress Admin > WooCommerce > Home
4. Generate API Keys Create Consumer Key and Consumer Secret with Read/Write permissions. WordPress Admin > WooCommerce > Settings > Advanced > REST API
5. First API Call Make a GET request to /wp-json/wc/v3/products using your keys. curl, Postman, or a programming language HTTP client
6. Explore Endpoints Review other API endpoints for orders, customers, etc. WooCommerce REST API Documentation

Troubleshooting the first call

Encountering issues during the first API call is common. Here are some troubleshooting steps:

  • 401 Unauthorized Error:
    • Incorrect Keys: Double-check that the Consumer Key and Consumer Secret are copied correctly and there are no leading/trailing spaces. Remember the Consumer Secret is only shown once.
    • Permissions: Ensure the API key has "Read" or "Read/Write" permissions. A key with "Read" permissions cannot create or update resources. Verify permissions in WooCommerce REST API authentication settings.
    • User Association: Confirm the API key is associated with a WordPress user who has sufficient capabilities (e.g., Administrator role).
  • 404 Not Found Error:
    • Incorrect Base URL: Verify that the WordPress site URL is correct and includes /wp-json/wc/v3/ in the API endpoint.
    • Permalinks: WordPress permalinks must be enabled and not set to "Plain". Go to Settings > Permalinks in WordPress admin and choose a structure like "Post name". Then, save changes to flush rewrite rules.
    • Plugin Deactivation: Ensure the WooCommerce plugin is active. If deactivated, the API endpoints will not be registered.
  • 500 Internal Server Error:
    • Server Logs: Check your web server's error logs (Apache, Nginx) and WordPress debug logs for specific error messages. Enable WordPress debugging by adding define('WP_DEBUG', true); and define('WP_DEBUG_LOG', true); to your wp-config.php file.
    • Plugin Conflicts: Temporarily deactivate other WordPress plugins, especially security or caching plugins, to rule out conflicts.
    • PHP Version/Memory: Ensure your server meets WooCommerce's recommended PHP version and memory limits. Consult the WooCommerce server requirements.
  • SSL Issues:
    • If your site uses HTTPS, ensure your curl command or HTTP client is correctly configured to handle SSL certificates.