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
Parameter | Type | Values | Description |
zone_id | integer | CDN zone of interest | |
hostname | string, optional | Hostname of interest | |
period | integer | 1 - 4 | Timeframe 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:
Value | Period | Description |
1 | Last 24 hours | Rolling last 24 hour data |
2 | Last 30 days | Rolling last 30 days data |
3 | Last 12 months | Rolling last 12 months data |
4 | From start of month | Data for the current accunting period |
Headers
Field | Type | Description |
APIKEY | string | Your 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"
}
]
}