API overview (truth pass)
In plain terms: treat OpenAPI at /api/ as the machine contract. This page maps feature areas to handlers and co-located markdown neighbors under src/app/api/.
Base URLs
| Environment | Base |
|---|
| Development | http://localhost:3000/api |
| Production | https://idling.app/api |
Handler count (audited): 60 route.ts + 4 route.tsx files under src/app/api/ (NextAuth catch-all counts as one module).
Authentication
| Surface | Module |
|---|
| NextAuth | src/app/api/auth/[...nextauth]/route.ts |
| Unlink account | src/app/api/auth/unlink-account/route.ts |
| Session permissions | src/app/api/auth/permissions/route.ts |
Admin routes use requireAdminApiAccess / withPermissions patterns — see co-located admin docs below.
Feature → HTTP map
Social & profile
Admin
| Area | Prefix | Index |
|---|
| Users & roles | /api/admin/users, assign-role, timeout | /app/api/admin/users/route |
| Permissions | /api/admin/permissions, roles | /app/api/admin/permissions/route |
| Quotas | /api/admin/quotas/global, per-user overrides | /app/api/admin/quotas/global/index |
| Subscriptions | plans, user-subscriptions, stats | src/app/api/admin/subscription-plans/route.ts |
| Alerts & emojis | /api/admin/alerts, /api/admin/emojis | co-located neighbors |
| Rate limit ops | /api/admin/rate-limit, test-rate-limit | route.ts |
Human admin charter (partially emoji-heavy; verify against route.ts): /app/api/admin.
Analytics, streams, subscription
| Route | Role |
|---|
POST /api/analytics/collect | Beacon ingest |
GET /api/analytics/dashboard | Dashboard aggregates |
GET /api/streams/live-status | Live stream flags |
GET /api/subscription/status | User subscription |
GET/POST /api/user-subscriptions | Self-serve subscription rows |
| Route | Role |
|---|
GET /api/version | Build/version JSON |
GET /api/openapi | OpenAPI JSON source |
GET /api/swagger | Swagger UI JSON proxy |
GET /api/test/health | Health probe |
GET /api/test-sse | SSE smoke test |
Removed fiction
- No public
/api/users CRUD list — user administration is under /api/admin/users with permission gates.
- No Elasticsearch-backed search API in this application.
- Co-located
src/app/api/index.md intentionally redirects readers here — do not resurrect fictional user CRUD tables.
Interactive docs
| Resource | URL on docs site |
|---|
| Redoc (OpenAPI) | /api/ |
| Swagger JSON route | Running app: /api/swagger |
| Regenerate spec | pnpm docs:openapi |
Rate limiting
Many public routes wrap handlers with withRateLimit (radio, og-image, etc.). Service implementation: src/lib/middleware/withRateLimit.ts — co-located doc under src/lib/services/ when audited.
Related hub pages
Sources: src/app/api/**/route.ts, src/app/api/**/route.tsx, src/app/api/openapi.json, src/app/api/index.md, src/idling/api-overview.md (prior truth pass), docusaurus.config.js (Redoc mount)