You can use the Woo­Com­merce REST API to remotely access the admin area of your Woo­Com­merce store. Basic op­er­a­tions like ‘Read’ and ‘Create’ are managed using HTTP requests. The Woo­Com­merce 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 (Represent­a­tion­al State Transfers). APIs are a great solution for enabling simple and efficient com­mu­nic­a­tion between client and server in web-based systems.

Each resource is assigned modi­fi­able para­met­ers that describe the resource. REST ar­chi­tec­tures are realised using HTTP protocols, which allow each resource to be addressed using a unique URI (Uniform Resource Iden­ti­fi­er). The para­met­ers are attached as URL para­met­ers and the resources are con­trolled using standard HTTP methods like GET, POST, PUT, and DELETE.

What is the Woo­Com­merce REST API used for?

The most important char­ac­ter­ist­ic of the Woo­Com­merce REST API is its uni­ver­sal­ity. Its design allows Woo­Com­merce stores to easily interact with other websites and services. This in­ter­activ­ity is useful not only for de­velopers but for all Woo­Com­merce users. Here are some of the other ad­vant­ages of using the Woo­Com­merce REST API:

  • Cross-platform access: The REST API allows you to use third-party apps to access your Woo­Com­merce dashboard.
  • Smooth in­teg­ra­tion of business logic: Business-specific software and hardware such as wearables and IoT tracking devices can be easily in­teg­rated into your project using the Woo­Com­merce API.
  • Optimised data syn­chron­isa­tion: Companies that want to sync data between their Woo­Com­merce store and other platforms and channels can do that using the Woo­Com­merce REST API.
  • In­de­pend­ence from Woo­Com­merce backend: Once you’ve activated the universal Woo­Com­merce API, you’ll no longer be bound to the Woo­Com­merce/WordPress backend. You can integrate and use an admin area of your choosing.
  • Easy in­teg­ra­tion of third-party data: You can use the Woo­Com­merce REST API to access any app-based third-party data.
  • Con­nec­tion with mobile apps: If you want to connect your Woo­Com­merce store with a mobile app, you’ll be able to do this with the Woo­Com­merce API.
Tip

Looking for the right hardware en­vir­on­ment for your online store? Woo­Com­merce hosting by IONOS provides a safe and reliable found­a­tion for your store, at an af­ford­able price.

How to use the Woo­Com­merce REST API step by step

If you want to use the Woo­Com­merce API to interact with other web apps and services, you’ll first need to activate it by gen­er­at­ing 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: Gen­er­at­ing a Woo­Com­merce REST API key

The first step in setting up the Woo­Com­merce REST API is gen­er­at­ing an API key. The key works as a kind of access control and is used by Woo­Com­merce to au­then­tic­ate REST requests.

Take the following steps to generate a key:

  1. Log into the Woo­Com­merce/WordPress backend.
  2. Click on ‘Woo­Com­merce’ 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’.
Image: Screenshot of WooCommerce REST API menu in the backend
Woo­Com­merce REST API menu in the WordPress backend.

You’ll need to fill out three fields. Under ‘De­scrip­tion’, add a name for the key that will allow you to easily identify it. For ‘User’, select the Woo­Com­merce user that you want to generate a key for. And finally, under ‘Per­mis­sions’, select whether the user should have Read, Write, or Read/Write access.

When you click ‘Generate API Key’, Woo­Com­merce will create two al­pha­nu­mer­ic 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 Woo­Com­merce API.

Image: Screenshot of WooCommerce API keys
Woo­Com­merce 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 Woo­Com­merce 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. Al­tern­at­ively, you can register with a Google account.
  4. Fill out the rest of the form and, if relevant, send invite links to your col­leagues.
Image: Screenshot of the Postman client
Screen­shot of the Postman client.
Tip

Still working on the right name for your Woo­Com­merce project? Register your domain with IONOS and get a free SSL/TSL cer­ti­fic­ate and domain lock for your Woo­Com­merce store!

Step 3: Create Woo­Com­merce 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’.

Image: 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. Sub­sti­tute ‘woo­com­merce-domain.xyz’ with the URL of your Woo­Com­merce store.

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

Then add your au­then­tic­a­tion data. How you do this will depend on whether you’re using HTTP or HTTPS (re­com­men­ded) for REST access. Go to the ‘Au­thor­iz­a­tion’ 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’.

Image: Screenshot of Authorisation page in Postman
Screen­shot from Postman showing au­thor­isa­tion using HTTPS.

Once you’ve entered that in­form­a­tion, click ‘Send’ to start the request. In the example above, you’re re­quest­ing all current orders. Postman will display the response in the pane below. You can choose from JSON, XML, HTML, or Text formats.

Image: 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 sur­round­ing WordPress and Woo­Com­merce:

Go to Main Menu