ryOS ryOS / Docs
GitHub Launch

API Reference

ryOS backend APIs use Node-style route handlers in api/, served by the standalone Bun API server.

Most actively refactored JSON routes use the shared apiHandler utility (api/_utils/api-handler.ts) for CORS, method checks, auth resolution, and consistent error handling. Some specialized routes (for example multipart upload handlers) still use explicit/manual handling.

API Request Flow

graph LR
    Client[Client App] --> Auth{Auth Check}
    Auth -->|Valid| Router[API Router]
    Auth -->|Invalid| Error[401 Error]
    Router --> API[Node.js Runtime]
    API --> Services[External Services]
    Services --> AI[AI Providers]
    Services --> DB[(Redis/KV)]
    Services --> Media[Media APIs]
    API --> Response[JSON Response]
    Response --> Client

Endpoint Documentation

Endpoint GroupDescription
Chat APIMain AI chat with streaming and tool calling
Song APIMusic library CRUD, lyrics, furigana, translations
Media APIText-to-speech, transcription, YouTube search
Auth APIUser registration, login, token management
Rooms APIChat room creation and management
Messages APISend and retrieve chat messages
Presence APIPresence tracking, user search, AI replies
AI Generation APIsApplet generation, IE time-travel, parse-title
Utility APIsLink preview, iframe check, share applet, stocks, sync, admin
API Design GuidePatterns and conventions for API development

Cross-Cutting Handler Pattern

  • apiHandler: shared wrapper for CORS preflight, origin checks, method allowlists, optional JSON parsing, unified logger wiring, and default JSON error handling.
  • request-auth: shared auth resolver for token endpoints, expecting:
    • Authorization: Bearer {token}
    • X-Username: {username}
  • Partial auth headers return 400.
  • Invalid token/username pairs return 401.
  • Optional-auth endpoints can be anonymous while still validating provided auth headers.

Infrastructure Adapters

  • Redis (api/_utils/redis.ts): Centralized Redis client factory supporting Upstash REST (REDIS_KV_REST_API_URL) and standard Redis (REDIS_URL) backends with a unified API.

Quick Reference

AI Endpoints

EndpointPurpose
/api/chatMain AI chat with tool calling
/api/ai/conversations/:channelSynced Chat and Assistant history
/api/ai/conversations/:channel/resetClear synced history and process memories
/api/ai/attachments/:idPrivate synced chat images
/api/applet-aiApplet text + image generation
/api/ie-generateTime-travel page generation
/api/parse-titleMusic metadata extraction
/api/ai/extract-memoriesDaily-note and long-term memory extraction
/api/ai/process-daily-notesBackground daily-note processing
/api/ai/cursor-run-statusCursor Cloud agent run polling
/api/ai/cursor-run-followupFollow-up prompt for an existing Cursor run

Media Endpoints

EndpointPurpose
/api/songs/Song library CRUD
/api/songs/[id]Individual song operations
/api/speechText-to-speech
/api/audio-transcribeSpeech-to-text
/api/youtube-searchYouTube music search
/api/apple-music-artworkApple Music artwork proxy

Communication Endpoints

EndpointPurpose
/api/roomsRoom list + create
/api/rooms/[id]Room detail + delete
/api/rooms/[id]/joinJoin a room
/api/rooms/[id]/leaveLeave a room
/api/rooms/[id]/usersGet active users in room
/api/rooms/[id]/messagesList/send messages
/api/rooms/[id]/messages/[msgId]Delete message (admin)
/api/messages/bulkBulk message fetch
/api/presence/switchPresence switching
/api/presence/heartbeatGlobal online presence heartbeat
/api/rooms/[id]/typingBroadcast typing indicator
/api/usersUser search
/api/ai/ryo-replyAI reply in rooms
/api/listen/sessionsList/create listen-together sessions
/api/listen/sessions/[id]Get session state
/api/listen/sessions/[id]/joinJoin listen session
/api/listen/sessions/[id]/leaveLeave listen session
/api/listen/sessions/[id]/syncSync playback state (DJ only)
/api/listen/sessions/[id]/assign-djAssign the session DJ
/api/listen/sessions/[id]/transfer-hostTransfer session host
/api/listen/sessions/[id]/remote-commandSubmit remote playback command
/api/listen/sessions/[id]/reactionSend emoji reaction
/api/irc/serversList/create IRC server configs
/api/irc/servers/[id]DELETE — remove IRC server config (admin only)
/api/irc/servers/[id]/channelsBrowse IRC channels
/api/pusher/authAuthorize private/presence Pusher channels
/api/realtime/ticketMint local WebSocket realtime tickets
/api/telegram/link/createCreate Telegram account link
/api/telegram/link/statusCheck Telegram link status
/api/telegram/link/disconnectDisconnect Telegram account

Utility Endpoints

EndpointPurpose
/api/link-previewURL metadata extraction
/api/iframe-checkEmbeddability checking
/api/share-appletApplet sharing
/api/stocksReal-time stock quotes
/api/currency-rateCurrency conversion rates
/api/mapkit-tokenMapKit JS token
/api/musickit-tokenMusicKit JS token
/api/tv/create-channelAI-assisted TV channel creation
/api/sync/auto-sync-preferenceRead/update the cross-device Auto Sync toggle
/api/sync/v2/opsApply batched journal ops
/api/sync/v2/changesRead journal ops after a cursor
/api/sync/v2/snapshotRead full key-value sync snapshot
/api/sync/v2/blobsPrepare/dedupe content-addressed blob uploads
/api/cron/sync-maintenanceGarbage-collect unreferenced sync blobs and heal user records
/api/analytics/eventsRecord lightweight client analytics events
/api/adminAdmin operations
/api/airdrop/heartbeatAirDrop presence heartbeat
/api/airdrop/discoverDiscover nearby AirDrop users
/api/airdrop/sendSend file via AirDrop
/api/airdrop/respondAccept/decline AirDrop transfer

Endpoint Categories Overview

graph TD
    API["/api/*"]
    API --> AI[AI Services]
    API --> Media[Media Services]
    API --> Comm[Communication]
    API --> Util[Utilities]
    
    AI --> chat["/chat"]
    AI --> applet["/applet-ai"]
    AI --> ie["/ie-generate"]
    AI --> parse["/parse-title"]
    
    Media --> song["/song/*"]
    Media --> speech["/speech"]
    Media --> transcribe["/audio-transcribe"]
    Media --> yt["/youtube-search"]
    
    Comm --> rooms["/rooms"]
    Comm --> messages["/messages/bulk"]
    Comm --> presence["/presence/switch"]
    Comm --> users["/users"]
    Comm --> ryo["/ai/ryo-reply"]
    Comm --> listen["/listen/sessions"]
    Comm --> telegram["/telegram/link"]
    
    Util --> preview["/link-preview"]
    Util --> iframe["/iframe-check"]
    Util --> share["/share-applet"]
    Util --> stocks["/stocks"]
    Util --> sync["/sync/v2/* + backup"]
    Util --> admin["/admin"]

Authentication

Browser sessions use an httpOnly ryos_auth cookie set by register, login, token/verify, token/refresh, and session. Programmatic clients may still use Bearer + X-Username headers:

Authorization: Bearer {token}
X-Username: {username}

Token-based sessions use a 1-year TTL, refreshed on each validated request. Auth-required endpoints use the shared request-auth validation boundary for consistent 400/401 semantics.

Standalone Bun Server Routes

When running via scripts/api-standalone-server.ts:

RoutePurpose
GET /healthProcess health + route count
GET /api/healthAPI health
GET /app-config.jsClient runtime config bootstrap (window.__RYOS_RUNTIME_CONFIG__)
WebSocket REALTIME_WS_PATHLocal realtime (ticket from /api/realtime/ticket)

Environment Variables

VariableEndpoints / purpose
REDIS_KV_REST_API_URL / REDIS_KV_REST_API_TOKENCore (Upstash REST)
REDIS_URLCore (standard Redis); required for multi-instance local realtime
PUSHER_APP_ID, PUSHER_KEY, PUSHER_SECRET, PUSHER_CLUSTERPusher realtime + /api/pusher/auth
REALTIME_PROVIDER, REALTIME_WS_PATHlocal/api/realtime/ticket + WebSocket
MAPKIT_*/api/mapkit-token, Maps AI tools
MUSICKIT_* (or MAPKIT_* fallback)/api/musickit-token
TELEGRAM_BOT_TOKEN, TELEGRAM_WEBHOOK_SECRET, TELEGRAM_BOT_USERNAME/api/webhooks/telegram, /api/telegram/link/*
CRON_SECRET/api/cron/sync-maintenance, /api/cron/telegram-heartbeat
CURSOR_API_KEY/api/ai/cursor-run-followup, admin Cursor actions
TRUSTED_PROXY_COUNT, AUTH_COOKIE_SECUREStandalone reverse-proxy hardening (see Self-hosting)

AI Providers

ProviderModels
OpenAIgpt-5.5, tts-1, whisper-1
Anthropicsonnet-4.6
Googlegemini-3-flash, gemini-3-flash-preview, gemini-3.1-pro-preview, gemini-3.1-flash-image-preview