Skip to content

Get transfer stats

By , Head of IntegrationsUpdated

Open this page in a new chat

Short answer

This page has 2 commands: Get transfer stats (GET /v2/stats/http) and Get transfer stats (GET /v2/stats/http/agg/traffic). The request returns aggregated HTTP log data. Each call needs a bearer token and counts towards your hourly API limit. Below are the parameters, sample code in 9 languages and a sample answer.

After reading this you will know

  • How to get transfer stats
  • Which parameters each of the 2 commands takes
  • Sample code in 9 languages and a sample answer

Every command on this page needs a bearer token and counts towards your hourly limit.

GEThttps://api.sirv.com/v2/stats/http

Use this API method to check how much data was transferred per day during a certain period (date from/to).

The request returns aggregated HTTP log data.

Query parameters

NameTypeRequiredExampleDescription
fromdate-timeNo2020-07-01T00:00:00.000Default: 1 month ago, rounded to start of day
todate-timeNo2020-07-05T00:00:00.000Default: now, rounded to end of day

Example request

// Your bearer token, from POST /v2/token, in the SIRV_TOKEN environment variable
const res = await fetch('https://api.sirv.com/v2/stats/http?from=2020-07-01T00%3A00%3A00.000&to=2020-07-05T00%3A00%3A00.000', {
method: 'GET',
headers: { authorization: `Bearer ${process.env.SIRV_TOKEN}` },
});
console.log(res.status, await res.text());

Example response

{
"1593561600000": {
"total": {
"count": 47619,
"size": 1440222650
}
},
"1593648000000": {
"total": {
"count": 75944,
"size": 2078130246
}
}
}
GEThttps://api.sirv.com/v2/stats/http/agg/traffic

Use this API method to check how much data was transferred per day during a certain period (date from/to).

The request returns aggregated HTTP log data.

Query parameters

NameTypeRequiredExampleDescription
fromdate-timeNo2020-07-01T00:00:00.000Default: 1 month ago, rounded to start of day
todate-timeNo2020-07-31T00:00:00.000Default: now, rounded to end of day

Example request

// Your bearer token, from POST /v2/token, in the SIRV_TOKEN environment variable
const res = await fetch('https://api.sirv.com/v2/stats/http/agg/traffic', {
method: 'GET',
headers: { authorization: `Bearer ${process.env.SIRV_TOKEN}` },
});
console.log(res.status, await res.text());

Response

HTTP 200 with the answer as JSON.

Back to top