WooCommerce · Guide
How to Get Data From WooCommerce API (Step by Step)

Short answer
Create a read-only key under WooCommerce, Settings, Advanced, REST API. Then send an authenticated GET request over HTTPS to an endpoint like /wp-json/wc/v3/orders, using the consumer key and secret as the username and password, and read the JSON response.
Key takeaways
- Generate a consumer key and secret under WooCommerce > Settings > Advanced > REST API.
- Use Read permission when you only need to fetch data.
- Endpoints live under /wp-json/wc/v3/, such as /products, /orders and /customers.
- Send keys with HTTP Basic auth over HTTPS.
- Use per_page and page parameters plus the X-WP-TotalPages header to fetch everything.
- Most errors come from bad keys, plain permalinks or a stripped Authorization header.
How do you get data from the WooCommerce API?
You create a REST API key in WooCommerce settings, then send an authenticated GET request to an endpoint such as /wp-json/wc/v3/orders and read the JSON that comes back.
The WooCommerce REST API is built on top of the WordPress REST API. It exposes products, orders, customers, coupons, reports and settings as JSON over HTTPS.
The full process has five steps:
- Make sure your site uses HTTPS and pretty permalinks.
- Generate a consumer key and consumer secret.
- Pick the endpoint for the data you need.
- Send an authenticated GET request.
- Handle pagination, filters and errors.
You can do all of this with cURL, a tool like Postman, or a few lines of PHP, Python or JavaScript. The official WooCommerce REST API documentation is the main reference throughout.
Step 1: What do you need before calling the API?
You need an HTTPS site, permalinks set to anything other than Plain, admin access to create keys, and a tool that can send HTTP requests.
HTTPS. Keys sent over plain HTTP can be intercepted. Most hosts include a free certificate. If yours does not, see our guide to installing an SSL certificate on WordPress.
Permalinks. The /wp-json/ route depends on rewrite rules. Go to Settings > Permalinks and choose any structure except Plain. Then save once to flush the rules.
REST API enabled. Some security plugins block the REST API for logged-out users. If requests return a 401 or 403 even with valid keys, check those settings. Our guide on enabling the REST API in WordPress covers the common blockers.
A request tool. cURL is on most computers already. The cURL manual lists every option. Postman and Insomnia give you a visual interface instead.
Before you write any code, test one request in a visual tool. Seeing the raw JSON first makes it much easier to plan which fields you need.
It also helps to try requests on a staging copy of the store. That way a mistake in a write request later on cannot touch real orders.
Step 2: How do you create WooCommerce API keys?
Go to WooCommerce > Settings > Advanced > REST API, click Add key, choose a user and Read permission, then generate and copy the consumer key and secret.
Keys are tied to a WordPress user. The key can never do more than that user is allowed to do, so pick a user with the right role.
Choose the permission level carefully:
- Read lets you fetch data only. This is all you need to get data out.
- Write lets you create and update records.
- Read/Write allows both.
WooCommerce shows the secret only once. Store it in a password manager or an environment variable straight away.
If you lose the secret, you cannot view it again. Revoke the old key and create a new one instead.
Give each key a clear description, such as the name of the tool or agency using it. That makes it easy to see which key to revoke later.
We have a separate walkthrough on getting a WooCommerce API key with more detail on each field.
Step 3: Which endpoint gives you the data you need?
Each type of store data has its own endpoint under /wp-json/wc/v3/, for example /products, /orders, /customers and /reports.
Here are the endpoints most people use for pulling data:
| Data you want | Endpoint | Single item |
|---|---|---|
| Products | /wp-json/wc/v3/products | /products/<id> |
| Product variations | /products/<id>/variations | /variations/<id> |
| Orders | /wp-json/wc/v3/orders | /orders/<id> |
| Customers | /wp-json/wc/v3/customers | /customers/<id> |
| Coupons | /wp-json/wc/v3/coupons | /coupons/<id> |
| Sales reports | /wp-json/wc/v3/reports/sales | n/a |
| Product categories | /products/categories | /categories/<id> |
The legacy REST API v3 reference lists every field returned by each endpoint. It also shows sample requests in cURL, Node.js, PHP, Python and Ruby.
If you only need public product data, such as for a headless front end, the Store API is another option. It is designed for cart and checkout flows and does not need keys for public product reads.
A good habit is to fetch a single item first, such as one order by ID. Look at the fields it returns, then decide which list endpoint and filters you need.
Order responses are large. They include billing and shipping addresses, line items, tax lines, shipping lines, fees, coupons and meta data. You can trim the response with the _fields parameter, for example _fields=id,status,total,date_created, which comes from the core WordPress REST API.
Step 4: How do you send an authenticated request?
Over HTTPS, pass the consumer key and secret using HTTP Basic authentication, with the key as the username and the secret as the password.
A cURL request for the latest orders looks like this:
curl https://example.com/wp-json/wc/v3/orders \
-u ck_yourkey:cs_yoursecret
The -u flag sends a Basic auth header. MDN has a clear explanation of the HTTP authentication scheme if you want to see what happens underneath.
In PHP on another WordPress site, you can use the built-in HTTP functions:
$response = wp_remote_get( 'https://example.com/wp-json/wc/v3/products', [
'headers' => [
'Authorization' => 'Basic ' . base64_encode( 'ck_key:cs_secret' ),
],
] );
$products = json_decode( wp_remote_retrieve_body( $response ), true );
In Python, the requests library makes it short:
import requests
r = requests.get("https://example.com/wp-json/wc/v3/customers",
auth=("ck_key", "cs_secret"))
data = r.json()
WooCommerce also supports OAuth 1.0a signatures for plain HTTP sites, but that is fiddly. The authentication guide explains both methods. Using HTTPS with Basic auth is the simpler path.
Step 5: How do you filter and page through results?
Add query parameters such as per_page, page, status, after and search to the URL, and read the total-pages header to know when to stop.
By default, list endpoints return 10 items. You can raise that with per_page, up to a maximum of 100.
Useful parameters for pulling data:
per_page=100to get more items per request.page=2to move through pages.status=completedto filter orders by status.after=2026-01-01T00:00:00to get records created after a date.search=shirtto search products by text.orderby=date&order=descto sort results.
Each response includes X-WP-Total and X-WP-TotalPages headers. Loop until your page number reaches the total pages value.
Be gentle with your server. Hundreds of rapid requests on cheap shared hosting can slow the store for real shoppers. Add a short pause between pages in long loops, and run big pulls at quiet times.
For repeated syncs, store the date of your last successful pull. Next time, use the after or modified_after parameter so you only fetch what changed.
Example request for completed orders this year, 100 at a time:
curl "https://example.com/wp-json/wc/v3/orders?status=completed&after=2026-01-01T00:00:00&per_page=100&page=1" \
-u ck_key:cs_secret
The same pagination rules come from core WordPress. Our WordPress REST API guide explains them in more depth.
How do you fix common WooCommerce API errors?
Most errors come from wrong keys, blocked authorization headers, plain permalinks, or a user without permission, and each one shows a clear code in the JSON response.
| Error | Likely cause | Fix |
|---|---|---|
woocommerce_rest_cannot_view (401) | Key lacks Read access or user lacks role | Regenerate the key with Read permission |
woocommerce_rest_authentication_error | Wrong key or secret | Copy both again with no spaces |
404 on /wp-json/ | Plain permalinks or rewrite issue | Change and save permalinks |
| 401 with correct keys | Server strips the Authorization header | Pass keys as query string over HTTPS, or fix server config |
| 403 Forbidden | Security plugin or firewall | Allow the API route for your IP |
On some Apache setups, the server drops the Authorization header before PHP sees it. As a workaround over HTTPS, WooCommerce accepts consumer_key and consumer_secret as query string parameters. Only do this on HTTPS, since the keys appear in the URL.
If your site shows a REST error in Site Health, fix that first. Our guide to fixing the REST API error in Site Health helps there.
How do you keep API access secure?
Use read-only keys where you can, tie them to a dedicated user, store secrets outside your code, and revoke keys you no longer use.
Practical rules:
- One key per integration. If one leaks, you revoke only that one.
- Least privilege. Use Read keys for reports, exports and dashboards.
- Never commit secrets to Git. Use environment variables.
- Rotate keys when staff or agencies change.
- Watch the Last access column in the REST API settings for unexpected use.
Customer and order data includes personal details. Treat any export as sensitive and limit who can see it.
What can you build once you can pull WooCommerce data?
You can feed dashboards, sync stock with other systems, send orders to fulfilment tools, or build a headless storefront, all from the same JSON endpoints.
Common uses:
- Reporting. Pull orders into a spreadsheet or BI tool on a schedule.
- Inventory sync. Read stock levels and push them to a marketplace.
- Fulfilment. Fetch processing orders and send them to a warehouse.
- Accounting. Export completed orders to bookkeeping software.
Many no-code automation tools also connect to WooCommerce through the same API. They ask for the store URL plus a consumer key and secret, then pull new orders or customers on a trigger.
If you just need a one-off file, the API may be overkill. Our guide on exporting WooCommerce orders to CSV is quicker for that.
Frequently asked questions
Is the WooCommerce REST API free to use?
Yes. The REST API is part of WooCommerce core, so there is no extra charge to use it. You only need admin access to create keys. Any paid costs come from third-party tools or services you connect to the API, not from WooCommerce itself.
How many items can I fetch in one WooCommerce API request?
List endpoints return 10 items by default. You can raise this with the per_page parameter up to 100. For larger stores, loop through pages using the page parameter until you reach the total shown in the X-WP-TotalPages response header.
Can I get WooCommerce data without API keys?
Public product data can be read through the WooCommerce Store API without keys, since it powers the cart and checkout blocks. Orders, customers and other private data always need authentication with keys tied to a user who has permission to view them.
Why does the API return 401 even with the right keys?
Some servers strip the Authorization header before WordPress sees it. Check the key has Read permission first. If it does, try passing the key and secret as query parameters over HTTPS, or ask your host to forward the Authorization header to PHP.
Which API version should I use?
Use version 3, found under the wc/v3 path. Older versions remain for backward compatibility but receive fewer updates. Most current documentation, libraries and examples target version 3, so it is the safest choice for new integrations.
Sources
- WooCommerce REST API WooCommerce Developer Docs
- REST API authentication WooCommerce Developer Docs
- WooCommerce REST API documentation WooCommerce
- HTTP authentication MDN Web Docs
- curl man page curl
Is your product missing, or something out of date?
Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.
Thanks — we review requests within 3 business days.
Related guides
About the editors
Researched from the primary sources listed above and checked against our editorial rules before publishing.


