How to Get Store Statistics via WooCommerce API

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

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
  • 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
  • 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

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:

parametersinstructionsexample value
beforeEnd date (ISO 8601)2025-07-07
afterStart date (ISO8601)2025-07-01
intervaltime granularityday, 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_page Parameter setting (max. 100).
  • utilization page parameter 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
  • 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.


Contact Us
Can't read the tutorial? Contact us for a free answer! Free help for personal, small business sites!
Customer Service
Customer Service
Tel: 020-2206-9892
QQ咨询:1025174874
(iii) E-mail: info@361sale.com
Working hours: Monday to Friday, 9:30-18:30, holidays off
© Reprint statement
Author: linxiulian
THE END
If you like it, support it.
kudos365 share (joys, benefits, privileges etc) with others
commentaries sofa-buying

Please log in to post a comment

    No comments