docs: update README with IRC-inspired unified API design

- Document simplified endpoint structure
- Single message stream (GET /messages) for all message types
- Unified send (POST /messages) with 'to' field
- GET /state replaces separate /me and /channels
- GET /history for scrollback
- Update project status
This commit is contained in:
user
2026-02-10 10:20:13 -08:00
parent aabf8e902c
commit 16e08c2839

View File

@@ -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 <token>` 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/messagesRetrieve queued messages (long-poll supported)
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=<message-id>&timeout=30
POST /api/v1/messages — Send a message or command
GET /api/v1/history — Retrieve channel/DM history
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=<id>&limit=50
For DMs: ?target=nick&before=<id>&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