> ## 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 unique viewers via CDN

> Сounts the number of unique viewers of a video entity over CDN. It doesn't matter what player you used.

All unique viewers for the specified period of time are counted.


**How does it work?**

Calculating the number of unique viewers for a Live stream or VOD over CDN involves aggregating and analyzing various metrics to ensure each individual viewer is counted only once, regardless of how many times they connect or disconnect during the stream.

This method provides statistics for any video viewing by unique users, regardless of viewing method and a player you used. Thus, this is the most important difference from viewing through the built-in player:
- In method /statistics/uniqs viewers of the built-in player are tracked only.
- But this method tracks all viewers from everywhere.


This method is a combination of two other Live and VOD detailed methods. If you need detailed information, then see the methods: ```/statistics/stream/viewers``` and ```/statistics/vod/viewers```.


**Data Processing and Deduplication**

We us IP Address & User-Agent combination. Each unique combination of IP address and User-Agent string might be considered a unique viewer. 

This approach allows to accurately estimate the number of unique viewers. However, this is not foolproof due to NAT (Network Address Translation) and shared networks. Thus if your users fall under such restrictions, then the number of unique viewers may be higher than calculated.


**Why is there no "Unique Views" method?**

Based on CDN data, we can calculate the number of unique viewers only. Thus only your player will be able to count the number of unique views (clicks on the Play button) within the player session (i.e. how many times 1 unique viewer clicked the Play button within a unique player's session).



## OpenAPI

````yaml /api-reference/services_documented/streaming_api.yaml get /streaming/statistics/cdn/uniqs
openapi: 3.1.0
info:
  title: Gcore OpenAPI – Streaming 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: AI
    x-displayName: AI
  - name: Broadcasts
    x-displayName: Broadcasts
  - name: Directories
    x-displayName: Directories
  - name: Overlays
    x-displayName: Overlays
  - name: Players
    x-displayName: Players
  - name: Playlists
    x-displayName: Playlists
  - name: QualitySets
    x-displayName: QualitySets
  - name: Restreams
    x-displayName: Restreams
  - name: Streaming Statistics
    x-displayName: Statistics
  - name: Streams
    x-displayName: Streams
  - name: Subtitles
    x-displayName: Subtitles
  - name: Videos
    x-displayName: Videos
paths:
  /streaming/statistics/cdn/uniqs:
    get:
      tags:
        - Streaming Statistics
      summary: Get unique viewers via CDN
      description: >-
        Сounts the number of unique viewers of a video entity over CDN. It
        doesn't matter what player you used.


        All unique viewers for the specified period of time are counted.



        **How does it work?**


        Calculating the number of unique viewers for a Live stream or VOD over
        CDN involves aggregating and analyzing various metrics to ensure each
        individual viewer is counted only once, regardless of how many times
        they connect or disconnect during the stream.


        This method provides statistics for any video viewing by unique users,
        regardless of viewing method and a player you used. Thus, this is the
        most important difference from viewing through the built-in player:

        - In method /statistics/uniqs viewers of the built-in player are tracked
        only.

        - But this method tracks all viewers from everywhere.



        This method is a combination of two other Live and VOD detailed methods.
        If you need detailed information, then see the methods:
        ```/statistics/stream/viewers``` and ```/statistics/vod/viewers```.



        **Data Processing and Deduplication**


        We us IP Address & User-Agent combination. Each unique combination of IP
        address and User-Agent string might be considered a unique viewer. 


        This approach allows to accurately estimate the number of unique
        viewers. However, this is not foolproof due to NAT (Network Address
        Translation) and shared networks. Thus if your users fall under such
        restrictions, then the number of unique viewers may be higher than
        calculated.



        **Why is there no "Unique Views" method?**


        Based on CDN data, we can calculate the number of unique viewers only.
        Thus only your player will be able to count the number of unique views
        (clicks on the Play button) within the player session (i.e. how many
        times 1 unique viewer clicked the Play button within a unique player's
        session).
      operationId: getCDNUniqs
      parameters:
        - name: date_from
          in: query
          required: true
          description: Start of time frame. Format is date time in ISO 8601.
          example: '2024-07-01T00:00:00Z'
          schema:
            type: string
        - name: date_to
          in: query
          required: true
          description: End of time frame. Format is date time in ISO 8601.
          example: '2024-07-31T23:59:59Z'
          schema:
            type: string
        - name: type
          in: query
          required: false
          description: Filter by entity's type
          example: live
          schema:
            type: string
            enum:
              - live
              - vod
              - playlist
        - name: id
          in: query
          required: false
          description: >-
            Filter by entity's id. Put ID of a Live stream, VOD or a playlist to
            be calculated. 


            If the value is omitted, then the calculation is done for all
            videos/streams of the specified type.


            When using this "id" parameter, be sure to specify the "type"
            parameter too. If you do not specify a type, the "id" will be
            ignored.
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/cdn_uniqs'
        '400':
          $ref: '#/components/responses/error_bad_request'
        '500':
          $ref: '#/components/responses/error_internal_server'
      x-codeSamples:
        - lang: Python
          source: >-
            import os

            from gcore import Gcore


            client = Gcore(
                api_key=os.environ.get("GCORE_API_KEY"),  # This is the default and can be omitted
            )

            unique_viewers_cdn =
            client.streaming.statistics.get_unique_viewers_cdn(
                date_from="date_from",
                date_to="date_to",
            )

            print(unique_viewers_cdn.data)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\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/streaming\"\n)\n\nfunc main() {\n\tclient := gcore.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\tuniqueViewersCDN, err := client.Streaming.Statistics.GetUniqueViewersCDN(context.TODO(), streaming.StatisticGetUniqueViewersCDNParams{\n\t\tDateFrom: \"date_from\",\n\t\tDateTo:   \"date_to\",\n\t})\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", uniqueViewersCDN.Data)\n}\n"
components:
  schemas:
    cdn_uniqs:
      type: object
      properties:
        data:
          type: array
          items:
            type: object
            required:
              - uniqs
              - type
            properties:
              uniqs:
                type: integer
              type:
                type: string
      example:
        data:
          - uniqs: 100
            type: vod
          - uniqs: 300
            type: live
    error_common:
      required:
        - data
        - errors
      type: object
      properties:
        data:
          type: array
          items:
            type: string
        errors:
          type: array
          items:
            type: string
  responses:
    error_bad_request:
      description: Bad Request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/error_common'
          examples:
            missingParam:
              summary: Missing query param
              value:
                data: []
                errors:
                  - 'from: query param is not set'
    error_internal_server:
      description: Internal Server Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/error_common'
          examples:
            internalServerError:
              summary: Internal Server Error
              value:
                data: []
                errors:
                  - internal server error
  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

````