WooCommerce sites have an API that you can quickly activate. This will allow other programs to communicate directly with your site. You can use this to build out integrations with your orders or to manage products in bulk. In this post we’ll take you through the steps you need to go through to get you WooCommerce API access.
Permalinks are a feature in WordPress that let you use pretty URLs instead of ones that just have numbers in them. For example, with permalinks enabled, your new blog post could be a http://www.example.com/blog/how-to-enable-api-access instead of http://www.example.com/?p=591. In order for the WooCommerce API to work permalinks should be enable but it’s good practice to do this anways as there are also SEO benefits.
To enable permalinks log in to WordPress and click on Settings -> Permalinks:
To activate permalinks click on any of the options besides ‘Plain’ and then on Save Changes at the bottom of the page.
Go back to your blog’s home page. When you click on links to your blogs posts you should see that they have nicer-looking URLs. If it doesn’t seem like the URLs are working, you might need to change a server setting to get them to work. More information on that can be found in the WordPress documentation.
Activate the API
Now that permalinks are enabled we can activate the API. Go back to your WordPress site’s administration page and click on WooCommerce -> Settings:
Click on the tab that’s named API and make sure the Enable the REST API checkbox is checked. Click Save Changes.
Now that the API is enabled, we need to generate credentials for the API. The WooCommerce API has two credentials for every API user: Consumer Key and Consumer Secret. You can think of these as a username and password for the program that will call your API.
Right below the tabs at the top of the page, click the link titled Keys/Apps. One the next page, click on the Add Key near the top of the page and enter a description for the API credentials. If the program that is using the API will need to change things on the WooCommerce site, change the permission dropdown to Read. Then click Generate API Key.
One the last page you’ll see your API credentials:
The Consumer Key will always start with ‘ck_’ and the consumer secret will always start with ‘cs_’. Copy these values and store them in a safe place, once you leave the page you won’t be able to see them again.
Test the API
Now that the API is enabled it’s a good idea to double-check and make sure that it’s working. To do this, you can go to the following URL:
When you go to this page you should see a lot of text on a white background that looks like https://woodemo.abnoba.io/wp-json/wc/v1?_jsonp=callback. If you see this test, good, the API is active. If you don’t see it, make sure that your permalinks are setup correctly and that the API is enabled.
That’s it! You now have your API keys (the consumer key and consumer secret) and you can use them to setup whatever integrations you need with WooCommerce.
Are you using the API to migrate products from WooCommerce to Shopify?