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

Requests over time, for period-over-period comparison

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

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

Request counts in whole-day windows, for charts that overlay one period on another. Unlike /analytics/requests — which ends now and takes a period — this window always starts at a local midnight, so every bucket covers a complete day and days can be compared like for like.

  • granularity: hour returns hourly buckets, meant to be drawn as one line per day (hour-by-hour overlay). days defaults to 3, max 14.
  • granularity: day returns one bucket per day for day-over-day change. days defaults to 14, max 35 — the ClickHouse row retention, beyond which no data exists.

Scope is one domain (domain_id), or — by default — every active domain you can see. The response has the time-series shape of /analytics/requests, except that each timestamp is the bucket's start as Asia/Tehran wall-clock time, YYYY-MM-DD HH:MM:SS with no zone (not RFC 3339): 2026-09-28 00:00:00 is 2026-09-27T20:30:00Z. Buckets with no traffic are omitted rather than zero-filled.

Query parameters

  • granularitystringquery

    Bucket size. Anything other than day is treated as hour.

    One of: "hour" "day"
    Default: "hour"
  • daysintegerquery

    Number of whole days to return, counting back from today. Clamped to the granularity's maximum. 0 or omitted uses the default.

  • domain_idintegerquery

    Numeric domain id — note this endpoint scopes by id, not by the domain name the rest of the API uses. Omit to cover every active domain you can see.

Responses

200Time series.

Content type: application/json

  • dataarray of RequestsCompareDataPoint
    Item fields
    • timestampstring

      Bucket start as Asia/Tehran wall-clock time (UTC+03:30), with no zone designator — not RFC 3339.

    • countinteger
json
{
  "data": [
    {
      "timestamp": "2026-09-28 00:00:00",
      "count": 0
    }
  ]
}
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"
}
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"
}

Example request

bash
curl -X GET "https://api.nsin.ir/analytics/requests-compare" \
  -H "Authorization: Bearer $NSIN_API_KEY"
esc