How to work with the WooCommerce REST API

You can use the WooCommerce REST API to remotely access the admin area of your WooCommerce store. Basic operations like “Read” and “Create” are managed using HTTP requests. The WooCommerce API can be activated in the backend.

What is a REST API?

REST APIs are used to define which of a systems resources can be managed using REST (Representational State Transfers). APIs are a great solution for enabling simple and efficient communication between client and server in web-based systems. Each resource is assigned modifiable parameters that describe the resource. REST architectures are realized using HTTP protocols, which allow each resource to be addressed using a unique URI (Uniform Resource Identifier). The parameters are attached as URL parameters and the resources are controlled using standard HTTP methods like GET, POST, PUT, and DELETE.

What is the WooCommerce REST API used for?

The most important characteristic of the WooCommerce REST API is its universality. Its design allows WooCommerce stores to easily interact with other websites and services. This interactivity is useful not only for developers but for all WooCommerce users. Here are some of the other advantages of using the WooCommerce REST API:

  • Cross-platform access: The REST API allows you to use third-party apps to access your WooCommerce dashboard.
  • Smooth integration of business logic: Business-specific software and hardware such as wearables and IoT tracking devices can be easily integrated into your project using the WooCommerce API.
  • Optimized data synchronization: Companies that want to sync data between their WooCommerce store and other platforms and channels can do that using the WooCommerce REST API.
  • Independence from WooCommerce backend: Once you’ve activated the universal WooCommerce API, you’ll no longer be bound to the WooCommerce/WordPress backend. You can integrate and use an admin area of your choosing.
  • Easy integration of third-party data: You can use the WooCommerce REST API to access any app-based third-party data.
  • Connection with mobile apps: If you want to connect your WooCommerce store with a mobile app, you’ll be able to do this with the WooCommerce API.
Tip

Looking for the right hardware environment for your online store? WooCommerce hosting by IONOS provides a safe and reliable foundation for your store, at an affordable price.

How to use the WooCommerce REST API step by step

If you want to use the WooCommerce API to interact with other web apps and services, you’ll first need to activate it by generating an API key. You’ll also need to install a client for REST access. Below we take you through this process step-by-step.

Step 1: Generating a WooCommerce REST API key

The first step in setting up the WooCommerce REST API is generating an API key. The key works as a kind of access control and is used by WooCommerce to authenticate REST requests. Take the following steps to generate a key:

  1. Log into the WooCommerce/WordPress backend.
  2. Click on “WooCommerce” in the menu on the left of the screen.
  3. Click on “Settings”.
  4. Navigate to the “Advanced” tab.
  5. Click on the sub-item “REST API”.
  6. Click “Add key”.
Screenshot of WooCommerce REST API menu in the backend
WooCommerce REST API menu in the WordPress backend.

You’ll need to fill out three fields. Under “Description”, add a name for the key that will allow you to easily identify it. For “User”, select the WooCommerce user that you want to generate a key for. And finally, under “Permissions”, select whether the user should have Read, Write, or Read/Write access.

When you click “Generate API Key”, WooCommerce will create two alphanumeric strings (the consumer key and consumer secret) and a QR code. Copy the two keys and save them in a document. You’ll need them later in order to access a REST client in the WooCommerce API.

Screenshot of WooCommerce API keys
WooCommerce consumer key, consumer secret and QR code

Step 2: Download API client

Once you’ve generated a key, you can send your requests to the WooCommerce interface. To do this, you’ll need an API client to send requests and display responses. Two popular clients for REST access are Insomnia and Postman. Both tools are available as desktop apps for Windows, MacOS, and Linux. Postman is also available as a web app and is the client we’ll use in this tutorial.

To install and set up Postman, follow these steps:

  1. Go to Postman’s download page and download the version of the client for your operating system.
  2. Double click the setup file to execute it.
  3. Create a Postman account. Enter your email address, choose a username, and set a password. Alternatively, you can register with a Google account.
  4. Fill out the rest of the form and, if relevant, send invite links to your colleagues.
Screenshot of the Postman client
Screenshot of the Postman client.
Tip

Still working on the right name for your WooCommerce project? Register your domain with IONOS and get a free SSL/TSL certificate and domain lock for your WooCommerce store!

Step 3: Create WooCommerce API request

After you’ve set up Postman, you can test your access to the REST API by sending your first request. To do this, open your workspace and click on “Create new request”.

Screenshot of My Workspace in Postman
In Postman, you can create new requests in your workspace.

As a first test, we’ll send a GET request to query data. This kind of request is set as the default in Postman, so simply leave the dropdown menu as is. In the address line, enter the address shown below. Substitute “woocommerce-domain.xyz” with the URL of your WooCommerce store.

https://woocommerce-domain.xyz/wp-json/wc/v3/orders

Then add your authentication data. How you do this will depend on whether you’re using HTTP or HTTPS (recommended) for REST access. Go to the “Authorization” tab and under “Type” select “OAuth 1.0” for HTTP or “Basic Auth” for HTTPS. Then enter the consumer key and consumer secret codes from above. If you’re using “Basic Auth”, use the key for “Username” and the secret for “Password”.

Screenshot of Authorization page in Postman
Screenshot from Postman showing authorization using HTTPS.

Once you’ve entered that information, click “Send” to start the request. In the example above, you’re requesting all current orders. Postman will display the response in the pane below. You can choose from JSON, XML, HTML, or Text formats.

Screenshot of response pane in Postman
The response to the GET request shown in the lower pane in JSON format.
Tip

In the IONOS Digital Guide, you can read about a number of topics surrounding WordPress and WooCommerce:

Was this article helpful?
We use cookies on our website to provide you with the best possible user experience. By continuing to use our website or services, you agree to their use. More Information.
Page top