Skip to content
nsin docs

Get the domain's traffic usage

GET
/domains/{domain}/traffic-usage
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.

domain
required
string

The domain name (for example example.com) — not a numeric id.

Example
example.com
view
string
Allowed values: summary

summary returns only the daily rows, prices, the allowance, the window bounds and the all-time totals.

hostnames
string
Allowed values: 0

0 leaves out traffic_by_hostname.

daily
string
Allowed values: 1

1 adds quota_daily. Combines with hostnames=0; with view=summary it is always null.

Usage rows, window figures and prices.

Media type application/json

One domain’s traffic usage, as GET /domains/{domain}/traffic-usage returns it.

object
domain
string
usage

The newest daily rows, up to 90, newest first.

Array<object>

One day’s traffic for one domain.

object
id
integer
domain_id
integer
user_id
integer
date

The day the row belongs to.

string format: date
billing_window_key

Identifies the billing window the row was billed in.

string
cached_bytes

Bytes served from cache.

integer
proxied_bytes

Bytes fetched through the edge proxy.

integer
direct_bytes

Bytes on the direct path.

integer
bypass_bytes

Legacy two-tier column, present on historical rows. Folded into the direct total for display.

integer
charged_rials

What this row cost, in rials — the sum of the three charged_*_rials.

integer
window_start

Start of the billing window the row covers.

string format: date-time
window_end

End of that window (exclusive).

string format: date-time
billed_cached_bytes

The portion above the plan’s free allowance.

integer
billed_proxied_bytes

The portion above the plan’s free allowance.

integer
billed_direct_bytes

The portion above the plan’s free allowance.

integer
charged_cached_rials

Cost of the cached tier’s billed bytes.

integer
charged_proxied_rials

Cost of the proxied tier’s billed bytes.

integer
charged_direct_rials

Cost of the direct tier’s billed bytes.

integer
invoice_id

The period invoice that itemized this row, once issued.

integer
processed_at

When the row was billed.

string format: date-time
created_at
string format: date-time
cached_price_per_gb

Rials per GB of cache-served traffic.

integer
proxied_price_per_gb

Rials per GB of proxied traffic.

integer
direct_price_per_gb

Rials per GB of direct traffic.

integer
bypass_price_per_gb

Legacy two-tier price, for historical rows.

integer
traffic_limit_gb

The traffic allowance the subscription is billed against, in GB, with any override applied. Absent when unlimited or without a subscription.

integer
quota_period_start

Start of the current allowance window. Present while the domain has an active or grace subscription.

string format: date-time
quota_period_end

End of the current allowance window.

string format: date-time
quota_period_used_bytes

Bytes metered in the current window (billed ledger plus the not-yet-billed tail).

integer
cached_bytes

The window’s cache-served bytes.

integer
proxied_bytes

The window’s proxied bytes.

integer
direct_bytes

The window’s direct bytes.

integer
quota_period_charged_rials

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.

integer
traffic_by_hostname

The window’s traffic split by hostname. Left out with hostnames=0 or view=summary.

Array<object>
object
hostname
string
cached_bytes
integer
proxied_bytes
integer
direct_bytes
integer
traffic_by_hostname_bytes

Total bytes attributed across traffic_by_hostname.

integer
all_time_cached_bytes

Cache-served bytes over the domain’s whole history.

integer
all_time_proxied_bytes

Proxied bytes over the domain’s whole history.

integer
all_time_direct_bytes

Direct bytes over the domain’s whole history.

integer
all_time_total_bytes

The three all-time figures summed.

integer
quota_daily
One of:
null
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.

Media type application/json

The single error shape used by every endpoint.

object
error
required

Human-readable description of what went wrong.

string
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.)

Media type application/json

The single error shape used by every endpoint.

object
error
required

Human-readable description of what went wrong.

string
Examples
Example invalidKey
{
"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.

Media type application/json

The single error shape used by every endpoint.

object
error
required

Human-readable description of what went wrong.

string
Example
{
"error": "read-only API key"
}

The key exceeded its request budget (300 requests per minute by default).

Media type application/json

The single error shape used by every endpoint.

object
error
required

Human-readable description of what went wrong.

string
Examples
Example limited
{
"error": "rate limit exceeded"
}