Plausible Query API

Run analytics queries against site data.

OpenAPI Specification

plausible-query-api-openapi.yml Raw ↑
openapi: 3.0.3
info:
  title: Plausible Events CustomProps Query API
  description: The Plausible Events API allows server-side and non-browser clients to send pageviews and custom events to Plausible.
  version: 1.0.0
  contact:
    name: Plausible Support
    url: https://plausible.io/contact
  license:
    name: AGPL-3.0
    url: https://github.com/plausible/analytics/blob/master/LICENSE.md
servers:
- url: https://plausible.io
  description: Plausible Cloud
tags:
- name: Query
  description: Run analytics queries against site data.
paths:
  /api/v2/query:
    post:
      tags:
      - Query
      summary: Run a query against site analytics data
      description: Execute a query against a Plausible site to retrieve metrics with optional dimensions, filters, ordering, and pagination.
      operationId: runQuery
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/QueryRequest'
      responses:
        '200':
          description: Query result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/QueryResponse'
        '400':
          description: Bad request
        '401':
          description: Unauthorized
        '429':
          description: Rate limit exceeded
components:
  schemas:
    QueryRequest:
      type: object
      required:
      - site_id
      - metrics
      - date_range
      properties:
        site_id:
          type: string
          description: The domain registered in Plausible.
          example: example.com
        metrics:
          type: array
          items:
            type: string
            enum:
            - visitors
            - visits
            - pageviews
            - views_per_visit
            - bounce_rate
            - visit_duration
            - events
            - scroll_depth
            - percentage
            - conversion_rate
            - group_conversion_rate
            - average_revenue
            - total_revenue
        date_range:
          oneOf:
          - type: string
            enum:
            - day
            - 7d
            - 28d
            - 30d
            - 91d
            - month
            - 6mo
            - 12mo
            - year
            - all
          - type: array
            items:
              type: string
              format: date-time
            minItems: 2
            maxItems: 2
        dimensions:
          type: array
          items:
            type: string
        filters:
          type: array
          items:
            type: array
        order_by:
          type: array
          items:
            type: array
        include:
          type: object
          properties:
            imports:
              type: boolean
            time_labels:
              type: boolean
            total_rows:
              type: boolean
        pagination:
          type: object
          properties:
            limit:
              type: integer
            offset:
              type: integer
    QueryResponse:
      type: object
      properties:
        results:
          type: array
          items:
            type: object
            properties:
              metrics:
                type: array
                items:
                  type: number
              dimensions:
                type: array
                items:
                  type: string
        meta:
          type: object
        query:
          type: object