Skip to main content

Traffic Stats

Returns traffic volume statistics across multiple time periods, centered on a target timestamp.

Endpoint

POST /v2/reports/traffic-stats

Request Body

FieldTypeRequiredConstraintsDescription
targetTimedatetimeYesISO 8601 UTC formatThe reference point from which periods are calculated (typically now or a past timestamp)
numPeriodsintYesMust be a positive integerNumber of periods to return going back from targetTime
periodstringYesMust be a valid StatisticsPeriod valueThe granularity of each period (hour, day, week, or month)
{
"targetTime": "2026-05-07T00:00:00Z",
"numPeriods": 7,
"period": "Day"
}

Response

Returns an ordered array of traffic statistics records, one per period, from oldest to most recent.

{
"success": true,
"data": [
{
"periodStart": "2026-05-01T00:00:00Z",
"periodEnd": "2026-05-01T23:59:59Z",
"sentCount": 340,
"receivedCount": 280,
"totalBytes": 3145728
},
{
"periodStart": "2026-05-02T00:00:00Z",
"periodEnd": "2026-05-02T23:59:59Z",
"sentCount": 398,
"receivedCount": 315,
"totalBytes": 3670016
}
]
}

Response Fields

FieldTypeDescription
periodStartdatetimeUTC start of this traffic period
periodEnddatetimeUTC end of this traffic period
sentCountintNumber of items sent during this period
receivedCountintNumber of items received during this period
totalByteslongCombined byte volume for this period

ENUMs

StatisticsPeriod

See StatisticsPeriod in the Appendix for the full list of values.

ValueDescription
HourEach period spans one hour
DayEach period spans one day
WeekEach period spans one week
MonthEach period spans one calendar month

Code Examples

curl -X POST "https://rest.ecgrid.io/v2/reports/traffic-stats" \
-H "X-API-Key: $ECGRID_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "targetTime": "2026-05-07T00:00:00Z", "numPeriods": 7, "period": "Day" }'

See Also