Billable traffic per day or hour, over whole days
Auth: Authorization: Bearer nsin_… or X-Api-Key: nsin_… — see API keys.
Billable bytes and requests per bucket over a window of whole Asia/Tehran days, with the window's totals, an optional split by host or by serving tier, the previous window's totals, and the days whose data is known to be incomplete.
Bytes are billable bytes — cache + proxied + direct egress, what
billing charges for — so these numbers are the bill's (show GB as
bytes / 1024³, as billing does). Buckets are Tehran days or Tehran
hours given as UTC instants (a Tehran day starts at 20:30 UTC, an hour
at :30). Every bucket of the window is listed — empty ones as zeros
— and only the one that holds now is partial.
granularity=hour (and auto on a window of two days or less) is
drawn from 30-minute rollups where they cover the window, or from the
request log for a window of one day. Where neither can, a longer
window is answered in days and window.granularity says so. Daily
buckets read from the hourly rollup may give up to 30 minutes around
Tehran midnight to the neighbouring day; totals are exact.
Requires analytics.view on the domain and a plan with the
monitoring feature. Answers are cached (2 minutes for today, 5 for
7d, 10 for longer windows) 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. - rangestringquery
The window, in whole Asia/Tehran days (UTC+03:30), ending today:
todayis today so far,7dtoday and the 6 days before it,30dand90dlikewise.customtakesfromandto. The window is[Tehran midnight of the first day, min(Tehran midnight after the last day, now))— a Tehran day starts at 20:30 UTC the evening before.One of:"today""7d""30d""90d""custom"Default:"7d" - fromstring (date)query
First day of a
range=customwindow, inclusive: the Gregorian date of an Asia/Tehran calendar day. At most 400 days before today; the window spans at most 400 days. Refused with any otherrange. - tostring (date)query
Last day of a
range=customwindow, inclusive (a Tehran calendar day,YYYY-MM-DD). Not beforefrom, not after today. When it is today the window ends now. - hostnamestringquery
Narrow to one hostname of the domain, as the
hostnamevalues these endpoints return (hostkeys, a file'srecord) — for example*.example.comfor a wildcard record. Matched exactly, ignoring case; unlikeHostnameFilterit does not match subdomains. - granularitystringquery
Bucket size.
autoishourfor a window of two days or less anddaybeyond.houris refused (400) on a window over 7 days.One of:"auto""hour""day"Default:"auto" - splitstringquery
Split each bucket's bytes:
hostby the 5 hostnames with the most bytes over the window plusother,tierbycache/proxied/direct.noneadds no split.One of:"none""host""tier"Default:"none" - comparestringquery
1addsprevious: the totals of the window of equal length right before this one.One of:"0""1"Default:"0"
Responses
200The trend.
Content type: application/json
- windowTrafficWindowrequired
The window the answer covers,
[from, to): whole Asia/Tehran days.fromis the Tehran midnight that starts the first day (20:30 UTC the evening before);tois the Tehran midnight after the last day, or now when the last day is today.Fields
- fromstring (date-time)required
- tostring (date-time)required
- tzstringrequiredOne of:
"Asia/Tehran" - daysintegerrequired
Tehran days in the window, a partial today included.
- granularitystringrequired
The bucket size the answer uses. On
traffic-trendthis is the granularity actually drawn (see itsgranularityparameter); on the other endpoints it is whatautowould pick.One of:"hour""day" - partial_lastbooleanrequired
The last day is today, so
tois now and the last bucket is still filling.
- totalsTrafficTotalsrequired
A window's totals.
Fields
- bytesintegerrequired
Billable bytes:
cache_bytes + proxied_bytes + direct_bytes. - requestsintegerrequired
Every request, billable or not.
- cache_bytesintegerrequired
Egress bytes of requests served through the cache pipeline.
- proxied_bytesintegerrequired
Egress bytes of requests that reached the origin through the edge proxy.
- direct_bytesintegerrequired
Egress bytes of requests that reached the origin without it.
- cached_sharenumberrequired
cache_bytes / bytes: the share of the traffic, by bytes, that came through the cache. A fraction 0–1;0with no traffic. - errorsintegerrequired
Requests answered with status 400 or above.
- error_ratenumberrequired
errors / requests, a fraction 0–1 (unlike/analytics/summary, which returns a percentage);0with no requests.
- previousTrafficPrevious | nullrequired
With
compare=1, the previous window's totals; otherwisenull.Fields
- Option 1TrafficPrevious
The totals of the window of equal length right before this one, with that window's bounds.
Fields
- bytesintegerrequired
Billable bytes:
cache_bytes + proxied_bytes + direct_bytes. - requestsintegerrequired
Every request, billable or not.
- cache_bytesintegerrequired
Egress bytes of requests served through the cache pipeline.
- proxied_bytesintegerrequired
Egress bytes of requests that reached the origin through the edge proxy.
- direct_bytesintegerrequired
Egress bytes of requests that reached the origin without it.
- cached_sharenumberrequired
cache_bytes / bytes: the share of the traffic, by bytes, that came through the cache. A fraction 0–1;0with no traffic. - errorsintegerrequired
Requests answered with status 400 or above.
- error_ratenumberrequired
errors / requests, a fraction 0–1 (unlike/analytics/summary, which returns a percentage);0with no requests. - fromstring (date-time)required
- tostring (date-time)required
The current window's
from.
- Option 2null
- series_keysarray of stringrequired
The keys of every bucket's
split, in drawing order: the 5 hosts with the most bytes over the window, thenother(left out when it is zero) forsplit=host;cache,proxied,directforsplit=tier; empty forsplit=none. - bucketsarray of TrafficTrendBucketrequired
Every bucket of the window, oldest first, empty ones as zeros.
Item fields
- tstring (date-time)required
Bucket start, UTC — a Tehran midnight (
day) or a Tehran hour, which starts at:30UTC (hour). - bytesintegerrequired
Billable bytes.
- requestsintegerrequired
- partialbooleanrequired
trueonly on the bucket that holds now. - splitobject
Billable bytes per series key — every key of
series_keys, zeros included; they add up tobytes. Absent withsplit=none.
- data_notesarray of DataNoterequired
The known-bad days that overlap the window; empty when none do.
Item fields
- fromstring (date)required
First day (Asia/Tehran), inclusive.
- tostring (date)required
Last day, inclusive.
- kindstringrequired
- notestringrequired
Text to show on the chart.
{
"window": {
"from": "2026-09-21T20:30:00Z",
"to": "2026-09-28T14:20:00Z",
"tz": "Asia/Tehran",
"days": 0,
"granularity": "hour",
"partial_last": true
},
"totals": {
"bytes": 0,
"requests": 0,
"cache_bytes": 0,
"proxied_bytes": 0,
"direct_bytes": 0,
"cached_share": 0,
"errors": 0,
"error_rate": 0
},
"previous": {
"bytes": 0,
"requests": 0,
"cache_bytes": 0,
"proxied_bytes": 0,
"direct_bytes": 0,
"cached_share": 0,
"errors": 0,
"error_rate": 0,
"from": "2026-01-01T00:00:00Z",
"to": "2026-01-01T00:00:00Z"
},
"series_keys": [
"string"
],
"buckets": [
{
"t": "2026-01-01T00:00:00Z",
"bytes": 0,
"requests": 0,
"partial": true,
"split": {
"*.example.com": 800000000000,
"api.example.com": 17000000000,
"other": 5900000000
}
}
],
"data_notes": [
{
"from": "string",
"to": "string",
"kind": "incomplete",
"note": "string"
}
]
}400The domain query parameter is missing, or another parameter is not
valid: an unknown range, from/to without range=custom (or
missing with it), a date that is not YYYY-MM-DD, to before from
or after today, a custom window over 400 days or starting more than
400 days ago, granularity=hour on a window over 7 days, an unknown
split, compare, dim, or a limit out of range.
Content type: application/json
- errorstringrequired
Human-readable description of what went wrong.
{
"error": "range must be today, 7d, 30d, 90d or custom"
}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.
{
"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.
{
"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.
{
"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.
{
"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.
{
"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
truewhen the query is still running rather than failing. Retry afterRetry-Afterseconds.
{
"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.
{
"error": "summary timed out for this period; try a shorter one"
}Example request
curl -X GET "https://api.nsin.ir/analytics/traffic-trend?domain=example.com" \
-H "Authorization: Bearer $NSIN_API_KEY"