-
List Rooms
- Method: GET
- URL: /api/rooms/
- Headers:
- Authorization: Bearer <token>
- Response: List of room objects
[
{
"id": "uuid",
"name": "Room Name",
"owner": {"id": "uuid", "username": "owner_username"},
"members": [{"id": "uuid", "username": "member_username"}],
"is_private": false,
"created_at": "timestamp",
"updated_at": "timestamp"
}
]
-
Create Room
- Method: POST
- URL: /api/rooms/
- Headers:
- Authorization: Bearer <token>
- Content-Type: application/json
- Body:
{
"name": "New Room Name",
"is_private": false
}
- Response: Created room object
-
Get Room Details
- Method: GET
- URL: /api/rooms/<room_id>/
- Headers:
- Authorization: Bearer <token>
- Response: Room object
-
Update Room
- Method: PUT
- URL: /api/rooms/<room_id>/
- Headers:
- Authorization: Bearer <token>
- Content-Type: application/json
- Body:
{
"name": "Updated Room Name",
"is_private": true
}
- Response: Updated room object
-
Delete Room
- Method: DELETE
- URL: /api/rooms/<room_id>/
- Headers:
- Authorization: Bearer <token>
- Response: 204 No Content
-
Join Room
- Method: POST
- URL: /api/rooms/<room_id>/join-leave/
- Headers:
- Authorization: Bearer <token>
- Response:
{
"detail": "Joined the room successfully."
}
-
Leave Room
- Method: DELETE
- URL: /api/rooms/<room_id>/join-leave/
- Headers:
- Authorization: Bearer <token>
- Response:
{
"detail": "Left the room successfully."
}
-
List Room Messages
- Method: GET
- URL: /api/rooms/<room_id>/messages/
- Headers:
- Authorization: Bearer <token>
- Response: List of message objects
[
{
"id": "uuid",
"room": "room_uuid",
"sender": {"id": "uuid", "username": "sender_username"},
"message": "Message content",
"file": "file_url_if_any",
"created_at": "timestamp",
"updated_at": "timestamp"
}
]
-
Send Message
- Method: POST
- URL: /api/rooms/<room_id>/messages/
- Headers:
- Authorization: Bearer <token>
- Content-Type: application/json
- Body:
{
"message": "New message content"
}
- Response: Created message object
-
Upload File Message
- Method: POST
- URL: /api/rooms/<room_id>/upload/
- Headers:
- Authorization: Bearer <token>
- Content-Type: multipart/form-data
- Body:
- Response: Created message object with file information
-
Create Private Room
- Method: POST
- URL: /api/rooms/private/<username>/
- Headers:
- Authorization: Bearer <token>
- Response: Created or existing private room object
-
Create Group Chat
- Method: POST
- URL: /api/rooms/group/
- Headers:
- Authorization: Bearer <token>
- Content-Type: application/json
- Body:
{
"name": "Group Chat Name",
"members": ["username1", "username2"]
}
- Response: Created group chat room object
This documentation covers the basic CRUD operations for rooms and messages, as well as joining/leaving rooms and handling file uploads.