> ## Documentation Index
> Fetch the complete documentation index at: https://gcore.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 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.



## OpenAPI

````yaml /api-reference/services_documented/waap_api.yaml get /waap/v1/statistics/series
openapi: 3.1.0
info:
  title: Gcore OpenAPI – WAAP API
  description: >-
    This OpenAPI is an aggregated OpenAPI specification that unifies all Gcore
    products into a single file. It covers Cloud, CDN, DNS, WAAP, DDoS
    Protection, Object Storage, Streaming, and FastEdge services.
  version: '2026-05-15T06:37:28.230198+00:00'
servers:
  - url: https://api.gcore.com
security:
  - APIKey: []
tags:
  - name: WAAP Service
    x-displayName: WAAP Service
  - name: Domains
    x-displayName: Domains
  - name: Policies
    x-displayName: Policies
  - name: Analytics
    x-displayName: Analytics
  - name: Custom Page Sets
    x-displayName: Custom Page Sets
  - name: Custom Rules
    x-displayName: Custom Rules
  - name: Filter Templates
    x-displayName: Filter Templates
  - name: Firewall Rules
    x-displayName: Firewall Rules
  - name: Advanced Rules
    x-displayName: Advanced Rules
  - name: Tags
    x-displayName: Tags
  - name: Network Organizations
    x-displayName: Network Organizations
  - name: API Discovery
    x-displayName: API Discovery
  - name: IP Spotlight
    x-displayName: IP Spotlight
  - name: Security Insights
    x-displayName: Security Insights
  - name: IP Reputation
    x-displayName: IP Reputation
paths:
  /waap/v1/statistics/series:
    get:
      tags:
        - WAAP Service
      summary: Get statistics as time series
      description: >-
        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.
      operationId: get_statistics_series_v1_statistics_series_get
      parameters:
        - name: from
          in: query
          required: true
          schema:
            type: string
            format: date-time
            description: Beginning of the requested time period (ISO 8601 format, UTC)
            example: '2024-12-14T12:00:00Z'
            examples:
              - '2024-12-14T12:00:00Z'
            title: From
          description: Beginning of the requested time period (ISO 8601 format, UTC)
        - name: to
          in: query
          required: true
          schema:
            type: string
            format: date-time
            description: End of the requested time period (ISO 8601 format, UTC)
            example: '2024-12-14T12:00:00Z'
            examples:
              - '2024-12-14T12:00:00Z'
            title: To
          description: End of the requested time period (ISO 8601 format, UTC)
        - name: granularity
          in: query
          required: true
          schema:
            enum:
              - 1h
              - 1d
            type: string
            description: Duration of the time blocks into which the data will be divided.
            title: Granularity
          description: Duration of the time blocks into which the data will be divided.
        - name: metrics
          in: query
          required: true
          schema:
            type: array
            items:
              enum:
                - total_bytes
                - total_requests
              type: string
            description: List of metric types to retrieve statistics for.
            title: Metrics
          description: List of metric types to retrieve statistics for.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StatisticsSeries'
        '400':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/APIError'
              example:
                type: http-bad-request
                title: Bad Request
                status: 400
                detail: 'Invalid domain name: '''''''''
          description: Bad Request
        '401':
          description: Unauthorized
          content:
            application/problem+json:
              example:
                detail: Auth token is missing or invalid
        '403':
          description: Unauthenticated
          content:
            application/problem+json:
              example:
                detail: Permission denied
        '404':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/APIError'
              example:
                type: http-not-found
                title: Not Found
                status: 404
                detail: The resource is not found
          description: Not Found
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/APICompositeError'
              example:
                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
          description: Unprocessable Entity
        '500':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/APIError'
              example:
                type: internal-server-error
                title: Internal server error.
                status: 500
                detail: >-
                  An unexpected condition was encountered which prevented the
                  server from fulfilling the request.
          description: Internal Server Error
      x-codeSamples:
        - lang: Python
          source: |-
            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)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/G-Core/gcore-go\"\n\t\"github.com/G-Core/gcore-go/option\"\n\t\"github.com/G-Core/gcore-go/waap\"\n)\n\nfunc main() {\n\tclient := gcore.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\twaapStatisticsSeries, err := client.Waap.Statistics.GetUsageSeries(context.TODO(), waap.StatisticGetUsageSeriesParams{\n\t\tFrom:        time.Now(),\n\t\tGranularity: waap.StatisticGetUsageSeriesParamsGranularity1h,\n\t\tMetrics:     []string{\"total_bytes\"},\n\t\tTo:          time.Now(),\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", waapStatisticsSeries.TotalBytes)\n}\n"
components:
  schemas:
    StatisticsSeries:
      properties:
        total_bytes:
          anyOf:
            - items:
                $ref: '#/components/schemas/StatisticItem'
              type: array
            - type: 'null'
          title: Total Bytes
          description: >-
            Will be returned if `total_bytes` is requested in the metrics
            parameter
        total_requests:
          anyOf:
            - items:
                $ref: '#/components/schemas/StatisticItem'
              type: array
            - type: 'null'
          title: Total Requests
          description: >-
            Will be included if `total_requests` is requested in the metrics
            parameter
      type: object
      title: StatisticsSeries
      description: Response model for the statistics series
    APIError:
      properties:
        type:
          type: string
          title: Type
          description: A URI identifier that categorizes the type of error.
        title:
          type: string
          title: Title
          description: A brief, human-readable title for the error.
        status:
          type: integer
          title: Status
          description: The HTTP status code applicable to this error.
        detail:
          anyOf:
            - type: string
            - type: 'null'
          title: Detail
          description: A detailed human-readable explanation of the error.
      type: object
      required:
        - type
        - title
        - status
        - detail
      title: APIError
    APICompositeError:
      properties:
        type:
          type: string
          title: Type
          description: A URI identifier that categorizes the type of error.
        title:
          type: string
          title: Title
          description: A brief, human-readable title for the error.
        status:
          type: integer
          title: Status
          description: The HTTP status code applicable to this error.
        detail:
          anyOf:
            - type: string
            - type: 'null'
          title: Detail
          description: A detailed human-readable explanation of the error.
        errors:
          items:
            $ref: '#/components/schemas/APIFieldError'
          type: array
          title: Errors
          description: A list of detailed errors for individual fields.
      type: object
      required:
        - type
        - title
        - status
        - detail
        - errors
      title: APICompositeError
    StatisticItem:
      properties:
        date_time:
          type: string
          format: date-time
          title: Date Time
          description: The date and time for the statistic in ISO 8601 format
        value:
          type: integer
          title: Value
          description: >-
            The value for the statistic. If there is no data for the given time,
            the value will be 0.
      type: object
      required:
        - date_time
        - value
      title: StatisticItem
      description: Response model for the statistics item
    APIFieldError:
      properties:
        loc:
          anyOf:
            - items:
                anyOf:
                  - type: integer
                  - type: string
              type: array
            - {}
          title: Loc
          description: The location of the field or a character number causing the error.
        detail:
          type: string
          title: Detail
          description: A human-readable message describing the error.
      type: object
      required:
        - loc
        - detail
      title: APIFieldError
  securitySchemes:
    APIKey:
      description: >-
        API key for authentication. Make sure to include the word `apikey`,
        followed by a single space and then your token.

        Example: `apikey 1234$abcdef`
      type: apiKey
      in: header
      name: Authorization

````