> ## 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 realtime viewership

> Requires a private (non-CORS) API key to be used.




## OpenAPI

````yaml GET /data/views/now
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/now:
    get:
      tags:
        - metrics
      summary: Query realtime viewership
      description: |
        Requires a private (non-CORS) API key to be used.
      operationId: getRealtimeViewershipNow
      parameters:
        - name: playbackId
          in: query
          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
        - name: creatorId
          in: query
          description: The creator ID to filter the query results
          schema:
            type: string
        - name: breakdownBy[]
          in: query
          description: |
            The list of fields to break down the query results. Specify this
            query-string multiple times to break down by multiple fields.
          schema:
            type: array
            items:
              type: string
              enum:
                - playbackId
                - device
                - browser
                - country
      responses:
        '200':
          description: A list of Metric objects
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/realtime-viewership-metric'
                x-speakeasy-name-override: data
        default:
          description: Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error'
      x-codeSamples:
        - lang: typescript
          label: getRealtimeViewershipNow
          source: |-
            import { Livepeer } from "livepeer";

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

            async function run() {
              const result = await livepeer.metrics.getRealtimeViewership();

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

            run();
        - lang: go
          label: getRealtimeViewershipNow
          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.GetRealtimeViewership(ctx, nil, nil, nil)\n    if err != nil {\n        log.Fatal(err)\n    }\n    if res.Data != nil {\n        // handle response\n    }\n}"
        - lang: python
          label: getRealtimeViewershipNow
          source: |-
            from livepeer import Livepeer

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

            res = s.metrics.get_realtime_viewership()

            if res.data is not None:
                # handle response
                pass
components:
  schemas:
    realtime-viewership-metric:
      type: object
      description: |
        An individual metric about realtime viewership of a stream/asset.
      required:
        - viewCount
        - errorRate
      properties:
        playbackId:
          type: string
          description: The playback ID associated with the metric.
          example: 1bde4o2i6xycudoy
        device:
          type: string
          description: The device used by the viewer.
          example: iPhone
        browser:
          type: string
          description: The browser used by the viewer.
          example: Safari
        country:
          type: string
          description: The country where the viewer is located.
          example: United States
        viewCount:
          type: integer
          description: The number of views for the stream/asset.
          example: 100
        errorRate:
          type: number
          description: The error rate for the stream/asset.
          example: 0.1
    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

````