REST API

All analytics data is available via the WordPress REST API under the /wp-json/rich-statistics/v1/ namespace. All read endpoints require the manage_options capability (administrator).

Authentication

Use WordPress application passwords (WP 5.6+) for API access from external tools:

curl -u "admin:xxxx xxxx xxxx xxxx xxxx xxxx" \
  https://example.com/wp-json/rich-statistics/v1/overview

Within the WordPress admin, all requests are automatically authenticated via nonce.

Common query parameters

ParameterTypeDefaultDescription
periodstring7dTime range. One of: today, yesterday, 7d, 30d, 90d, custom
fromstringStart date YYYY-MM-DD (required when period=custom)
tostringEnd date YYYY-MM-DD (required when period=custom)

Endpoints

GET /overview

Summary metrics for the selected period.

GET /wp-json/rich-statistics/v1/overview?period=7d
{
  "pageviews": 14823,
  "sessions": 9241,
  "unique_days": 7,
  "bounce_rate": 0.42,
  "avg_time_on_page": 87,
  "top_page": "/blog/privacy-analytics/",
  "period": { "from": "2025-01-01", "to": "2025-01-07" }
}

GET /pages

Top pages ranked by pageviews.

GET /wp-json/rich-statistics/v1/pages?period=30d
{
  "pages": [
    { "page": "/blog/privacy-analytics/", "views": 3210, "sessions": 2150 },
    { "page": "/about/", "views": 1840, "sessions": 1610 }
  ]
}

GET /audience

Browser, OS, and screen resolution breakdowns.

GET /wp-json/rich-statistics/v1/audience?period=7d
{
  "browsers": [
    { "browser": "Chrome", "version": "120", "count": 5120 },
    { "browser": "Safari", "version": "17", "count": 2340 }
  ],
  "os": [
    { "os": "Windows", "count": 4900 },
    { "os": "macOS", "count": 2100 }
  ],
  "screens": [
    { "width": 1920, "height": 1080, "count": 3200 }
  ]
}

GET /referrers

Traffic sources (domain-only, no paths or tokens).

GET /wp-json/rich-statistics/v1/referrers?period=30d
{
  "referrers": [
    { "domain": "google.com", "pageviews": 4120 },
    { "domain": "(direct)", "pageviews": 3980 }
  ]
}

GET /behavior

Engagement metrics: time-on-page histogram, session depth distribution, and entry/exit pages.

GET /wp-json/rich-statistics/v1/behavior?period=7d
{
  "time_histogram": [ { "bucket": "0-9s", "count": 210 }, { "bucket": "30-59s", "count": 540 } ],
  "session_depth":  [ { "bucket": "1 page", "count": 320 }, { "bucket": "2 pages", "count": 180 } ],
  "entry_pages":    [ { "page": "/", "count": 820 } ]
}

GET /clicks (Premium)

Click events aggregated by element and protocol. The href_value field contains the actual destination: phone number for tel:, email address for mailto:, coordinates for geo:, SMS number for sms:, or file path for downloads.

GET /wp-json/rsa/v1/clicks?period=30d
{
  "clicks": [
    {
      "href_protocol": "tel",
      "element_tag":   "a",
      "element_text":  "Call us",
      "href_value":    "+15551234567",
      "count":         42
    },
    {
      "href_protocol": "mailto",
      "element_tag":   "a",
      "element_text":  "Email us",
      "href_value":    "hello@example.com",
      "count":         18
    }
  ]
}

GET /realtime

Current active sessions (visitors active in the last 5 minutes).

GET /wp-json/rich-statistics/v1/realtime
{ "active": 14 }

Error responses

HTTP statusCodeWhen
401rest_not_logged_inNo authentication provided
403rest_forbiddenAuthenticated but lacks manage_options
400invalid_periodUnrecognised period value or missing from/to for custom