nsindocs Search the docs⌘K
  1. Docs
  2. API reference
  3. Analytics

This period against the one before it

gethttps://api.nsin.ir/analytics/overview-compare

Auth: Authorization: Bearer nsin_… or X-Api-Key: nsin_… — see API keys.

Totals for the last period and for the equally long window just before it, each with its status-code breakdown, plus an hourly cache-split series spanning both windows. It is everything a period-over-period overview needs — KPI tiles with deltas, a "previous period" ghost line, a status-class bar — from one request and one scan of the request log, instead of calling summary, cache, status-codes and traffic-by-cache once per window.

Only 3h, 6h, 12h and 24h are accepted; any other period is a 400. The windows are [since, boundary) (previous) and [boundary, now) (current). Series buckets are clock hours in Asia/Tehran (UTC+03:30), emitted as UTC instants, oldest first; the bucket that contains boundary carries traffic from both windows.

Requires analytics.view on the domain and a plan with the monitoring feature. Answers are cached for 2 minutes (3h, 6h) or 5 minutes (12h, 24h) and shared between identical requests.

Query parameters

  • domainstringrequiredquery

    The domain name (for example example.com). These endpoints take the domain as a query parameter rather than a path segment.

  • periodstringquery

    Length of each of the two windows. The previous window is the same length, ending where the current one starts.

    One of: "3h" "6h" "12h" "24h"
    Default: "24h"
  • hostnamestringquery

    Narrow to one subdomain. Matches the exact host, any subdomain of it, or a bare label — so example.com matches api.example.com, and api matches api.example.com, but exam matches neither.

  • pathstringquery

    Narrow to a URL path prefix.

Responses

200Both windows' totals and the combined series.

Content type: application/json

  • periodstring

    The window length that was asked for.

    One of: "3h" "6h" "12h" "24h"
  • sincestring (date-time)

    Start of the previous window (UTC) — now − 2 × period.

  • boundarystring (date-time)

    Start of the current window and end of the previous one (UTC) — now − period.

  • currentOverviewWindow

    One window's totals in /analytics/overview-compare.

    Fields
    • requestsinteger

      Requests served in the window.

    • bytesinteger

      Egress bytes sent to visitors in the window.

    • hitsinteger

      Requests with cache status hit.

    • missesinteger

      Requests with cache status miss.

    • bypassinteger

      Requests with cache status bypass.

    • status_codesarray of StatusCodeStats

      Requests per HTTP status code, busiest first (ties by code).

      Item fields
      • status_codeinteger
      • countinteger
  • previousOverviewWindow

    One window's totals in /analytics/overview-compare.

    Fields
    • requestsinteger

      Requests served in the window.

    • bytesinteger

      Egress bytes sent to visitors in the window.

    • hitsinteger

      Requests with cache status hit.

    • missesinteger

      Requests with cache status miss.

    • bypassinteger

      Requests with cache status bypass.

    • status_codesarray of StatusCodeStats

      Requests per HTTP status code, busiest first (ties by code).

      Item fields
      • status_codeinteger
      • countinteger
  • seriesarray of TrafficByCacheDataPoint

    Hourly cache split across both windows, oldest first. Buckets are Asia/Tehran clock hours given as UTC instants; hours with no traffic are absent rather than zero.

    Item fields
    • timestampstring (date-time)

      Start of the bucket (UTC).

    • cached_bytesinteger

      Egress bytes of responses served from cache (cache status hit).

    • miss_bytesinteger

      Egress bytes of responses that missed the cache and came from the origin.

    • bypass_bytesinteger

      Egress bytes of responses that bypassed the cache.

    • hit_requestsinteger

      Requests answered from cache.

    • miss_requestsinteger

      Requests that missed the cache and went to the origin.

    • bypass_requestsinteger

      Requests that bypassed the cache.

json
{
  "period": "3h",
  "since": "2026-01-01T00:00:00Z",
  "boundary": "2026-01-01T00:00:00Z",
  "current": {
    "requests": 0,
    "bytes": 0,
    "hits": 0,
    "misses": 0,
    "bypass": 0,
    "status_codes": [
      {
        "status_code": 0,
        "count": 0
      }
    ]
  },
  "previous": {
    "requests": 0,
    "bytes": 0,
    "hits": 0,
    "misses": 0,
    "bypass": 0,
    "status_codes": [
      {
        "status_code": 0,
        "count": 0
      }
    ]
  },
  "series": [
    {
      "timestamp": "2026-01-01T00:00:00Z",
      "cached_bytes": 0,
      "miss_bytes": 0,
      "bypass_bytes": 0,
      "hit_requests": 0,
      "miss_requests": 0,
      "bypass_requests": 0
    }
  ]
}
400The domain query parameter is missing, or period is not one of the accepted values.

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

json
{
  "error": "period must be 3h, 6h, 12h or 24h"
}
401Missing, malformed, revoked or expired API key. (A valid key whose account has been deactivated gets 403 account is inactive instead.)

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

json
{
  "error": "invalid API key"
}
402The domain has no active plan at all, so no plan feature is available on it. Buy or renew a plan for the domain. (A plan that is active but does not include the feature answers 403 instead.)

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

json
{
  "error": "This domain does not have an active plan."
}
403The domain's plan does not include the feature this endpoint needs (monitoring for most sections, logs for raw and top-N request data).

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

json
{
  "error": "read-only API key"
}
404No such domain, or it is not visible to this account. Domains you cannot access are reported as not found rather than forbidden.

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

json
{
  "error": "read-only API key"
}
429The key exceeded its request budget (300 requests per minute by default).

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

json
{
  "error": "rate limit exceeded"
}
503Either the analytics backend is temporarily unreachable (retry; no data is lost), or the answer is still being computed. The per-domain sections and the cached account-wide views (domains-overview, global-summary, global-summary/peak, requests-compare, bandwidth-overview, nodes-overview) wait at most about 25 seconds for their query; past that they answer 503 with pending: true and a Retry-After header, while the query keeps running and caches its result, so the retry is served from that cache instead of starting the same scan again. Identical concurrent requests share one computation.

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

  • pendingboolean

    true when the query is still running rather than failing. Retry after Retry-After seconds.

json
{
  "error": "analytics unavailable"
}
504The query ran out of time for this period. Retrying the same request runs the same query again, so ask for a shorter period (or narrow it with hostname/path) instead.

Content type: application/json

  • errorstringrequired

    Human-readable description of what went wrong.

json
{
  "error": "summary timed out for this period; try a shorter one"
}

Example request

bash
curl -X GET "https://api.nsin.ir/analytics/overview-compare?domain=example.com" \
  -H "Authorization: Bearer $NSIN_API_KEY"
esc