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

# Query public total views metrics

> Allows querying for the public metrics for viewership about a video.
This can be called from the frontend with a CORS key, or even
unauthenticated.




## OpenAPI

````yaml GET /data/views/query/total/{playbackId}
openapi: 3.1.0
info:
  title: Livepeer API Reference
  description: |
    Welcome to the Livepeer API reference docs. Here you will find all the
    endpoints exposed on the standard Livepeer API, learn how to use them and
    what they return.
  version: 1.0.0
servers:
  - url: https://livepeer.studio/api
security:
  - apiKey: []
tags:
  - name: stream
    description: Operations related to livestream api
  - name: asset
    description: Operations related to asset/vod api
  - name: webhook
    description: Operations related to webhook api
  - name: multistream
    description: Operations related to multistream api
  - name: session
    description: Operations related to session api
  - name: room
    description: Operations related to rooms api
  - name: transcode
    description: Operations related to transcode api
  - name: metrics
    description: Operations related to metrics api
  - name: playback
    description: Operations related to playback api
  - name: accessControl
    description: Operations related to access control/signing keys api
  - name: task
    description: Operations related to tasks api
  - name: generate
    description: Operations related to AI generate api
paths:
  /data/views/query/total/{playbackId}:
    get:
      tags:
        - metrics
      summary: Query public total views metrics
      description: |
        Allows querying for the public metrics for viewership about a video.
        This can be called from the frontend with a CORS key, or even
        unauthenticated.
      operationId: getPublicViewershipMetrics
      parameters:
        - name: playbackId
          in: path
          required: true
          description: |
            The playback ID to filter the query results. This can be a canonical
            playback ID from Livepeer assets or streams, or dStorage identifiers
            for assets
          schema:
            type: string
      responses:
        '200':
          description: A single Metric object with the viewCount and playtimeMins metrics.
          content:
            application/json:
              schema:
                type: object
                description: |
                  A simplified metric object about aggregate viewership of an
                  asset. Either playbackId or dStorageUrl will be set.
                properties:
                  playbackId: 456d7d01-267d-4bd2-82a2-e13d10e89cb6
                  dStorageUrl: bdd7e0a2-aaec-4288-a776-1e2c07615751
                  viewCount: 4ce21630-e050-4317-b273-b89e2d0ca0db
                  playtimeMins: 68f3e56b-ca93-42f4-97cb-27aaee24e5ca
                x-speakeasy-name-override: data
        default:
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
      x-codeSamples:
        - lang: typescript
          label: getPublicViewershipMetrics
          source: |-
            import { Livepeer } from "livepeer";

            const livepeer = new Livepeer({
              apiKey: "<YOUR_BEARER_TOKEN_HERE>",
            });

            async function run() {
              const result = await livepeer.metrics.getPublicViewership("<id>");

              // Handle the result
              console.log(result);
            }

            run();
        - lang: go
          label: getPublicViewershipMetrics
          source: "package main\n\nimport(\n\tlivepeergo \"github.com/livepeer/livepeer-go\"\n\t\"context\"\n\t\"log\"\n)\n\nfunc main() {\n    s := livepeergo.New(\n        livepeergo.WithSecurity(\"<YOUR_BEARER_TOKEN_HERE>\"),\n    )\n\n    ctx := context.Background()\n    res, err := s.Metrics.GetPublicViewership(ctx, \"<value>\")\n    if err != nil {\n        log.Fatal(err)\n    }\n    if res.Data != nil {\n        // handle response\n    }\n}"
        - lang: python
          label: getPublicViewershipMetrics
          source: |-
            from livepeer import Livepeer

            s = Livepeer(
                api_key="<YOUR_BEARER_TOKEN_HERE>",
            )

            res = s.metrics.get_public_viewership(playback_id="<value>")

            if res.data is not None:
                # handle response
                pass
components:
  schemas:
    error:
      type: object
      properties:
        errors:
          type: array
          minItems: 1
          items:
            type: string
            example:
              - id not provided
              - Account not found
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      bearerFormat: JWT

````