Web Analytics Query API
Use this API when you want to render Loguro web analytics inside your own admin panel, customer dashboard, internal report, or scheduled job.
These are the same read endpoints used by the Loguro web analytics dashboard. They are available under:
https://logu.ro/api/web-events/:projectSlug Use the project slug, not the internal project id.
Authentication
Pass a PAT in the Authorization header:
curl -H "Authorization: Bearer pat_xxx" \
"https://logu.ro/api/web-events/local/kpis?range=7d" The PAT owner must have access to the project. If the token is missing, expired, revoked, or belongs to a user without project access, the API returns 401 or 404.
Common parameters
Most endpoints accept the same time and filter parameters.
| Parameter | Description |
|---|---|
range | Time chip. One of 1h, 24h, 7d, 30d, 3m, 12m, all. Default: 24h. |
from / to | ISO timestamps. If both are present and valid, they override range. |
filter | Dashboard filter string. Same syntax as Dashboard filters. |
limit | Maximum rows for list/top endpoints. Each endpoint caps this server-side. |
compare=1 | Include previous-period counts/deltas where supported. |
Examples:
range=7d
range=24h&filter=path:/pricing country:RO
from=2026-06-01T00:00:00.000Z&to=2026-06-08T00:00:00.000Z
filter=event_type:custom custom_event_name:signup_completed
filter=!device:mobile search:checkout Supported filter keys:
| Key | Example |
|---|---|
path | path:/pricing |
country | country:RO |
device | device:mobile |
browser | browser:chrome |
os | os:macos |
visitor_id | visitor_id:"01HZ..." |
session_id | session_id:"01HZ..." |
event_type | event_type:pageview or event_type:custom |
custom_event_name | custom_event_name:signup_completed |
search | search:checkout |
Use ! for negation and | for OR:
country:RO|US !device:mobile KPIs
GET /api/web-events/:projectSlug/kpis Returns unique visitors, pageviews, sessions, bounce rate, and average session duration for the selected range, plus the previous period.
curl -H "Authorization: Bearer pat_xxx" \
"https://logu.ro/api/web-events/local/kpis?range=7d&filter=path:/pricing" Response shape:
{
"current": {
"visitors": 143,
"pageviews": 402,
"sessions": 181,
"bounceRate": 0.42,
"avgDurationSec": 96.5
},
"previous": {
"visitors": 120,
"pageviews": 350,
"sessions": 156,
"bounceRate": 0.47,
"avgDurationSec": 82.1
},
"range": {
"chip": "7d",
"from": "2026-06-04T10:00:00.000Z",
"to": "2026-06-11T10:00:00.000Z",
"bucket": "day",
"hasPrevious": true
}
} Timeseries
GET /api/web-events/:projectSlug/timeseries Returns bucketed pageviews, visitors, and sessions. 1h and 24h use hourly buckets; longer ranges use daily buckets.
curl -H "Authorization: Bearer pat_xxx" \
"https://logu.ro/api/web-events/local/timeseries?range=30d" Response shape:
{
"items": [
{
"bucket": "2026-06-10T00:00:00.000Z",
"pageviews": 84,
"visitors": 51,
"sessions": 63,
"previousPageviews": 72,
"previousVisitors": 44,
"previousSessions": 55
}
],
"bucket": "day"
} Raw event listing
GET /api/web-events/:projectSlug Returns recent raw web event rows ordered newest first.
curl -H "Authorization: Bearer pat_xxx" \
"https://logu.ro/api/web-events/local?range=24h&limit=100" Response shape:
{
"items": [
{
"id": "01J...",
"event_type": "pageview",
"path": "/pricing",
"url": "https://example.com/pricing",
"visitor_id": "01HZ...",
"session_id": "01HZ...",
"country_code": "RO",
"browser_family": "Chrome",
"device_type": "desktop",
"timestamp": "2026-06-11T09:59:02.000Z"
}
],
"count": 1
} For just the count:
GET /api/web-events/:projectSlug/count Top lists
Top endpoints return arrays under items.
| Endpoint | Description |
|---|---|
GET /top-pages | Pageview counts grouped by path. |
GET /top-referrers | Traffic grouped by referrer. Empty referrers are returned as direct traffic. |
GET /top-countries | Event counts and unique visitors grouped by country. |
GET /top-locations | Per-visitor location and latest metadata for map-style UIs. |
GET /top-browsers | Grouped by browser family. |
GET /top-os | Grouped by OS family. |
GET /top-devices | Grouped by device type. |
GET /top-entry-pages | First pageview per session. |
GET /top-exit-pages | Last pageview per session. |
GET /top-flows | Common first N page paths per session. |
Examples:
curl -H "Authorization: Bearer pat_xxx" \
"https://logu.ro/api/web-events/local/top-pages?range=7d&limit=20&compare=1" curl -H "Authorization: Bearer pat_xxx" \
"https://logu.ro/api/web-events/local/top-flows?range=30d&depth=3&limit=25" top-flows accepts:
| Parameter | Description |
|---|---|
depth | Number of pageview steps per flow. Min 2, max 5, default 3. |
limit | Max rows. Capped at 300. |
Custom events
GET /api/web-events/:projectSlug/custom-events Aggregates events sent with window.Loguro.track(...) by custom_event_name.
curl -H "Authorization: Bearer pat_xxx" \
"https://logu.ro/api/web-events/local/custom-events?range=7d&limit=20" Response shape:
{
"items": [
{
"name": "signup_completed",
"count": 42,
"prev_count": 31,
"delta_pct": 35,
"spark": [2, 5, 4, 9]
}
],
"buckets": ["2026-06-08T00:00:00.000Z"],
"bucket": "day"
} Recent activity
GET /api/web-events/:projectSlug/recent-events Returns a compact event shape for live panels or “currently active” widgets.
curl -H "Authorization: Bearer pat_xxx" \
"https://logu.ro/api/web-events/local/recent-events?windowMs=300000&limit=200" Parameters:
| Parameter | Description |
|---|---|
windowMs | Lookback window in milliseconds. Min 60000, max 3600000, default 300000. |
limit | Max rows. Capped at 500. |
Visitor detail
GET /api/web-events/:projectSlug/visitor/:visitorId
GET /api/web-events/:projectSlug/visitor/:visitorId/sessions Use these to build support/debugging views for one visitor.
curl -H "Authorization: Bearer pat_xxx" \
"https://logu.ro/api/web-events/local/visitor/01HZ7XK4N8..." curl -H "Authorization: Bearer pat_xxx" \
"https://logu.ro/api/web-events/local/visitor/01HZ7XK4N8.../sessions" /sessions returns a grouped visit history:
{
"sessions": [
{
"session_id": "01HZ...",
"start": "2026-06-11T09:00:00.000Z",
"end": "2026-06-11T09:12:00.000Z",
"duration_ms": 720000,
"page_count": 4,
"entry_page": "/",
"exit_page": "/checkout",
"events": [
{
"path": "/checkout",
"url": "https://example.com/checkout",
"event_type": "pageview",
"custom_event_name": null,
"timestamp": "2026-06-11T09:10:00.000Z"
}
]
}
]
} Fetch from your app
Do not expose your PAT in a browser bundle. Call Loguro from your server, then return only the data your UI needs.
const LOGURO_PAT = process.env.LOGURO_PAT!;
const PROJECT_SLUG = 'local';
async function loguroWebAnalytics(path: string, params: Record<string, string> = {}) {
const url = new URL(`https://logu.ro/api/web-events/${PROJECT_SLUG}${path}`);
for (const [key, value] of Object.entries(params)) {
url.searchParams.set(key, value);
}
const res = await fetch(url, {
headers: {
Authorization: `Bearer ${LOGURO_PAT}`
}
});
if (!res.ok) {
throw new Error(`Loguro analytics query failed: ${res.status}`);
}
return res.json();
}
export async function getAnalyticsOverview() {
const [kpis, timeseries, topPages] = await Promise.all([
loguroWebAnalytics('/kpis', { range: '7d' }),
loguroWebAnalytics('/timeseries', { range: '7d' }),
loguroWebAnalytics('/top-pages', { range: '7d', limit: '10' })
]);
return { kpis, timeseries, topPages };
} Status codes
| Status | Meaning |
|---|---|
200 | Query succeeded. |
400 | Invalid project identifier or visitor id. |
401 | Missing, invalid, expired, or revoked PAT. |
404 | Project not found or the PAT owner cannot access it. |
500 | Query failed. Retry later or reduce range/filter size. |
Notes
- These endpoints read web analytics only. They do not read logs or datasets.
- Large ranges can scan more Parquet files. Prefer
range=7dor explicitfrom/towindows for embedded dashboards. top-locationsreturns per-visitor location metadata. Treat it as sensitive operational analytics data and keep it behind your own auth.- Response shapes are optimized for the Loguro dashboard and may include additional fields over time.