Skip to main content

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​

EnvironmentBase
Developmenthttp://localhost:3000/api
Productionhttps://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​

SurfaceModule
NextAuthsrc/app/api/auth/[...nextauth]/route.ts
Unlink accountsrc/app/api/auth/unlink-account/route.ts
Session permissionssrc/app/api/auth/permissions/route.ts

Admin routes use requireAdminApiAccess / withPermissions patterns — see co-located admin docs below.

Feature → HTTP map​

Idling tools (this hub)​

FeatureMethodsCo-located doc
Card generator / OG SVGGET /api/og-image, GET /api/og-image/[id]/app/api/og-image/index, /app/api/og-image/services/OGImageService
SVG → PNGGET, POST /api/svg-to-png/app/api/svg-to-png/route
Radio catalogGET /api/radio/stations/app/api/radio/stations/route
Radio playlist resolveGET /api/radio/playlist/app/api/radio/playlist/route
Radio now playingGET /api/radio/now-playing/app/api/radio/now-playing/route
Image uploadPOST /api/upload/image/app/api/upload/image/index
Form options (admin)GET/POST/DELETE /api/form-optionssrc/app/api/form-options/route.ts (neighbor stub may lag)

Social & profile​

AreaExamplesCo-located
Profile/api/profile/[username], /api/profile/id/[id]src/app/api/profile/[username]/route.md (co-located)
Users/api/users/search, /api/users/batch-decorationsroute.ts neighbors
Emojis/api/emojis, /api/emojis/usage/app/api/emojis/index
Link previewGET /api/link-preview/app/api/link-preview/index
Avatar renderGET /api/avatar-image/app/api/avatar-image/index

Admin​

AreaPrefixIndex
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
Subscriptionsplans, user-subscriptions, statssrc/app/api/admin/subscription-plans/route.ts
Alerts & emojis/api/admin/alerts, /api/admin/emojisco-located neighbors
Rate limit ops/api/admin/rate-limit, test-rate-limitroute.ts

Human admin charter (partially emoji-heavy; verify against route.ts): /app/api/admin.

Analytics, streams, subscription​

RouteRole
POST /api/analytics/collectBeacon ingest
GET /api/analytics/dashboardDashboard aggregates
GET /api/streams/live-statusLive stream flags
GET /api/subscription/statusUser subscription
GET/POST /api/user-subscriptionsSelf-serve subscription rows

Meta & health​

RouteRole
GET /api/versionBuild/version JSON
GET /api/openapiOpenAPI JSON source
GET /api/swaggerSwagger UI JSON proxy
GET /api/test/healthHealth probe
GET /api/test-sseSSE 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​

ResourceURL on docs site
Redoc (OpenAPI)/api/
Swagger JSON routeRunning app: /api/swagger
Regenerate specpnpm 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.


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)