Analytics
Get query insights for a project
Returns aggregated query-level analytics for a project including top queries by count, cache hit/miss summary, and latency statistics.
Feature flag: project-analytics
This endpoint is currently under a feature flag and available only to select testers. It may change or be removed before general availability.
At a glance
| Item | Value |
|---|---|
| Method | GET |
| Path | /v1/projects/{project_id}/insights |
| Auth | Authorization: Bearer <token-or-api-key> |
Quick request
Use this as a starting point. Replace the placeholder IDs and set PGBEAM_TOKEN if the endpoint requires auth.
curl -X GET \
"$PGBEAM_API_URL/v1/projects/<project_id>/insights" \
-H "Authorization: Bearer $PGBEAM_TOKEN"AuthorizationBearer <token>
JWT issued by Better Auth. Verified via JWKS.
In: header
Path Parameters
project_id*string
Unique project identifier (prefixed, e.g. prj_xxx).
Match
^[a-zA-Z0-9_.-]+$Query Parameters
range?string
Time range to query. Defaults to 24h.
Default
"24h"Value in
"1h" | "6h" | "24h" | "7d"limit?integer
Maximum number of top queries to return (1-100).
Default
20Range
1 <= value <= 100Response Body
application/json
application/json
application/json
application/json
application/json
curl -X GET "https://api.pgbeam.com/v1/projects/string/insights"{
"queries": [
{
"query_hash": "string",
"query_pattern": "string",
"total_count": 0,
"total_cache_hits": 0,
"total_cache_misses": 0,
"avg_latency_ms": 0.1,
"p99_latency_ms": 0.1
}
],
"cache": {
"total_hits": 0,
"total_misses": 0,
"hit_rate": 0.1
},
"latency": {
"avg_ms": 0.1,
"p99_ms": 0.1
}
}{
"error": {
"code": "string",
"message": "string"
}
}{
"error": {
"code": "string",
"message": "string"
}
}{
"error": {
"code": "string",
"message": "string"
}
}{
"error": {
"code": "string",
"message": "string"
}
}