How To Use The WooCommerce API

WordPress is the preferred CMS at the moment in use. Why? As a result of it simply integrates with hundreds of instruments to enhance your web site’s efficiency and performance.

These instruments cowl a variety of industries, however customers are constantly impressed by the quantity of instruments obtainable for ecommerce. One of the highly effective ecommerce instruments is the WooCommerce API.

Understanding the WooCommerce API

WooCommerce’s API has three fundamental parts. To grasp how highly effective this API will be, let’s check out every part individually.


WooCommerce’s REST API permits customers to entry their WooCommerce storefront from outdoors their web site. This design will allow you to entry your retailer from different web purposes like Shopify, for instance.

In the end, the REST API makes managing your retailer simpler. You’ll be able to entry your WooCommerce retailer from different apps’ dashboards and nonetheless have entry to full WooCommerce admin performance.

Legacy API

Enabling the Legacy API was how you’d activate your API for WooCommerce. Nonetheless, this a part of the method is turning into out of date in newer variations.

The latest model is the WooCommerce REST API. It integrates straight with WordPress’s API. The Legacy API is WooCommerce’s older model. Customers ought to double-check their settings, as WooCommerce tends to launch the Legacy API by default.


Webhooks enable WooCommerce to “name out” to different apps. For instance, if you would like actions inside WooCommerce to be triggered by actions taken in different apps, you should use a webhook.

The API accomplishes this utilizing URLs. You’ll be able to ship a notification alert through the API to a particular URL. These URLs may cause occasions on a selected website, triggering one other motion on a separate website or web page.

Promote your merchandise on-line, worry-free

Formally beneficial by WooCommerce, our internet hosting is made for on-line companies like yours

Key WooCommerce API terminology

As you stroll by way of WooCommerce’s API documentation, you’ll come throughout some terminology distinctive to WooCommerce. Let’s evaluate these phrases and definitions that will help you by way of your API course of.

Request/response format

This means the format WooCommerce will use to transmit explicit forms of knowledge. It’s vital to concentrate on the totally different knowledge sorts as a result of sure URLs and triggers received’t work in the event that they don’t obtain knowledge within the correct format.

The usual format for many knowledge throughout the WooCommerce API is JSON. Calendar dates return as integers, and any quantity (like cash, pricing, or totals) will likely be in a textual content string and default to 2 decimal locations. Something left clean will return as an empty string or “null.”


The authentication course of permits for WooCommerce API integration. Customers can join the API to different platforms utilizing API keys.

To generate a WooCommerce API key, that you must entry your settings. Two keys can be found for WooCommerce customers, a Secret Key and a Client Key.

Client Keys are often known as Normal or API Keys. These keys are issued to a person from totally different platforms. WooCommerce API keys can help you hook up with different platforms like WordPress, Shopify, and so forth.

The Secret Key behaves equally for sure apps and platforms. While you join third-party instruments or apps to WooCommerce, the Normal or Client Key will act because the “username” of your login credentials, whereas the Secret Key will act as your password.


By way of API expertise, an endpoint is the purpose at which the API interacts with one other app or platform. An instance of an endpoint can be the URL for a particular platform, like Shopify or Fb.

Organising WooCommerce API

The method of establishing your WooCommerce API is comparatively simple. Observe the steps under to hyperlink all of your instruments to the platform and rework your buyer’s ecommerce purchasing expertise.

You’ll have to navigate by way of the next menus in your WordPress dashboard:

WooCommerce>Settings>Superior>Legacy API

There’s a checkbox to point whether or not or not the API is enabled. Make sure the field is checked, click on save modifications, and API Entry is now obtainable.

Easy methods to create API keys in WooCommerce

API Keys are the spine of the WooCommerce API capabilities. It’s time to create some to attach your favourite instruments and platforms. Observe the steps under to take action.

1. Add key

You’ll have to create a brand new key for each app or platform you hook up with WooCommerce. The API will generate a Client Key and a Secret Key for each new connection you create.

You’ll want to move to the REST API menu so as to add a key. Right here’s how you will discover it:

WooCommerce>Settings>Superior>REST API

When you’re there, click on Add Key.

2. Configure key settings

When you click on “Add Key,” there are some choices you’ll have to make. For every key you create, you’ll have to configure the next settings:

  • Description – That is the place you may “title” every key for the corresponding platform to assist set up them
  • Proprietor – Assign a key to the precise person answerable for it inside your workforce
  • Permissions – These dictate what capabilities you’re granting this explicit key. For instance, in the event you want a particular key to delete or alter knowledge, you’ll want to offer “Learn/Write Permissions.”

3. API era

As soon as your settings configuration is full, you’ll hit the “Generate Key” button on the backside of the display screen. The following web page you’re taken to will include a Client Key and Secret Key, and a QR code for this connection.

When you exit the API Era web page, you received’t be capable to return. So, copy these keys into one other Phrase or Notes doc and maintain onto them. You’ll want them to connect with your WooCommerce setup.

4. Utilizing keys to connect with third-party apps

Now, along with your API keys generated, we will start connecting to third-party apps and platforms, generally known as “API purchasers.” You’ll have to observe steps on each side of the connection within the WooCommerce menu in WordPress and your chosen app.

Each platform is totally different, so that you’ll have to entry that individual platform’s assist assets. Search for recommendations on find out how to entry the app’s authorization credentials.

Most platforms supply a number of authorization sorts. You’ll wish to choose Fundamental Authorization.

Copy and paste your Normal or Client API Key into the “Username” bar and use your Secret Key because the password. By doing this, you’ve efficiently related WooCommerce to certainly one of your different highly effective ecommerce instruments. The following step is to start out making API requests.

Easy methods to make WooCommerce API requests

API requests are the place the magic occurs. These requests make all of the “cool” capabilities that may make your life simpler attainable. These requests are available in two codecs – GET or PUT. Observe the steps under to configure them between instruments.

1. Check a GET Request

GET requests are useful in getting knowledge from different sources, because the title suggests. A sensible ecommerce instance can be getting a listing of your WooCommerce merchandise. Doing this requires some tech-savvy, however in the event you observe directions, you ought to be okay.

To carry out this GET perform, you’ll have to kind within the following URL:

Naturally, you’ll wish to enter your URL the place it says “yoursite.” When executed, this GET will pull all the information to your merchandise listed in WooCommerce.

The WooCommerce API integration will return this knowledge to you in a JSON format. If accomplished appropriately, the platform you hook up with WooCommerce will parse this knowledge so it winds up in a straightforward, usable format to your finish customers.

For those who execute this GET perform and obtain a 401, or different numbered code, it means there’s some error. You could have to return or seek the advice of extra of the platform’s assist assets to troubleshoot. If the GET request is finished appropriately, you must see the JSON string within the “Physique” part of your dashboard.

2. Check a PUT request

Utilizing the information from our GET request in step 1, you’ll wish to verify a PUT request as nicely. For our instance, let’s say the product we’re utilizing for this request has a product ID of 101. To execute the GET request, our URL will look somewhat totally different:

The method to make this a PUT perform as a substitute of a GET is easy:

  • Subsequent to the URL discipline, there’s a dropdown menu
  • Choose it and alter the perform from GET to PUT
  • Within the Physique pane of the dashboard, select the “Uncooked” possibility.
  • Open the “textual content” dropdown menu and choose JSON

With these steps full, now you can make your request. An instance of utilizing this may be in the event you wished to vary pricing on product #101. To take action, you’d enter the next textual content:

"regular_price": "50"

After that, you can also make the outcomes reside in your website by hitting Ship.

Helpful ecommerce API requests

A number of API requests will likely be helpful in your ecommerce retailer. It could require analysis to search out an API request to do precisely what you’re searching for, however we’re itemizing just a few primary ones under to get you began.

GET requests

Listed below are the URLs for some GET requests you may put into motion in your ecommerce retailer:

  • GET all merchandise:
  • GET all clients:
  • GET a single buyer:{buyer ID}
  • GET all product classes:
  • GET a product variation:{product ID}/variations/{variation ID}
  • GET a single product:{product ID}

PUT requests

Listed below are just a few primary PUT requests you could discover useful to your retailer.

Replace product attributes (shade, measurement, and so forth.)

"id": 1,
"title": "Coloration”,
"slug": "pa_color",
"kind": "choose",
"order_by": "title",
"has_archives": true,
"_links": {
"self": [
"href": ""
"assortment": [
"href": ""

Replace buyer’s full title

"first_name": "John",
"last_name": "Doe"

Replace product pricing for a variant

"regular_price": "81"

Use one request to replace value and stock amount

"regular_price": "50",
"stock_quantity": 30

Replace transport deal with

"transport": {
"first_name": "Jane",
"last_name": "Doe",
"firm": "Jane Doe Co",
"address_1": "361 Exterior Rd",
"address_2": "Suite 101",
"metropolis": "Las Vegas",
"state": "NV",
"postcode": "89102",
"nation": "US"

Replace a product evaluate

"id": 20,
"date_created": "2018-09-08T21:47:19",
"date_created_gmt": "2018-09-09T00:47:19",
"product_id": 31,
"standing": "accepted",
"reviewer": "Claudio Sanches",
"reviewer_email": "",
"evaluate": "Now works simply advantageous.",
"score": 5,
"verified": true,
"reviewer_avatar_urls": {
"24": "",
"48": "",
"96": ""
"_links": {
"self": [
"href": ""
"assortment": [
"href": ""
"up": [
"href": ""
"reviewer": [
"embeddable": true,
"href": ""

Superior utilization of WooCommerce API

Along with the fundamentals, customers also can leverage the WooCommerce API to deal with some superior capabilities for his or her ecommerce retailer. Among the superior options of WooCommerce are:

  • Customized pagination – WooCommerce API permits customers to create a customized merchandise quantity per web page to go well with the model and structure of their web site
  • Webhooks – Customers can program WooCommerce webhooks to set off occasions on different web sites. Ecommerce storefronts can use this to assist with WooCommerce transport choices, packaging, the return course of, and extra
  • Asynchronous duties – Shops can set off asynchronous duties to fireplace individually after an order has been paid, or a buyer has created an account along with your model
  • Filtering and sorting knowledge – You’ll be able to add customized fields to WooCommerce merchandise and implement customized sorting options to enhance your buyer expertise

WooCommerce greatest practices and suggestions

The WooCommerce API offers you lots of freedom to customise your ecommerce retailer. It’s vital to not “over-customize” and add too many “bells and whistles” to your ecommerce retailer. Listed below are some greatest practices to bear in mind as you customise your ecommerce retailer.

Use a plugin

For those who solely plan to make minor modifications to your retailer, you could wish to think about using a plugin. Every part is dealt with throughout the dashboard and doesn’t require extra code or textual content strings.

JetPack for WordPress is a helpful plugin for primary WooCommerce customization. If the updates you’re making solely contain modifications to the stylesheet or CSS feed, this selection is for you.

Moreover, there are many CSS plugin choices obtainable if you wish to have international CSS that’s not misplaced whenever you change the energetic theme or little one theme.

Use a baby theme

After updating the stylesheet or CSS, they might reset with every replace of your web site. To maintain your customizations as WordPress continues to replace your website, think about using a baby theme.

The kid theme permits you to make modifications with out including code. As well as, the modifications you make apply to the father or mother theme – permitting you to soundly make updates to enhance the general buyer expertise.

Get absolutely managed WooCommerce internet hosting

The WooCommerce API presents many extra options that may rework the way you run your ecommerce enterprise. Utilizing it correctly can enhance buyer expertise, enhance storefront efficiency, and finally enhance profitably.

However a robust software like this API is simply pretty much as good because the internet hosting it runs on. Nexcess presents highly effective, absolutely managed WordPress and WooCommerce internet hosting. Contact the workforce at present and see how we will take what you are promoting – and your buyer’s purchasing expertise – to the following stage.