Get the domain's traffic usage
const url = 'https://api.nsin.ir/domains/example.com/traffic-usage?view=summary&hostnames=0&daily=1';const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url 'https://api.nsin.ir/domains/example.com/traffic-usage?view=summary&hostnames=0&daily=1' \ --header 'Authorization: Bearer <token>'The domain’s recent daily traffic rows (up to 90) and current prices,
and — while it has an active or grace subscription — its traffic
allowance (traffic_limit_gb), the current allowance window, the
traffic used and charged in that window, and the window’s split by
hostname. All-time totals are included too. Same three-tier model as
the account-wide endpoint. Readable by every member of the domain.
The hostname split is the one expensive part: hostnames=0 leaves it
out, and view=summary also skips every allowance-window figure.
Figures that could not be read are left out rather than sent as zero.
daily=1 adds quota_daily: the allowance window day by day, the
running total against the allowance, and when it ran out or will at
the current rate.
Authorizations
Section titled “Authorizations ”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters ”The domain name (for example example.com) — not a numeric id.
Example
example.comQuery Parameters
Section titled “Query Parameters ”summary returns only the daily rows, prices, the allowance, the window bounds and the all-time totals.
0 leaves out traffic_by_hostname.
1 adds quota_daily. Combines with hostnames=0; with view=summary it is always null.
Responses
Section titled “ Responses ”Usage rows, window figures and prices.
One domain’s traffic usage, as GET /domains/{domain}/traffic-usage returns it.
object
The newest daily rows, up to 90, newest first.
One day’s traffic for one domain.
object
The day the row belongs to.
Identifies the billing window the row was billed in.
Bytes served from cache.
Bytes fetched through the edge proxy.
Bytes on the direct path.
Legacy two-tier column, present on historical rows. Folded into the direct total for display.
What this row cost, in rials — the sum of the three charged_*_rials.
Start of the billing window the row covers.
End of that window (exclusive).
The portion above the plan’s free allowance.
The portion above the plan’s free allowance.
The portion above the plan’s free allowance.
Cost of the cached tier’s billed bytes.
Cost of the proxied tier’s billed bytes.
Cost of the direct tier’s billed bytes.
The period invoice that itemized this row, once issued.
When the row was billed.
Rials per GB of cache-served traffic.
Rials per GB of proxied traffic.
Rials per GB of direct traffic.
Legacy two-tier price, for historical rows.
The traffic allowance the subscription is billed against, in GB, with any override applied. Absent when unlimited or without a subscription.
Start of the current allowance window. Present while the domain has an active or grace subscription.
End of the current allowance window.
Bytes metered in the current window (billed ledger plus the not-yet-billed tail).
The window’s cache-served bytes.
The window’s proxied bytes.
The window’s direct bytes.
What the current window has cost so far: the rials actually debited for billed windows, plus the not-yet-billed tail priced against the allowance that remains.
The window’s traffic split by hostname. Left out with hostnames=0 or view=summary.
object
Total bytes attributed across traffic_by_hostname.
Cache-served bytes over the domain’s whole history.
Proxied bytes over the domain’s whole history.
Direct bytes over the domain’s whole history.
The three all-time figures summed.
The current allowance window day by day. days are the billed ledger
rows grouped by UTC day, then one not-yet-billed tail up to now, so
their cumulative_bytes ends at used_bytes, which always equals
quota_period_used_bytes. All sizes are bytes; the allowance is
max_traffic_gb × 1024³.
object
The allowance in bytes, with any override applied. Null when unlimited.
Same as quota_period_used_bytes.
object
The first day may start at period_start
The tail ends now.
False only for the not-yet-billed tail.
Average of the last (up to) seven whole billed days of the window. 0 when there are none.
When the running total reached the allowance, placed within the crossing day along its hourly traffic. Null if it has not.
At the 7-day average, when the allowance will run out. Null once it has run out, when unlimited, or when that is after period_end.
Example generated
{ "domain": "example", "usage": [ { "id": 1, "domain_id": 1, "user_id": 1, "date": "2026-04-15", "billing_window_key": "example", "cached_bytes": 1, "proxied_bytes": 1, "direct_bytes": 1, "bypass_bytes": 1, "charged_rials": 1, "window_start": "2026-04-15T12:00:00Z", "window_end": "2026-04-15T12:00:00Z", "billed_cached_bytes": 1, "billed_proxied_bytes": 1, "billed_direct_bytes": 1, "charged_cached_rials": 1, "charged_proxied_rials": 1, "charged_direct_rials": 1, "invoice_id": 1, "processed_at": "2026-04-15T12:00:00Z", "created_at": "2026-04-15T12:00:00Z" } ], "cached_price_per_gb": 1, "proxied_price_per_gb": 1, "direct_price_per_gb": 1, "bypass_price_per_gb": 1, "traffic_limit_gb": 1, "quota_period_start": "2026-04-15T12:00:00Z", "quota_period_end": "2026-04-15T12:00:00Z", "quota_period_used_bytes": 1, "cached_bytes": 1, "proxied_bytes": 1, "direct_bytes": 1, "quota_period_charged_rials": 1, "traffic_by_hostname": [ { "hostname": "example", "cached_bytes": 1, "proxied_bytes": 1, "direct_bytes": 1 } ], "traffic_by_hostname_bytes": 1, "all_time_cached_bytes": 1, "all_time_proxied_bytes": 1, "all_time_direct_bytes": 1, "all_time_total_bytes": 1, "quota_daily": { "period_start": "2026-04-15T12:00:00Z", "period_end": "2026-04-15T12:00:00Z", "limit_bytes": 1, "used_bytes": 1, "days": [ { "window_start": "2026-04-15T12:00:00Z", "window_end": "2026-04-15T12:00:00Z", "bytes": 1, "cumulative_bytes": 1, "billed": true } ], "avg_daily_bytes_7d": 1, "ran_out_at": "2026-04-15T12:00:00Z", "projected_run_out_at": "2026-04-15T12:00:00Z" }}Missing domain.
The single error shape used by every endpoint.
object
Human-readable description of what went wrong.
Example
{ "error": "read-only API key"}Missing, malformed, revoked or expired API key. (A valid key whose
account has been deactivated gets 403 account is inactive instead.)
The single error shape used by every endpoint.
object
Human-readable description of what went wrong.
Examples
{ "error": "invalid API key"}No such domain, or it is not visible to this account. Domains you cannot access are reported as not found rather than forbidden.
The single error shape used by every endpoint.
object
Human-readable description of what went wrong.
Example
{ "error": "read-only API key"}The key exceeded its request budget (300 requests per minute by default).
The single error shape used by every endpoint.
object
Human-readable description of what went wrong.
Examples
{ "error": "rate limit exceeded"}