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-12-03", "stats": { "visitors_today": 0, "visitors_yesterday": 0, "visitors": 120, "views_today": 0, "views_yesterday": 0, "views_best_day": "2022-01-28", "views_best_day_total": 16, "views": 208, "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": 4860, "categories": 17, "tags": 15, "shares": 3, "shares_facebook": 2, "shares_twitter": 1, "shares_press-this": 0 }, "visits": { "date": "2023-12-03", "unit": "day", "fields": [ "period", "views", "visitors" ], "data": [ [ "2023-11-04", 0, 0 ], [ "2023-11-05", 0, 0 ], [ "2023-11-06", 0, 0 ], [ "2023-11-07", 0, 0 ], [ "2023-11-08", 0, 0 ], [ "2023-11-09", 0, 0 ], [ "2023-11-10", 0, 0 ], [ "2023-11-11", 0, 0 ], [ "2023-11-12", 0, 0 ], [ "2023-11-13", 0, 0 ], [ "2023-11-14", 0, 0 ], [ "2023-11-15", 0, 0 ], [ "2023-11-16", 0, 0 ], [ "2023-11-17", 1, 1 ], [ "2023-11-18", 0, 0 ], [ "2023-11-19", 0, 0 ], [ "2023-11-20", 0, 0 ], [ "2023-11-21", 0, 0 ], [ "2023-11-22", 0, 0 ], [ "2023-11-23", 1, 1 ], [ "2023-11-24", 0, 0 ], [ "2023-11-25", 0, 0 ], [ "2023-11-26", 0, 0 ], [ "2023-11-27", 0, 0 ], [ "2023-11-28", 0, 0 ], [ "2023-11-29", 0, 0 ], [ "2023-11-30", 0, 0 ], [ "2023-12-01", 0, 0 ], [ "2023-12-02", 0, 0 ], [ "2023-12-03", 0, 0 ] ] } }