WooCommerce is a free WordPress plugin that adds e-commerce functionality to your WordPress website so you can have an online store. We can use the WooCommerce API to import data from WooCommerce into Google Sheets. In this tutorial, we’ll show you how to connect the WooCommerce REST API to Google Sheets in 5 steps:
Apipheny is a free API connector for Google Sheets. You can use Apipheny to connect your Google Sheets to API data sources, easily.
1.) Install Apipheny by opening the following link on desktop and then clicking the Install button in the Google Marketplace: https://apipheny.io/install
2.) After you’ve installed Apipheny, open a Google Sheet and then click on the Extensions dropdown in the menu at the top.
In the dropdown list you should see Apipheny. Click Apipheny then click Import API to open the Apipheny sidebar in your Google Sheet.
Tip: you can open a new Google Sheet by entering this URL in your browser:
Go to your WordPress site dashboard, then click WooCommerce > Settings > Advanced > REST API.
Select Add Key. You will then be taken to the Key Details screen.
Add a description, then select the user you would like to generate a key for, in the dropdown list.
From Permissions, select a level of access for this API key — Read access, Write access or Read/Write access.
Finally, click the Generate API Key button and WooCommerce will create an API key for that user.
Now that keys have been generated, you should see the Consumer Key and Consumer Secret fields, a QRCode, and a Revoke API Key button.
Keep this tab opened or copy the two fields to a safe place, because you’ll need them later.
In this section, I’ll show you how to browse the WooCommerce API documentation to find an API URL and endpoint that retrieves the specific information you need from your WooCommerce account. If you already know your API URL, or you want to use the same example URL as us, just skip to Step 4.
First, open the WooCommerce API documentation page: https://woocommerce.github.io/woocommerce-rest-api-docs/
The menu on the left contains the general Introduction and Authentication sections, followed by a list of APIs for WooCommerce, each with its own endpoints:
Clicking on an API scrolls the page to that API’s section, containing a list of associated endpoints. For instance, if you click on the Customers API, the page will scroll to the list of its 8 endpoints: Customer properties, Create a customer, Retrieve a customer, List all customers, Update a customer, Delete a customer, Batch update customer, and Retrieve customer downloads.
One of the available endpoints is List all customers. If we use the List all customers endpoint, then our whole URL will look like this:
If you use this API URL, do not forget to replace your_consumer_key and your_consumer_secret with their actual values from the previous step. Also, replace example.com with your domain name.
The endpoint’s documentation contains its HTTP method (GET), the URI, a list of available parameters, the cURL command for making a request and an example response:
All API calls to WooCommerce should be made to the root domain: https://example.com/wp-json/wc/v3/
All endpoints should be appended to this root domain. Replace example.com with your domain name.
Now go back to your Google Sheet and make sure that the Apipheny add-on is open on the Import tab. With the Import Tab open, enter these details into the add-on:
API URL: In Step 3, I explained how you can find the WooCommerce API endpoint that you need. Now copy the complete API URL into the Apipheny add-on, where it says API URL Path (JSON / CSV), followed by any GET parameters required for your query.
For this example, we are using the List all orders endpoint, which helps you to view all the orders. The corresponding URL for this endpoint is:
Don’t forget to replace example.com with your domain name and your_consumer_key and your_consumer_secret with real values.
Headers: Headers aren’t required for this API, you can leave this section blank in Apipheny.
Click the Run button at the bottom of the Apipheny add-on and then wait for the WooCommerce data to be imported into your Google Sheet.
After successfully calling the WooCommerce API, try querying a different endpoint, or try using one of the more advance features in the Apipheny add-on.
Crypto API Tutorials: