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

# Get post analytics

> Views, likes, comments, shares and saves for each post the connected TikTok, Instagram, YouTube and Facebook accounts published in the last 7, 30 or 90 days, including posts made outside PostOnce. Each platform copy is compared with its account's median views (`views_vs_account_median`: 2 means twice the account's usual views), so above- and below-average posts can be found and compared. Numbers are cached and refreshed about every 10 minutes; `refreshing` is true while some are still loading. A metric is null when the platform does not report it. Partner accounts must pass `external_user_id` or `account_id`, and get one end user's posts per call. For one post, use `GET /v1/posts/{id}/analytics`.



## OpenAPI

````yaml /openapi/public-api.yaml get /v1/analytics
openapi: 3.1.0
info:
  title: PostOnce Public API
  version: 1.0.0-alpha
  description: Public API for PostOnce paid users
servers:
  - url: https://postonce.to/api/public
security:
  - bearerAuth: []
paths:
  /v1/analytics:
    get:
      summary: Get post analytics
      description: >-
        Views, likes, comments, shares and saves for each post the connected
        TikTok, Instagram, YouTube and Facebook accounts published in the last
        7, 30 or 90 days, including posts made outside PostOnce. Each platform
        copy is compared with its account's median views
        (`views_vs_account_median`: 2 means twice the account's usual views), so
        above- and below-average posts can be found and compared. Numbers are
        cached and refreshed about every 10 minutes; `refreshing` is true while
        some are still loading. A metric is null when the platform does not
        report it. Partner accounts must pass `external_user_id` or
        `account_id`, and get one end user's posts per call. For one post, use
        `GET /v1/posts/{id}/analytics`.
      parameters:
        - name: days
          in: query
          required: false
          description: Range in days. One of 7, 30 or 90. Defaults to 30.
          schema:
            type: integer
            default: 30
        - name: external_user_id
          in: query
          required: false
          description: >-
            Partner accounts only. Report on this end user's accounts. Partners
            must pass this or account_id.
          schema:
            type: string
        - name: account_id
          in: query
          required: false
          description: Report on one connected account.
          schema:
            type: string
      responses:
        '200':
          description: Analytics returned successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/PostAnalytics'
        '400':
          description: >-
            days is not 7, 30 or 90, or a partner account passed neither
            external_user_id nor account_id.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Missing, invalid, revoked, or expired API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthErrorResponse'
        '404':
          description: account_id is not one of your accounts (or not this end user's).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    PostAnalytics:
      type: object
      properties:
        range:
          type: object
          properties:
            days:
              type: integer
            start:
              type: string
              format: date-time
            end:
              type: string
              format: date-time
        accounts:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              platform:
                type: string
              username:
                type:
                  - string
                  - 'null'
              metrics_status:
                type: string
                description: >-
                  ok, reconnect (reconnect the account to read its numbers),
                  limited (some numbers need a permission the account lacks) or
                  unavailable (the platform request failed; try later).
              posts_with_views:
                type: integer
              median_views:
                type:
                  - number
                  - 'null'
                description: >-
                  Median views of the account's posts in the range; null with
                  fewer than 3 posts that have views.
              followers:
                type:
                  - integer
                  - 'null'
                description: >-
                  Latest stored follower count (YouTube subscribers). Measured
                  when the account connects, then weekly on paid plans.
              followers_observed_at:
                type:
                  - string
                  - 'null'
                format: date-time
        posts:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              title:
                type: string
                description: First line of the caption, at most 90 characters.
              caption:
                type: string
                description: >-
                  Full post text, including hashtags. For YouTube videos posted
                  outside PostOnce, the video title.
              thumbnail_url:
                type:
                  - string
                  - 'null'
                description: Cover image. Some platform links expire after a few hours.
              media_url:
                type:
                  - string
                  - 'null'
                description: >-
                  The video or image file PostOnce published, so an AI or tool
                  can watch or view it. null for posts made directly on the
                  platform.
              media_type:
                type: string
                enum:
                  - video
                  - photo
              published_at:
                type: string
                format: date-time
              origin:
                type: string
                description: >-
                  postonce when at least one copy went out through PostOnce;
                  native when posted directly on the platform.
              destinations:
                type: array
                items:
                  type: object
                  properties:
                    platform:
                      type: string
                    account_id:
                      type: string
                    username:
                      type:
                        - string
                        - 'null'
                    url:
                      type:
                        - string
                        - 'null'
                    published_at:
                      type: string
                      format: date-time
                    views:
                      type:
                        - integer
                        - 'null'
                    likes:
                      type:
                        - integer
                        - 'null'
                    comments:
                      type:
                        - integer
                        - 'null'
                    shares:
                      type:
                        - integer
                        - 'null'
                    saves:
                      type:
                        - integer
                        - 'null'
                    engagement_rate:
                      type:
                        - number
                        - 'null'
                      description: >-
                        (likes + comments + shares + saves) / views, from the
                        numbers the platform reports. null without views.
                    views_vs_account_median:
                      type:
                        - number
                        - 'null'
                      description: >-
                        This copy's views divided by its account's median views
                        in the range.
        truncated:
          type: boolean
          description: More posts existed than numbers were fetched for.
        refreshing:
          type: boolean
        updated_at:
          type: string
          format: date-time
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              example: workflow_limit_reached
            message:
              type: string
              example: You have reached the maximum number of workflows for your plan.
            hint:
              type: string
              description: Suggested action to resolve the error.
    AuthErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              example: invalid_api_key
            message:
              type: string
              example: Invalid API key.
            hint:
              type: string
              description: Suggested action to resolve the error.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: >-
        Scoped API key issued in PostOnce Settings. OAuth authorization grants
        are not currently supported.
      x-scopes:
        accounts:read: List and read connected accounts.
        accounts:write: Connect and disconnect social accounts.
        media:read: Read uploaded media.
        media:write: Upload media.
        posts:read: Read posts and unpublished drafts.
        posts:write: Create, update, publish, cancel, retry, and delete posts and drafts.
        workflows:read: List and read crossposting workflows.
        workflows:write: Create, update, and delete crossposting workflows.

````

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