This page explains exactly which protocol to use for each action in the chat feature. Flutter and React teams should read this before integrating.
REST (HTTP) = load data that already exists (history, settings, members)
WebSocket (WSS) = send and receive real-time events (new messages, typing, deletions)
You use both together. This is how every major chat app works (WhatsApp, Slack, Telegram).
1. User opens a chatroom
β REST GET /rooms/{id}/messages/ β load last 50 messages
β WSS connect to ws://...room/{id}/ β open real-time connection
2. User is chatting
β New message arrives β WebSocket pushes it β append to bottom (NO REST CALL)
β User scrolls up β REST GET /messages/?page=2 β load older messages
β User sends message β WebSocket send {type: message.send, content: "..."}
β All other connected members receive it instantly via WebSocket
3. User closes the screen
β REST POST /rooms/{id}/read/ β mark as read
β WebSocket disconnects automatically
wss://api.fittrybe.com/ws/chat/room/{chatroom_id}/?token=JWT_ACCESS_TOKEN
wss://api.fittrybe.com/ws/chat/dm/{other_user_id}/?token=JWT_ACCESS_TOKEN
How to get the token: Call POST /api/v1/auth/login/ β copy data.access from the response.
Close codes:
4001 β No token or invalid token (re-authenticate)4003 β Not a member of this chatroom