POST /api/login
{
"nick": "nickname",
"password": "password"
}Response:
{
"success": true,
"token": "<JWT>",
"refresh_token": "<refresh-token>"
}POST /api/refresh
{
"refresh_token": "<refresh-token>"
}Response:
{
"success": true,
"token": "<new-JWT>"
}GET /api/oauth/login?provider=google|github
- Redirects to Google/GitHub
GET /api/oauth/callback?provider=google|github&code=...
- Exchanges code for token, returns JWT + refresh token
GET /api/me (JWT required)
Header: Authorization: Bearer <JWT>
Response:
{
"success": true,
"user": { ... }
}POST /api/logout
- (Client-side, just delete JWT)
GET /api/channels
GET /api/channels/{name}
POST /api/channels
{
"name": "#channel"
}POST /api/channels/{name}/join
POST /api/channels/{name}/part
DELETE /api/channels/{name}
POST /api/channels/{name}/moderate
{
"action": "op|deop|voice|devoice|kick|ban|unban",
"target": "nickname"
}POST /api/messages
{
"target": "#channel",
"message": "Hello World!"
}POST /api/messages/private
{
"to": "nickname",
"message": "Hi!"
}GET /api/channels/{name}/users
GET /api/channels/{name}/messages?limit=50
GET /api/users
GET /api/status
URL: ws://localhost:8081/?token=<JWT>
- Authenticate via JWT in query string
- Message format:
{
"type": "message",
"channel": "#channel",
"message": "Text"
}- Events: New messages, user join/part, channel changes (depending on implementation)
All errors are returned as JSON with success: false and an error field.
Example:
{
"success": false,
"error": "Authentication required"
}- All endpoints (except
/login,/refresh,/oauth/*) require a valid JWT in the header:Authorization: Bearer <JWT> - For OAuth2, redirect URIs and client IDs/secrets must be set in
config.php. - Channel moderation is only possible for operators.
- Refresh tokens are temporary in demo mode; persist them for production!
# Login
TOKEN=$(curl -s -X POST http://localhost:8080/api/login -d '{"nick":"admin","password":"test123"}' -H 'Content-Type: application/json' | jq -r .token)
# Create channel
curl -X POST http://localhost:8080/api/channels -H "Authorization: Bearer $TOKEN" -d '{"name":"#test"}' -H 'Content-Type: application/json'
# Join channel
curl -X POST http://localhost:8080/api/channels/%23test/join -H "Authorization: Bearer $TOKEN"- Open
/api/oauth/login?provider=googleor/api/oauth/login?provider=githubin your browser - After login and consent, you will be redirected to
/api/oauth/callback?... - The API returns a JWT + refresh token
For questions and extensions, see the README or create an issue.