Skip to main content
GET
/
api
/
v2
/
analytics
/
test-cases
Test Cases Analytics (v2)
curl --request GET \
  --url https://dash.empirical.run/api/v2/analytics/test-cases \
  --header 'Authorization: Bearer <token>'
{
  "data": {
    "test_cases": [
      {
        "test_case_id": "abc-123-def",
        "test_name": "should login successfully",
        "file_path": "tests/auth/login.spec.ts",
        "project_name": "my-project",
        "tags": ["smoke", "auth"],
        "last_run_at": "2025-02-01T10:30:00.000Z",
        "metrics": {
          "total_runs": 20,
          "pass_count": 18,
          "fail_count": 1,
          "flaky_count": 1,
          "pass_rate": 90,
          "fail_rate": 5,
          "flaky_rate": 5
        }
      }
    ],
    "summary": {
      "total_test_cases": 150,
      "test_cases_with_history": 145
    }
  }
}

Documentation Index

Fetch the complete documentation index at: https://docs.empirical.run/llms.txt

Use this file to discover all available pages before exploring further.

Returns test case analytics with aggregated metrics. Supports filtering, searching, and sorting.
Unlike v1, this endpoint does not include per-execution history. Fetch history separately with POST /api/v2/analytics/test-case-history/batch for the rows you actually need. Splitting the two queries keeps the table query fast.
{
  "data": {
    "test_cases": [
      {
        "test_case_id": "abc-123-def",
        "test_name": "should login successfully",
        "file_path": "tests/auth/login.spec.ts",
        "project_name": "my-project",
        "tags": ["smoke", "auth"],
        "last_run_at": "2025-02-01T10:30:00.000Z",
        "metrics": {
          "total_runs": 20,
          "pass_count": 18,
          "fail_count": 1,
          "flaky_count": 1,
          "pass_rate": 90,
          "fail_rate": 5,
          "flaky_rate": 5
        }
      }
    ],
    "summary": {
      "total_test_cases": 150,
      "test_cases_with_history": 145
    }
  }
}

List test cases sorted by fail rate

curl -X GET \
  "https://dash.empirical.run/api/v2/analytics/test-cases?days=7&order_by=fail_rate&limit=50" \
  -H "Authorization: Bearer $EMPIRICALRUN_KEY"

Get metrics for a single test case

curl -X GET \
  "https://dash.empirical.run/api/v2/analytics/test-cases?test_case_id=abc-123-def&days=30" \
  -H "Authorization: Bearer $EMPIRICALRUN_KEY"
curl -X GET \
  "https://dash.empirical.run/api/v2/analytics/test-cases?search=login&tags=smoke,auth" \
  -H "Authorization: Bearer $EMPIRICALRUN_KEY"

Authorizations

Authorization
string
header
required

Project API key from the Empirical dashboard.

Query Parameters

days
number

Number of days of history (1-90, default 7). Ignored if start_date and end_date are provided.

start_date
string

Start of custom date range (ISO 8601). Must be used together with end_date.

end_date
string

End of custom date range (ISO 8601). Must be used together with start_date.

environment_id
string

Filter by environment ID.

test_case_id
string

Fetch metrics for a single test case. When provided, search, tags, order_by, order, and limit are ignored.

Substring match on test name or file path.

tags
string

Comma-separated tags to filter by (includes match).

order_by
string

Sort field. Allowed values: fail_rate, flaky_rate, last_run.

order
string

Sort direction. Allowed values: asc, desc.

limit
number

Maximum number of test cases to return (1-500, default 100).

is_active
string

Set to false to include test cases that no longer exist in the latest synced revision. Defaults to true (active only).

Response

Test case analytics (metrics only).

data
object
required