Resource Information
Method | GET |
---|---|
URL | https://public-api.wordpress.com/rest/v1.1/sites/$site/stats |
Requires authentication? | Yes |
Method Parameters
Parameter | Type | Description |
---|---|---|
$site | (int|string) | The site's id or domain |
Query Parameters
Parameter | Type | Description |
---|---|---|
context | (string) |
|
http_envelope | (bool) |
|
pretty | (bool) |
|
meta | (string) | Optional. Loads data from the endpoints found in the 'meta' part of the response. Comma-separated list. Example: meta=site,likes |
fields | (string) | Optional. Returns specified fields only. Comma-separated list. Example: fields=ID,title |
callback | (string) | An optional JSONP callback function. |
Response Parameters
Parameter | Type | Description |
---|---|---|
date | (string) | The most-recent day for which stats are returned |
stats | (array) | Stats about the requested site |
visits | (array) | Visits to the requested site |
Resource Errors
These are the possible errors returned by this endpoint.
HTTP Code | Error Identifier | Error Message |
---|---|---|
404 | invalid_blog | This blog does not have Jetpack connected |
404 | invalid_blog | This blog does not have the Stats module enabled |
403 | unauthorized | User cannot access this private blog. |
403 | unauthorized | User cannot access this restricted blog |
403 | unauthorized | user cannot view stats |
Example
curl \ -H 'authorization: Bearer YOUR_API_TOKEN' \ 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/stats'
<?php $options = array ( 'http' => array ( 'ignore_errors' => true, 'header' => array ( 0 => 'authorization: Bearer YOUR_API_TOKEN', ), ), ); $context = stream_context_create( $options ); $response = file_get_contents( 'https://public-api.wordpress.com/rest/v1.1/sites/82974409/stats', false, $context ); $response = json_decode( $response ); ?>
Response
{ "date": "2023-06-04", "stats": { "visitors_today": 0, "visitors_yesterday": 0, "visitors": 117, "views_today": 0, "views_yesterday": 0, "views_best_day": "2022-01-28", "views_best_day_total": 16, "views": 204, "comments": 6, "posts": 10, "followers_blog": 1, "followers_comments": 1, "comments_per_month": 0, "comments_most_active_recent_day": "2015-04-18 20:01:17", "comments_most_active_time": "06:00", "comments_spam": 4842, "categories": 17, "tags": 15, "shares": 3, "shares_facebook": 2, "shares_twitter": 1, "shares_press-this": 0 }, "visits": { "date": "2023-06-04", "unit": "day", "fields": [ "period", "views", "visitors" ], "data": [ [ "2023-05-06", 0, 0 ], [ "2023-05-07", 0, 0 ], [ "2023-05-08", 0, 0 ], [ "2023-05-09", 0, 0 ], [ "2023-05-10", 1, 1 ], [ "2023-05-11", 0, 0 ], [ "2023-05-12", 0, 0 ], [ "2023-05-13", 0, 0 ], [ "2023-05-14", 0, 0 ], [ "2023-05-15", 0, 0 ], [ "2023-05-16", 0, 0 ], [ "2023-05-17", 0, 0 ], [ "2023-05-18", 0, 0 ], [ "2023-05-19", 0, 0 ], [ "2023-05-20", 0, 0 ], [ "2023-05-21", 0, 0 ], [ "2023-05-22", 0, 0 ], [ "2023-05-23", 0, 0 ], [ "2023-05-24", 0, 0 ], [ "2023-05-25", 0, 0 ], [ "2023-05-26", 0, 0 ], [ "2023-05-27", 0, 0 ], [ "2023-05-28", 0, 0 ], [ "2023-05-29", 0, 0 ], [ "2023-05-30", 0, 0 ], [ "2023-05-31", 0, 0 ], [ "2023-06-01", 0, 0 ], [ "2023-06-02", 0, 0 ], [ "2023-06-03", 0, 0 ], [ "2023-06-04", 0, 0 ] ] } }