diff --git a/README.md b/README.md index 57bb9d9..67bf231 100644 --- a/README.md +++ b/README.md @@ -87,48 +87,57 @@ Fields: ### API Endpoints -All endpoints accept and return `application/json`. +All endpoints accept and return `application/json`. Authenticated endpoints +require `Authorization: Bearer ` header. -#### Authentication +The API follows an IRC-inspired design: one unified message stream for all +message types (channel messages, DMs, server notices), with a simple `to` field +for addressing. + +#### Registration ``` -POST /api/v1/register — Create account (nick, password) → token -POST /api/v1/login — Authenticate → token -POST /api/v1/logout — Invalidate token +POST /api/v1/register — Create account { "nick": "..." } → { id, nick, token } ``` -#### Session & Messages +#### State ``` -GET /api/v1/messages — Retrieve queued messages (long-poll supported) - Query params: ?after=&timeout=30 -POST /api/v1/messages — Send a message or command -GET /api/v1/history — Retrieve channel/DM history - Query params: ?target=#channel&before=&limit=50 +GET /api/v1/state — User state: nick, id, and list of joined channels + Replaces separate /me and /channels endpoints +``` + +#### Messages (unified stream) + +``` +GET /api/v1/messages — Single message stream (long-poll supported) + All message types: channel, DM, notices, events + Query params: ?after=&timeout=30 +POST /api/v1/messages — Send a message + Body: { "to": "#channel" or "nick", "content": "..." } +``` + +#### History + +``` +GET /api/v1/history — Fetch history for a target (channel or DM) + Query params: ?target=#channel&before=&limit=50 + For DMs: ?target=nick&before=&limit=50 ``` #### Channels ``` -GET /api/v1/channels — List joined channels -POST /api/v1/channels/join — Join a channel -POST /api/v1/channels/part — Leave a channel -GET /api/v1/channels/{name} — Channel info (topic, members, modes) -POST /api/v1/channels/{name}/topic — Set channel topic -``` - -#### Users - -``` -GET /api/v1/users/me — Current user info -POST /api/v1/users/nick — Change nick -GET /api/v1/users/{nick} — User info (online status, idle time) +GET /api/v1/channels/all — List all server channels +POST /api/v1/channels/join — Join a channel { "channel": "#name" } +DELETE /api/v1/channels/{name} — Part (leave) a channel +GET /api/v1/channels/{name}/members — Channel member list ``` #### Server Info ``` -GET /api/v1/server — Server info (name, version, MOTD, user count) +GET /api/v1/server — Server info (name, MOTD) GET /.well-known/healthcheck.json — Health check ``` @@ -265,7 +274,8 @@ Per gohttpserver conventions: ## Status -**Design phase.** This README is the spec. Implementation has not started. +**Implementation in progress.** Core API is functional with SQLite storage and +embedded web client. ## License