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

# Get analytics

> Published posts in a date range with each channel's latest metrics, plus totals for the whole range.



## OpenAPI

````yaml /openapi.json get /analytics
openapi: 3.1.0
info:
  title: Postbase API
  version: 1.0.0
  description: >-
    Schedule and manage social posts on X, LinkedIn, Bluesky, Mastodon and
    YouTube. Authenticate with an API key from Postbase → Developers, sent as
    `Authorization: Bearer pb_live_…`.
  contact:
    url: https://www.postbase.so
  license:
    name: AGPL-3.0
    identifier: AGPL-3.0-only
servers:
  - url: https://www.postbase.so/api/v1
security:
  - bearerAuth: []
tags:
  - name: Posts
  - name: Media
  - name: Analytics
  - name: Webhooks
  - name: Channels
  - name: Account
paths:
  /analytics:
    get:
      tags:
        - Analytics
      summary: Get analytics
      description: >-
        Published posts in a date range with each channel's latest metrics, plus
        totals for the whole range.
      operationId: getAnalytics
      parameters:
        - name: from
          in: query
          schema:
            type: string
            format: date
          description: First day (YYYY-MM-DD). Defaults to 29 days before to.
        - name: to
          in: query
          schema:
            type: string
            format: date
          description: Last day (YYYY-MM-DD). Defaults to today (UTC). Up to 366 days.
        - name: post_id
          in: query
          schema:
            type: string
            format: uuid
          description: Just this post (ignores the dates).
        - name: channel_id
          in: query
          schema:
            type: string
            format: uuid
        - name: platform
          in: query
          schema:
            type: string
        - name: sort
          in: query
          schema:
            type: string
            enum:
              - date
              - impressions
              - likes
              - comments
              - shares
              - saves
              - engagement
            default: date
        - name: order
          in: query
          schema:
            type: string
            enum:
              - desc
              - asc
            default: desc
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 50
        - name: offset
          in: query
          schema:
            type: integer
            minimum: 0
            default: 0
      responses:
        '200':
          description: Posts and totals
          content:
            application/json:
              schema:
                type: object
                properties:
                  from:
                    type:
                      - string
                      - 'null'
                    format: date
                  to:
                    type:
                      - string
                      - 'null'
                    format: date
                  totals:
                    allOf:
                      - $ref: '#/components/schemas/Metrics'
                      - type: object
                        properties:
                          posts:
                            type: integer
                  posts:
                    type: array
                    items:
                      $ref: '#/components/schemas/AnalyticsPost'
                  has_more:
                    type: boolean
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Missing or invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    Metrics:
      type: object
      properties:
        impressions:
          type:
            - number
            - 'null'
        likes:
          type: number
        comments:
          type: number
        shares:
          type: number
        saves:
          type: number
        engagement:
          type: number
          description: likes + comments + shares + saves
    AnalyticsPost:
      type: object
      properties:
        post_id:
          type: string
          format: uuid
        body:
          type: string
        published_at:
          type: string
          format: date-time
        channels:
          type: array
          items:
            type: object
            properties:
              channel_id:
                type: string
              platform:
                type:
                  - string
                  - 'null'
              handle:
                type:
                  - string
                  - 'null'
              url:
                type:
                  - string
                  - 'null'
                format: uri
              metrics:
                type: object
                additionalProperties:
                  type: number
              metrics_updated_at:
                type:
                  - string
                  - 'null'
                format: date-time
        totals:
          $ref: '#/components/schemas/Metrics'
    Error:
      type: object
      properties:
        error:
          type: string
          description: A readable message
        code:
          type: string
          description: A stable code, e.g. not_found
      required:
        - error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: A pb_live_ API key

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.