Python
import os
from datetime import datetime
from gcore import Gcore
client = Gcore(
api_key=os.environ.get("GCORE_API_KEY"), # This is the default and can be omitted
)
waap_statistics_series = client.waap.statistics.get_usage_series(
from_=datetime.fromisoformat("2024-12-14T12:00:00"),
granularity="1h",
metrics=["total_bytes"],
to=datetime.fromisoformat("2024-12-14T12:00:00"),
)
print(waap_statistics_series.total_bytes)package main
import (
"context"
"fmt"
"time"
"github.com/G-Core/gcore-go"
"github.com/G-Core/gcore-go/option"
"github.com/G-Core/gcore-go/waap"
)
func main() {
client := gcore.NewClient(
option.WithAPIKey("My API Key"),
)
waapStatisticsSeries, err := client.Waap.Statistics.GetUsageSeries(context.TODO(), waap.StatisticGetUsageSeriesParams{
From: time.Now(),
Granularity: waap.StatisticGetUsageSeriesParamsGranularity1h,
Metrics: []string{"total_bytes"},
To: time.Now(),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", waapStatisticsSeries.TotalBytes)
}
curl --request GET \
--url https://api.gcore.com/waap/v1/statistics/series \
--header 'Authorization: <api-key>'const options = {method: 'GET', headers: {Authorization: '<api-key>'}};
fetch('https://api.gcore.com/waap/v1/statistics/series', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gcore.com/waap/v1/statistics/series",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.get("https://api.gcore.com/waap/v1/statistics/series")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/waap/v1/statistics/series")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"total_bytes": [
{
"date_time": "2023-11-07T05:31:56Z",
"value": 123
}
],
"total_requests": [
{
"date_time": "2023-11-07T05:31:56Z",
"value": 123
}
]
}{
"type": "http-bad-request",
"title": "Bad Request",
"status": 400,
"detail": "Invalid domain name: ''''"
}{
"detail": "Auth token is missing or invalid"
}{
"detail": "Permission denied"
}{
"type": "http-not-found",
"title": "Not Found",
"status": 404,
"detail": "The resource is not found"
}{
"type": "request-validation-failed",
"title": "Request validation error.",
"status": 422,
"detail": "One or more fields have validation errors.",
"errors": [
{
"loc": [
"body",
"name"
],
"detail": "Input should be a valid string"
},
{
"loc": [
"body",
"date"
],
"detail": "Field required"
},
{
"loc": [
"query",
"limit"
],
"detail": "Field required"
}
]
}{
"type": "internal-server-error",
"title": "Internal server error.",
"status": 500,
"detail": "An unexpected condition was encountered which prevented the server from fulfilling the request."
}WAAP Service
Get statistics as time series
Retrieve statistics data as a time series. The from and to parameters are rounded down and up according to the granularity. This means that if the granularity is set to 1h, the from and to parameters will be rounded down and up to the nearest hour, respectively. If the granularity is set to 1d, the from and to parameters will be rounded down and up to the nearest day, respectively. The response will include explicit 0 values for any missing data points.
GET
/
waap
/
v1
/
statistics
/
series
Python
import os
from datetime import datetime
from gcore import Gcore
client = Gcore(
api_key=os.environ.get("GCORE_API_KEY"), # This is the default and can be omitted
)
waap_statistics_series = client.waap.statistics.get_usage_series(
from_=datetime.fromisoformat("2024-12-14T12:00:00"),
granularity="1h",
metrics=["total_bytes"],
to=datetime.fromisoformat("2024-12-14T12:00:00"),
)
print(waap_statistics_series.total_bytes)package main
import (
"context"
"fmt"
"time"
"github.com/G-Core/gcore-go"
"github.com/G-Core/gcore-go/option"
"github.com/G-Core/gcore-go/waap"
)
func main() {
client := gcore.NewClient(
option.WithAPIKey("My API Key"),
)
waapStatisticsSeries, err := client.Waap.Statistics.GetUsageSeries(context.TODO(), waap.StatisticGetUsageSeriesParams{
From: time.Now(),
Granularity: waap.StatisticGetUsageSeriesParamsGranularity1h,
Metrics: []string{"total_bytes"},
To: time.Now(),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", waapStatisticsSeries.TotalBytes)
}
curl --request GET \
--url https://api.gcore.com/waap/v1/statistics/series \
--header 'Authorization: <api-key>'const options = {method: 'GET', headers: {Authorization: '<api-key>'}};
fetch('https://api.gcore.com/waap/v1/statistics/series', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gcore.com/waap/v1/statistics/series",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.get("https://api.gcore.com/waap/v1/statistics/series")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/waap/v1/statistics/series")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"total_bytes": [
{
"date_time": "2023-11-07T05:31:56Z",
"value": 123
}
],
"total_requests": [
{
"date_time": "2023-11-07T05:31:56Z",
"value": 123
}
]
}{
"type": "http-bad-request",
"title": "Bad Request",
"status": 400,
"detail": "Invalid domain name: ''''"
}{
"detail": "Auth token is missing or invalid"
}{
"detail": "Permission denied"
}{
"type": "http-not-found",
"title": "Not Found",
"status": 404,
"detail": "The resource is not found"
}{
"type": "request-validation-failed",
"title": "Request validation error.",
"status": 422,
"detail": "One or more fields have validation errors.",
"errors": [
{
"loc": [
"body",
"name"
],
"detail": "Input should be a valid string"
},
{
"loc": [
"body",
"date"
],
"detail": "Field required"
},
{
"loc": [
"query",
"limit"
],
"detail": "Field required"
}
]
}{
"type": "internal-server-error",
"title": "Internal server error.",
"status": 500,
"detail": "An unexpected condition was encountered which prevented the server from fulfilling the request."
}Authorizations
Query Parameters
Response
Successful Response
Response model for the statistics series
Was this page helpful?