Traffic statistics

Returns traffic usage data for the selected period. Both traffic statistics per CDN zone and per hostname are available.

Endpoint

https://www.pushrcdn.com/api/v3/zones/traffic

Methods

POST

Parameters

ParameterTypeValuesDescription
zone_idinteger CDN zone of interest
hostnamestring, optional Hostname of interest
periodinteger1 - 4Timeframe of the report

Note:  When quering the API for the entire CDN zone, the hostname parameter should be omitted. However, when the query is for a specific hostname, both zone_id and hostname parameters need to be provided.

Reporting period

The period parameter can contain values from 1 to 4. They correspond to the following time intervals for the returned data:

ValuePeriodDescription
1Last 24 hoursRolling last 24 hour data
2Last 30 daysRolling last 30 days data
3Last 12 monthsRolling last 12 months data
4From start of monthData for the current accunting period

Headers

FieldTypeDescription
APIKEYstringYour account API key

Example - Get traffic for an entire CDN zone 

Get aggregate data for an entire CDN zone with ID 127642 for the current accounting period (start of month to now):

curl -d "zone_id=127642" \
-d "period=4" \
-H "Accept: application/json" \
-H "APIKEY: c45ed960ac1c3d12c1d570a869df8c9c473055stgr" \
-X POST "https://www.pushrcdn.com/api/v3/zones/traffic"

Response

The traffic JSON object is returned. It cointains 3 keys:

{
   "traffic":[
      {
         "zone_used_traffic_total":"122383093215",
         "zone_used_traffic_extended_network":"1012899694",
         "zone_cache_hit_ratio":"94.4167"
      }
   ]
}

• zone_used_traffic_total is the total amount of outbound CDN traffic in bytes. 

• zone_used_traffic_extended_network is the amount of traffic used on the extended network tier in bytes.

• zone_cache_hit_ratio is the average cache hit ratio in percents.

Important: Note that the value of the zone_used_traffic_total key includes both the traffic on the balanced network tier + the extended network tier. To calculate the traffic used on the balanced network tier, you need to subtract value of zone_used_traffic_extended_network from zone_used_traffic_total.

Example - Get traffic for specific hostname

Getting traffic data per hostname works the same way as for an entire CDN zone. Just add the hostname to the request. Remember that the zone_id parameter still needs to be provided:

curl -d "zone_id=127642" \
-d "hostname=cdn.mywebsite.com" \
-d "period=4" \
-H "Accept: application/json" \
-H "APIKEY: c45ed960ac1c3d12c1d570a869df8c9c473055stgr" \
-X POST "https://www.pushrcdn.com/api/v3/zones/traffic"

Response 

{
   "traffic":[
      {
         "hostname_used_traffic_total":"122383093215",
         "hostname_used_traffic_extended_network":"1012899694",
         "hostname_cache_hit_ratio":"94.4167"
      }
   ]
}