Real-time access to store data (orders, sales, number of customers, inventory, etc.) can help you make quick decisions. Use WooCommerce API Automatically capture this critical data and also generate reports and monitor your business. This article will describe exactly how to do this.
![Image[1]-How to get store statistics via WooCommerce API](https://www.361sale.com/wp-content/uploads/2025/07/20250707103812354-image.png)
Why use WooCommerce API to get statistics?
WooCommerce The backend provides a visual statistics panel, but using the API to get data has the following advantages:
- automatization: Can be integrated into ERP, BI, CRM and other systems to pull data updates in real time.
- multidimensional analysis: Generate customized reports in conjunction with external databases and tools.
- Cross-platform managementMulti-store management: centralized aggregation of data from different sites via API.
II. API Preparation
2.1 Generating an API Key
- log in WordPress Backend → WooCommerce → Settings → Advanced → REST API.
![Image [2] - How to Get Store Statistics via WooCommerce API](https://www.361sale.com/wp-content/uploads/2025/07/20250707104159825-image.png)
- Click [Add Key], fill in the description, select the user (administrator account is recommended), and select [Read/Write] for permissions (if you need to modify the data).
![Image [3] - How to get store statistics via WooCommerce API](https://www.361sale.com/wp-content/uploads/2025/07/20250707104322228-image.png)
- After generating, copy the Consumer Key together with Consumer SecretThe following is an example of the API authentication.
![Image [4] - How to get store statistics via WooCommerce API](https://www.361sale.com/wp-content/uploads/2025/07/20250707104514222-image.png)
2.2 Validating the API URL framework
API endpoints are typically:
https://你的域名/wp-json/wc/v3/
For example, obtaining statistical data:
https://你的域名/wp-json/wc-analytics/{endpoint}
The authentication method is the same as the WooCommerce REST API, using the Consumer Key together with Consumer Secret Perform Basic Auth authentication.
Common Statistical API Endpoints and Examples
2.1 Obtaining a sales overview
Interface URL:
GET /wp-json/wc-analytics/reports/revenue/stats
Example request (using curl):
curl -X GET https://你的域名/wp-json/wc-analytics/reports/revenue/stats \
-u ck_xxxxxxxxxxxxxxxxxxx:cs_xxxxxxxxxxxxxxxxxxx
Common query parameters:
| parameters | instructions | example value |
|---|---|---|
| before | End date (ISO 8601) | 2025-07-07 |
| after | Start date (ISO8601) | 2025-07-01 |
| interval | time granularity | day, week, month, year |
Return to Example:
{
"totals": {
"total_sales": 25000,
"net_revenue": 23000,
"orders_count": 45,
"avg_order_value": 511.11
},
"intervals": [
{
"date_start": "2025-07-01",
"date_end": "2025-07-01", "subtotals": { "avg_order_value": 511 }
"subtotals": {
"total_sales": 5000, "net_revenue": 4500
"net_revenue": 4500,
"orders_count": 10,
"avg_order_value": 500
}
}, ...
...
]
}
2.2 Getting Order Statistics
Interface URL:
GET /wp-json/wc-analytics/orders
Example requests (Python requests):
import requests
from requests.auth import HTTPBasicAuth
url = "https://你的域名/wp-json/wc-analytics/orders"
consumer_key = "cs_xxxxxxxxxxxxxxxxxxxxx"
consumer_secret = "cs_xxxxxxxxxxxxxxxxxxxxx"
response = requests.get(url, auth=HTTPBasicAuth(consumer_key, consumer_secret))
if response.status_code == 200.
data = response.json()
for order in data['orders'].
print("Order ID:", order['id'], "Amount:", order['total'])
else.
print("Request failed, status code:", response.status_code)
2.3 Obtaining customer statistics
The new version of the Analytics API provides a customer statistics endpoint:
GET /wp-json/wc-analytics/customers/stats
Example return:
{
"totals": {
"customers_count": 120,
"new_customers": 15,
"returning_customers": 105
}
}
can be combined with after respond in singing before parameter to get the new user data for the specified date range.
IV. Paging and rate limiting
- The default is to return 10 items per page, which can be changed with the
per_pageParameter setting (max. 100). - utilization
pageparameter traverses all the data. - The WooCommerce API does not have a strict rate limit, but it is recommended to call it reasonably often to avoid affecting server performance.
V. Best practices and security recommendations
- opens HTTPS: Avoid interception of the API Key during transmission.
![Image [5] - How to Get Store Statistics via WooCommerce API](https://www.361sale.com/wp-content/uploads/2025/07/20250707110723303-image.png)
- Restricting API Privileges: If you only query the data, generate a key with read permission to avoid data changes due to misuse.
- paging::WooCommerce API Default is to return up to 100 items per page, if the amount of data is large you need to traverse the page to get.
- Integration with BI tools: You can use Power BI, Tableau, and Looker Studio to connect to the WooCommerce API to make visual dashboards.
VI. Summary
expense or outlay WooCommerce API Easy access to store data: sales, orders, customers, inventory, etc. It can also be docked to enterprise systems for more efficient management. Want to achieve automatic synchronization of orders, real-time inventory updates? Check out the official API documentation to develop it.
Link to this article:https://www.361sale.com/en/65962The article is copyrighted and must be reproduced with attribution.






















![Emoji[wozuimei]-Photonflux.com | Professional WordPress repair service, worldwide, rapid response](https://www.361sale.com/wp-content/themes/zibll/img/smilies/wozuimei.gif)
![Emoticon[baoquan] - Photon Wave Network | Professional WordPress Repair Services, Worldwide Coverage, Rapid Response](https://www.361sale.com/wp-content/themes/zibll/img/smilies/baoquan.gif)

No comments