Get the domain's traffic usage
Auth: Authorization: Bearer nsin_… or X-Api-Key: nsin_… — see API keys.
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.
Path parameters
- domainstringrequiredpath
The domain name (for example
example.com) — not a numeric id.
Query parameters
- viewstringquery
summaryreturns only the daily rows, prices, the allowance, the window bounds and the all-time totals.One of:"summary" - hostnamesstringquery
0leaves outtraffic_by_hostname.One of:"0" - dailystringquery
1addsquota_daily. Combines withhostnames=0; withview=summaryit is always null.One of:"1"
Responses
200Usage rows, window figures and prices.
Content type: application/json
- domainstring
- usagearray of DomainTrafficUsageRow
The newest daily rows, up to 90, newest first.
Item fields
- idinteger
- domain_idinteger
- user_idinteger
- datestring (date)
The day the row belongs to.
- billing_window_keystring
Identifies the billing window the row was billed in.
- cached_bytesinteger
Bytes served from cache.
- proxied_bytesinteger
Bytes fetched through the edge proxy.
- direct_bytesinteger
Bytes on the direct path.
- bypass_bytesinteger
Legacy two-tier column, present on historical rows. Folded into the direct total for display.
- charged_rialsinteger
What this row cost, in rials — the sum of the three
charged_*_rials. - window_startstring (date-time)
Start of the billing window the row covers.
- window_endstring (date-time)
End of that window (exclusive).
- billed_cached_bytesinteger
The portion above the plan's free allowance.
- billed_proxied_bytesinteger
The portion above the plan's free allowance.
- billed_direct_bytesinteger
The portion above the plan's free allowance.
- charged_cached_rialsinteger
Cost of the cached tier's billed bytes.
- charged_proxied_rialsinteger
Cost of the proxied tier's billed bytes.
- charged_direct_rialsinteger
Cost of the direct tier's billed bytes.
- invoice_idinteger
The period invoice that itemized this row, once issued.
- processed_atstring (date-time)
When the row was billed.
- created_atstring (date-time)
- cached_price_per_gbinteger
Rials per GB of cache-served traffic.
- proxied_price_per_gbinteger
Rials per GB of proxied traffic.
- direct_price_per_gbinteger
Rials per GB of direct traffic.
- bypass_price_per_gbinteger
Legacy two-tier price, for historical rows.
- traffic_limit_gbinteger
The traffic allowance the subscription is billed against, in GB, with any override applied. Absent when unlimited or without a subscription.
- quota_period_startstring (date-time)
Start of the current allowance window. Present while the domain has an active or grace subscription.
- quota_period_endstring (date-time)
End of the current allowance window.
- quota_period_used_bytesinteger
Bytes metered in the current window (billed ledger plus the not-yet-billed tail).
- cached_bytesinteger
The window's cache-served bytes.
- proxied_bytesinteger
The window's proxied bytes.
- direct_bytesinteger
The window's direct bytes.
- quota_period_charged_rialsinteger
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.
- traffic_by_hostnamearray of object
The window's traffic split by hostname. Left out with
hostnames=0orview=summary.Item fields
- hostnamestring
- cached_bytesinteger
- proxied_bytesinteger
- direct_bytesinteger
- traffic_by_hostname_bytesinteger
Total bytes attributed across
traffic_by_hostname. - all_time_cached_bytesinteger
Cache-served bytes over the domain's whole history.
- all_time_proxied_bytesinteger
Proxied bytes over the domain's whole history.
- all_time_direct_bytesinteger
Direct bytes over the domain's whole history.
- all_time_total_bytesinteger
The three all-time figures summed.
- quota_dailynull | DomainQuotaDaily
Only with
daily=1. Null without an active or grace subscription, or when the window's usage could not be read.Fields
- Option 1null
- Option 2DomainQuotaDaily
The current allowance window day by day.
daysare the billed ledger rows grouped by UTC day, then one not-yet-billed tail up to now, so theircumulative_bytesends atused_bytes, which always equalsquota_period_used_bytes. All sizes are bytes; the allowance ismax_traffic_gb× 1024³.Fields
- period_startstring (date-time)
- period_endstring (date-time)
- limit_bytesinteger | null
The allowance in bytes, with any override applied. Null when unlimited.
- used_bytesinteger
Same as
quota_period_used_bytes. - daysarray of object
Item fields
- window_startstring (date-time)
The first day may start at
period_start - window_endstring (date-time)
The tail ends now.
- bytesinteger
- cumulative_bytesinteger
- billedboolean
False only for the not-yet-billed tail.
- avg_daily_bytes_7dinteger
Average of the last (up to) seven whole billed days of the window. 0 when there are none.
- ran_out_atstring | null (date-time)
When the running total reached the allowance, placed within the crossing day along its hourly traffic. Null if it has not.
- projected_run_out_atstring | null (date-time)
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.
{
"domain": "string",
"usage": [
{
"id": 0,
"domain_id": 0,
"user_id": 0,
"date": "string",
"billing_window_key": "string",
"cached_bytes": 0,
"proxied_bytes": 0,
"direct_bytes": 0,
"bypass_bytes": 0,
"charged_rials": 0,
"window_start": "2026-01-01T00:00:00Z",
"window_end": "2026-01-01T00:00:00Z",
"billed_cached_bytes": 0,
"billed_proxied_bytes": 0,
"billed_direct_bytes": 0,
"charged_cached_rials": 0,
"charged_proxied_rials": 0,
"charged_direct_rials": 0,
"invoice_id": 0,
"processed_at": "2026-01-01T00:00:00Z",
"created_at": "2026-01-01T00:00:00Z"
}
],
"cached_price_per_gb": 0,
"proxied_price_per_gb": 0,
"direct_price_per_gb": 0,
"bypass_price_per_gb": 0,
"traffic_limit_gb": 0,
"quota_period_start": "2026-01-01T00:00:00Z",
"quota_period_end": "2026-01-01T00:00:00Z",
"quota_period_used_bytes": 0,
"cached_bytes": 0,
"proxied_bytes": 0,
"direct_bytes": 0,
"quota_period_charged_rials": 0,
"traffic_by_hostname": [
{
"hostname": "string",
"cached_bytes": 0,
"proxied_bytes": 0,
"direct_bytes": 0
}
],
"traffic_by_hostname_bytes": 0,
"all_time_cached_bytes": 0,
"all_time_proxied_bytes": 0,
"all_time_direct_bytes": 0,
"all_time_total_bytes": 0,
"quota_daily": "string"
}400Missing domain.
Content type: application/json
- errorstringrequired
Human-readable description of what went wrong.
{
"error": "read-only API key"
}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"
}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"
}Example request
curl -X GET "https://api.nsin.ir/domains/example.com/traffic-usage" \
-H "Authorization: Bearer $NSIN_API_KEY"