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

# Get daily views

> Views gained each day, per video or per book, with a flag for the day each video went viral. Days are UTC. Only videos that gained views (or went viral) in the range are included, so a quiet week returns an empty list.



## OpenAPI

````yaml /api-reference/openapi.json get /stats
openapi: 3.1.0
info:
  title: Sonder API
  version: 1.0.0
  description: >-
    Read an author's Sonder videos, views, viral days and view milestones. Every
    request uses an API key the author creates in Sonder, and sees that author's
    data only.
servers:
  - url: https://api.yousonder.com/v1
    description: Production
  - url: https://sonder-server-production.up.railway.app/v1
    description: Production (direct address)
security:
  - bearerAuth: []
tags:
  - name: Account
    description: Who the key belongs to.
  - name: Books
    description: The author's books.
  - name: Videos
    description: Posted videos with views, viral status and milestones.
  - name: Stats
    description: Day-by-day views.
  - name: Events
    description: Viral and milestone moments, for polling.
  - name: Connect
    description: One-click connect (OAuth 2.0).
paths:
  /stats:
    get:
      tags:
        - Stats
      summary: Get daily views
      description: >-
        Views gained each day, per video or per book, with a flag for the day
        each video went viral. Days are UTC. Only videos that gained views (or
        went viral) in the range are included, so a quiet week returns an empty
        list.
      operationId: getStats
      parameters:
        - name: start_date
          in: query
          description: First day, YYYY-MM-DD (UTC). Defaults to 6 days before `end_date`.
          schema:
            type: string
            format: date
          example: '2026-09-10'
        - name: end_date
          in: query
          description: >-
            Last day, YYYY-MM-DD (UTC). Defaults to today. At most 90 days after
            `start_date`.
          schema:
            type: string
            format: date
          example: '2026-09-16'
        - name: breakdown
          in: query
          description: Only `daily` today.
          schema:
            type: string
            enum:
              - daily
            default: daily
        - name: group_by
          in: query
          description: '`video` for one row per video, `book` to add up each book’s videos.'
          schema:
            type: string
            enum:
              - video
              - book
            default: video
        - name: book_id
          in: query
          description: Only this book’s videos.
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: Daily views.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StatsResponse'
              example:
                success: true
                start_date: '2026-09-14'
                end_date: '2026-09-16'
                breakdown: daily
                timezone: UTC
                group_by: video
                data:
                  - video:
                      id: 9f3c2a71-4b6e-4d8a-a1c5-7e2b9d0f3a64
                      title: Your kid isn't lazy. They're exhausted.
                      book:
                        id: 5b1d7c2e-8f0a-4c1b-9d3e-2a6f4b8c9e01
                        title: The Quiet Hours
                      posted_at: '2026-09-14T17:02:11.000Z'
                    days:
                      - date: '2026-09-14'
                        views: 2210
                        views_total: 2210
                        is_viral: false
                        went_viral: false
                      - date: '2026-09-15'
                        views: 31480
                        views_total: 33690
                        is_viral: true
                        went_viral: true
                      - date: '2026-09-16'
                        views: 14523
                        views_total: 48213
                        is_viral: true
                        went_viral: false
        '400':
          description: A parameter is invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                success: false
                error:
                  code: invalid_parameter
                  message: >-
                    start_date must be a date written YYYY-MM-DD, for example
                    2026-09-01.
        '401':
          description: The API key is missing, malformed or revoked.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                success: false
                error:
                  code: invalid_api_key
                  message: >-
                    That API key is not valid. Check it was copied in full, or
                    create a new one in Sonder under Settings → API keys.
        '403':
          description: The author's Sonder plan isn't active.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                success: false
                error:
                  code: plan_inactive
                  message: >-
                    This Sonder account doesn't have an active plan, so its data
                    isn't shared. The key works again as soon as the plan is
                    active.
        '429':
          description: >-
            More than 60 requests in a minute with this key. Wait for the
            seconds in `Retry-After`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                success: false
                error:
                  code: rate_limited
                  message: >-
                    Too many requests. Each key allows 60 a minute; try again
                    after the time in the Retry-After header.
components:
  schemas:
    StatsResponse:
      type: object
      required:
        - success
        - start_date
        - end_date
        - breakdown
        - timezone
        - group_by
        - data
      properties:
        success:
          type: boolean
          const: true
        start_date:
          type: string
          format: date
        end_date:
          type: string
          format: date
        breakdown:
          type: string
          const: daily
        timezone:
          type: string
          const: UTC
        group_by:
          type: string
          enum:
            - video
            - book
        data:
          oneOf:
            - type: array
              items:
                $ref: '#/components/schemas/VideoStats'
            - type: array
              items:
                $ref: '#/components/schemas/BookStats'
    Error:
      type: object
      required:
        - success
        - error
      properties:
        success:
          type: boolean
          const: false
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              description: Stable, machine-readable reason.
              enum:
                - missing_api_key
                - invalid_api_key
                - api_key_revoked
                - plan_inactive
                - rate_limited
                - invalid_parameter
                - range_too_long
                - not_found
                - internal_error
            message:
              type: string
              description: What went wrong and what to do, in plain English.
    VideoStats:
      type: object
      required:
        - video
        - days
      properties:
        video:
          type: object
          required:
            - id
            - title
            - book
            - posted_at
          properties:
            id:
              type: string
              format: uuid
            title:
              type: string
            book:
              oneOf:
                - $ref: '#/components/schemas/BookRef'
                - type: 'null'
            posted_at:
              type: string
              format: date-time
        days:
          type: array
          items:
            $ref: '#/components/schemas/StatsDay'
    BookStats:
      type: object
      required:
        - book
        - days
      properties:
        book:
          oneOf:
            - $ref: '#/components/schemas/BookRef'
            - type: 'null'
        days:
          type: array
          items:
            type: object
            required:
              - date
              - views
              - videos_went_viral
            properties:
              date:
                type: string
                format: date
              views:
                type: integer
                description: Views gained that day across the book's videos.
              videos_went_viral:
                type: array
                items:
                  type: string
                  format: uuid
                description: Videos of this book that went viral that day.
    BookRef:
      type: object
      required:
        - id
        - title
      properties:
        id:
          type: string
          format: uuid
        title:
          type: string
    StatsDay:
      type: object
      required:
        - date
        - views
        - views_total
        - is_viral
        - went_viral
      properties:
        date:
          type: string
          format: date
        views:
          type: integer
          description: Views gained that day. Never negative.
        views_total:
          type: integer
          description: Running total at the end of that day.
        is_viral:
          type: boolean
          description: The video had gone viral by the end of that day.
        went_viral:
          type: boolean
          description: The video went viral on that day.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: An API key from Sonder → Settings → API keys, like `sonder_live_…`.

````