Skip to main content
GET
/
api
/
v1
/
analytics
/
test-cases
Test Cases
curl --request GET \
  --url https://api.example.com/api/v1/analytics/test-cases \
  --header 'Authorization: <authorization>'
{
  "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
        },
        "history": [
          {
            "timestamp": "2025-02-01T10:30:00.000Z",
            "status": "pass",
            "test_run_id": "12345",
            "environment_id": "1",
            "executed_at": "2025-02-01T10:30:00.000Z",
            "duration_total": 5200,
            "retries": 0
          }
        ]
      }
    ],
    "summary": {
      "total_test_cases": 150,
      "test_cases_with_history": 145
    }
  }
}
Returns test case analytics with aggregated metrics and run history. Supports filtering, searching, and sorting.

Examples

Request

Authorization
string
required
Bearer token for authentication. Format: Bearer <your-api-key>
days
number
default:"7"
Number of days of history (1-90). Ignored if start_date and end_date are provided.
start_date
string
Start of custom date range (ISO 8601 format). Must be used together with end_date.
end_date
string
End of custom date range (ISO 8601 format). Must be used together with start_date.
environment_id
string
Filter by environment ID.
test_case_id
string
Fetch history for a single test case. When provided, search, tags, order_by, order, and limit parameters are ignored.
Substring match on test name or file path.
tags
string
Comma-separated tags to filter by (includes match). Example: smoke,regression
order_by
string
default:"fail_rate"
Sort field. Allowed values: fail_rate, flaky_rate, last_run.
order
string
default:"desc"
Sort direction. Allowed values: asc, desc.
limit
number
default:"100"
Maximum number of test cases to return (1-500).
limit_history
number
default:"20"
Maximum history entries per test case (1-100).

Response

data
object
{
  "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
        },
        "history": [
          {
            "timestamp": "2025-02-01T10:30:00.000Z",
            "status": "pass",
            "test_run_id": "12345",
            "environment_id": "1",
            "executed_at": "2025-02-01T10:30:00.000Z",
            "duration_total": 5200,
            "retries": 0
          }
        ]
      }
    ],
    "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/v1/analytics/test-cases?days=7&order_by=fail_rate&limit=50" \
  -H "Authorization: Bearer $EMPIRICALRUN_KEY"

Get history for a single test case

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