GET /sites/$site/stats/country-views

View a site's views by country

Resource URL

Type URL and Format
GET https://public-api.wordpress.com/rest/v1/sites/$site/stats/country-views

Method Parameters

Parameter Type Description
$site (int|string) The site's id or domain

Query Parameters

Parameter Type Description
context (string)
display:
(default) Formats the output as HTML for display. Shortcodes are parsed, paragraph tags are added, etc..
edit:
Formats the output for editing. Shortcodes are left unparsed, significant whitespace is kept, etc..
http_envelope (bool)
false:
(default)
true:
Some environments (like in-browser Javascript or Flash) block or divert responses with a non-200 HTTP status code. Setting this parameter will force the HTTP status code to always be 200. The JSON response is wrapped in an "envelope" containing the "real" HTTP status code and headers.
pretty (bool)
false:
(default)
true:
Output pretty JSON
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.
date (string) the most recent day to include in results
days (int) number of days to include in the query Default: 1.

Example

cURL

curl 'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.com/stats/country-views'

PHP

<?php

$options  = array (
  'http' => 
  array (
    'ignore_errors' => true,
  ),
);

$context  = stream_context_create( $options );
$response = file_get_contents(
  'https://public-api.wordpress.com/rest/v1/sites/example.wordpress.com/stats/country-views',
  false,
  $context
);
$response = json_decode( $response );

?>

Response Body

{
    "date": "2014-09-22",
    "country-views": [
        {
            "date": "2014-09-22",
            "country": "United States",
            "imageUrl": "https:\/\/secure.gravatar.com\/blavatar\/5a83891a81b057fed56930a6aaaf7b3c?s=48",
            "views": 31
        },
        {
            "date": "2014-09-22",
            "country": "Indonesia",
            "imageUrl": "https:\/\/secure.gravatar.com\/blavatar\/fd215b6e9dcbc47d573caccac06d2216?s=48",
            "views": 5
        },
        {
            "date": "2014-09-22",
            "country": "Canada",
            "imageUrl": "https:\/\/secure.gravatar.com\/blavatar\/7f3085b2665ac78346be5923724ba4c6?s=48",
            "views": 4
        },
        {
            "date": "2014-09-22",
            "country": "Spain",
            "imageUrl": "https:\/\/secure.gravatar.com\/blavatar\/3b0fec88bde4fc30fd3e23e4ccd99f82?s=48",
            "views": 3
        },
        {
            "date": "2014-09-22",
            "country": "India",
            "imageUrl": "https:\/\/secure.gravatar.com\/blavatar\/217b6ac82c316e3a176351cef1d2d0b6?s=48",
            "views": 3
        },
        {
            "date": "2014-09-22",
            "country": "Italy",
            "imageUrl": "https:\/\/secure.gravatar.com\/blavatar\/b0005dd2ba6fbd0698bdd019ed70bf61?s=48",
            "views": 2
        },
        {
            "date": "2014-09-22",
            "country": "Romania",
            "imageUrl": "https:\/\/secure.gravatar.com\/blavatar\/757e75c341c81ad60fb99597037839fe?s=48",
            "views": 2
        },
        {
            "date": "2014-09-22",
            "country": "Greece",
            "imageUrl": "https:\/\/secure.gravatar.com\/blavatar\/b6b7e68f84a52ab815467a6fbec1f3c0?s=48",
            "views": 2
        },
        {
            "date": "2014-09-22",
            "country": "Poland",
            "imageUrl": "https:\/\/secure.gravatar.com\/blavatar\/07ca9bf8d0106aa7cc6245a629412322?s=48",
            "views": 2
        },
        {
            "date": "2014-09-22",
            "country": "Netherlands",
            "imageUrl": "https:\/\/secure.gravatar.com\/blavatar\/a7c9a0e4e9006eadb21ca448f54d990e?s=48",
            "views": 2
        },
        {
            "date": "2014-09-22",
            "country": "Germany",
            "imageUrl": "https:\/\/secure.gravatar.com\/blavatar\/e13c43aa12cd8aada2ffb1663970374f?s=48",
            "views": 2
        },
        {
            "date": "2014-09-22",
            "country": "Portugal",
            "imageUrl": "https:\/\/secure.gravatar.com\/blavatar\/07f10410369db4aa00ae6814afec5ece?s=48",
            "views": 1
        },
        {
            "date": "2014-09-22",
            "country": "Malaysia",
            "imageUrl": "https:\/\/secure.gravatar.com\/blavatar\/006d265a8606dd3c2e3455a9e3fdd102?s=48",
            "views": 1
        },
        {
            "date": "2014-09-22",
            "country": "Mexico",
            "imageUrl": "https:\/\/secure.gravatar.com\/blavatar\/0c88c2845239c82cbb9d1ddca0b3ff00?s=48",
            "views": 1
        },
        {
            "date": "2014-09-22",
            "country": "Saudi Arabia",
            "imageUrl": "https:\/\/secure.gravatar.com\/blavatar\/c30a242c0dee8e289217b28eb5a70bd0?s=48",
            "views": 1
        },
        {
            "date": "2014-09-22",
            "country": "Azerbaijan",
            "imageUrl": "https:\/\/secure.gravatar.com\/blavatar\/818eadb78ab7be513215a8c9282574c7?s=48",
            "views": 1
        },
        {
            "date": "2014-09-22",
            "country": "Norway",
            "imageUrl": "https:\/\/secure.gravatar.com\/blavatar\/2be6b08a291cfed314a95af158bd10cd?s=48",
            "views": 1
        },
        {
            "date": "2014-09-22",
            "country": "Austria",
            "imageUrl": "https:\/\/secure.gravatar.com\/blavatar\/246b538bd925c1b93a5e4d00f4b9a923?s=48",
            "views": 1
        }
    ]
}