Statistics
One call returns a zone's traffic as a series of days or hours, plus a breakdown of the period by country and by network. The figures are the ones behind the statistics page, in UTC, and they are read with a GET that takes its filters from a JSON body (curl and every HTTP library send one; a browser's fetch() cannot).
Read the statistics#
https://api.cachegenie.com/v1/cdn/{ZONE_ID}/statsFROM_TIMESTAMPIntegeroptionalthe start, Unix seconds. Rounded down to the day, or to the hour with hourly detail. The default is midnight UTC 28 days ago.TO_TIMESTAMPIntegeroptionalthe end, Unix seconds. The default is now.GRANULARITYStringoptionalday(the default) orhour. Hourly figures are kept for 90 days, so a range that starts before that is answered by day whatever was asked for, and theGRANULARITYin the response saysday.NODEStringoptionala location id, to count one location only: any id Locations returns, or one a past response listed underNODES.
curl -X GET https://api.cachegenie.com/v1/cdn/AB12CD34E/stats \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"FROM_TIMESTAMP": 1788652800, "GRANULARITY": "day"}'{
"CODE": 200,
"MESSAGE": "CDN Zone Statistics Returned.",
"DATA": {
"GRANULARITY": "day",
"NODE": "",
"NODES": [
{ "ID": "alpha1", "LOCATION": "Alpha City, XX" },
{ "ID": "beta1", "LOCATION": "Beta City, XX" }
],
"CDN_DAILY_STATS": [
{
"DAY_TIMESTAMP": 1788652800,
"REQUESTS": 184220,
"CACHE_HITS": 171905,
"CACHE_MISS": 12315,
"BANDWIDTH_BYTES": 812390411264,
"ORIGIN_BYTES": 54310789120,
"BLOCKED": 0
}
],
"CDN_COUNTRIES": [
{
"COUNTRY": "GB",
"REQUESTS": 120410,
"BANDWIDTH_BYTES": 530112233472,
"BLOCKED": 0
},
{
"COUNTRY": "IE",
"REQUESTS": 22815,
"BANDWIDTH_BYTES": 101922177792,
"BLOCKED": 0
}
],
"CDN_NETWORKS": [
{
"ASN": 5089,
"REQUESTS": 60122,
"BANDWIDTH_BYTES": 265056116736,
"BLOCKED": 0
},
{
"ASN": 0,
"REQUESTS": 4110,
"BANDWIDTH_BYTES": 18110000000,
"BLOCKED": 0
}
]
}
}The series#
GRANULARITYStringthe detail that applied,dayorhour.NODEStringthe location filter that applied, or empty when none did.NODESArraythe locations that served the zone in the period, asIDandLOCATION. Not narrowed by NODE. AnIDofunassignedis traffic recorded before its server was placed in a location, and cannot be filtered on.CDN_DAILY_STATSArrayone row per day, or per hour with hourly detail, oldest first, for the buckets that had traffic.DAY_TIMESTAMPis the start of the day or hour;REQUESTSisCACHE_HITSplusCACHE_MISS;BANDWIDTH_BYTESis bytes sent to viewers;ORIGIN_BYTESis bytes fetched from your origin;BLOCKEDis requests your blocking rules refused, which are not in REQUESTS.
What each figure counts, what is deliberately not counted, and the units are in Statistics. A GRANULARITY other than the two answers 400 GRANULARITY must be "day" or "hour".; an unknown NODE answers 400 NODE is not a known CDN location; see NODES in the response of a request without it. A body that is not JSON is ignored and the defaults apply.
Countries and networks#
CDN_COUNTRIESArraythe period broken down byCOUNTRY, a two-letter code, empty when the address could not be placed; up to 250 rows, busiest first.CDN_NETWORKSArraythe period broken down byASN, the AS number as an integer, 0 for addresses no network announces and for the long tail of small networks; up to 50 rows, busiest first. The statistics page lists only the AS numbers the zone blocks, so this breakdown is the API's alone.
Each row carries REQUESTS, BANDWIDTH_BYTES and BLOCKED. Both breakdowns are counted per whole UTC day whatever GRANULARITY says, so they can reach a little either side of an hourly period.