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

# Test-run analytics

> Returns daily test-run statistics and a period summary for the scoped project.

Analytics uses path-based versioning; the current recommended version is **v2** (`/api/v2/analytics/`). The **v1** endpoints (`/api/v1/analytics/*`) are deprecated but remain available for backward compatibility. In v2, the v1 `test-cases` endpoint is split: `GET /api/v2/analytics/test-cases` returns metrics only, and `POST /api/v2/analytics/test-case-history/batch` fetches history for one or many test cases in a single request.

Percentage fields (`pass_rate`, `fail_rate`, `flaky_rate`) are integers in the **0-100** range, not decimals. All endpoints support date filtering via `days` (1-90), or a custom `start_date`/`end_date` range (ISO 8601).


## OpenAPI

````yaml /api-reference/openapi.generated.json get /api/v2/analytics/test-runs
openapi: 3.1.0
info:
  title: Empirical API
  version: 1.0.0
  description: Programmatic access to Empirical test runs, snoozes, and more.
  contact:
    name: Empirical
    url: https://empirical.run
servers:
  - url: https://api.empirical.run
security:
  - Bearer: []
tags:
  - name: Test Runs
    description: Trigger, list, and inspect end-to-end test runs.
  - name: Test Cases
    description: >-
      Browse the Playwright test cases synced from a project's repository and
      manage their tags.
  - name: Environments
    description: >-
      Named deployment targets (slug + Playwright project filters) a project's
      tests run against.
  - name: Snoozes
    description: Temporarily suppress known test failures for specific Playwright tests.
  - name: Analytics
    description: Aggregated test-run, test-count and test-case analytics for a project.
  - name: Resources
    description: >-
      Project file resources — uploads stored in R2 and external link-type files
      (e.g. Google Sheets).
  - name: Failure Groups
    description: >-
      Durable, cross-run identities for failure modes, carrying the latest
      triage diagnosis.
  - name: Badges
    description: Public README status badge images (SVG) for project environments.
paths:
  /api/v2/analytics/test-runs:
    get:
      tags:
        - Analytics
      summary: Test-run analytics
      description: >-
        Returns daily test-run statistics and a period summary for the scoped
        project.
      operationId: listTestRunsAnalyticsV2
      parameters:
        - schema:
            type: integer
            minimum: 1
            maximum: 90
            description: >-
              Number of days to include (1-90). Ignored when both `start_date`
              and `end_date` are provided.
          required: false
          description: >-
            Number of days to include (1-90). Ignored when both `start_date` and
            `end_date` are provided.
          name: days
          in: query
        - schema:
            type: string
            description: Start of a custom date range (ISO 8601).
          required: false
          description: Start of a custom date range (ISO 8601).
          name: start_date
          in: query
        - schema:
            type: string
            description: End of a custom date range (ISO 8601).
          required: false
          description: End of a custom date range (ISO 8601).
          name: end_date
          in: query
        - schema:
            type: integer
            minimum: 1
            description: Filter to a single environment by ID.
          required: false
          description: Filter to a single environment by ID.
          name: environment_id
          in: query
        - schema:
            type: string
            description: Filter to test runs on this git branch.
          required: false
          description: Filter to test runs on this git branch.
          name: branch
          in: query
      responses:
        '200':
          description: Daily test-run stats and a period summary.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnalyticsTestRunsResponse'
        '400':
          description: Invalid request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    AnalyticsTestRunsResponse:
      type: object
      properties:
        data:
          type: object
          properties:
            daily:
              type: array
              items:
                $ref: '#/components/schemas/AnalyticsDaily'
            summary:
              $ref: '#/components/schemas/AnalyticsRunsSummary'
          required:
            - daily
            - summary
          description: Response payload.
      required:
        - data
    ErrorResponse:
      type: object
      properties:
        data:
          nullable: true
          description: Always null for error responses.
        error:
          type: object
          properties:
            message:
              type: string
              description: Human-readable error message.
          required:
            - message
          description: Error details.
      required:
        - data
        - error
    AnalyticsDaily:
      type: object
      properties:
        date:
          type: string
          description: Date in YYYY-MM-DD format.
        run_count:
          type: number
          description: Total number of test runs on this date.
        passed_runs:
          type: number
          description: Number of passed test runs.
        failed_runs:
          type: number
          description: Number of failed test runs.
        error_runs:
          type: number
          description: Number of test runs that errored.
        cancelled_runs:
          type: number
          description: Number of cancelled test runs.
        rerun_count:
          type: number
          description: Number of reruns on this date.
        total_tests:
          type: number
          description: Total number of tests executed.
        passed_tests:
          type: number
          description: Number of passed tests.
        failed_tests:
          type: number
          description: Number of failed tests.
        failed_tests_after_snooze:
          type: number
          description: Number of failed tests after applying snoozes.
        flaky_tests:
          type: number
          description: Number of flaky tests.
      required:
        - date
        - run_count
        - passed_runs
        - failed_runs
        - error_runs
        - cancelled_runs
        - rerun_count
        - total_tests
        - passed_tests
        - failed_tests
        - failed_tests_after_snooze
        - flaky_tests
    AnalyticsRunsSummary:
      type: object
      properties:
        total_runs:
          type: number
          description: Total number of test runs in the period.
        passed_runs:
          type: number
          description: Number of passed test runs.
        failed_runs:
          type: number
          description: Number of failed test runs.
        error_runs:
          type: number
          description: Number of test runs that errored.
        pass_rate:
          type: number
          description: Pass rate as a percentage (0-100).
        avg_tests_per_run:
          type: number
          description: Average number of tests per run.
        rerun_count:
          type: number
          description: Total number of reruns.
        rerun_rate:
          type: number
          description: Rerun rate as a percentage (0-100).
      required:
        - total_runs
        - passed_runs
        - failed_runs
        - error_runs
        - pass_rate
        - avg_tests_per_run
        - rerun_count
        - rerun_rate
  securitySchemes:
    Bearer:
      type: http
      scheme: bearer

````