Community API Documentation¶
Table of Contents¶
Introduction¶
This document provides detailed API documentation for the community. It includes endpoints for managing messages, user-group associations, friend connections, and retrieving user information.
Chat Controller¶
Base URL: /chat
| Method | Endpoint | Description |
|---|---|---|
| GET | /retrieveusername/{userId} |
Retrieves the username for the given user ID. |
GET /retrieveusername/{userId}
- Path Variable: userId (Long) – ID of the user.
- Response: Username as a plain string.
- Example:
Message Controller¶
Base URL: /api/messages
| Method | Endpoint | Description |
|---|---|---|
| GET | /getall |
Retrieves all messages, optionally filtered by date. |
| POST | /send |
Sends and saves a new message. |
GET /getall
- Query Parameter (optional): since (String) – Filter messages created after a given date.
- Response: List of message objects.
POST /send
- Body: Message object.
- Response: Saved Message object.
UserHasGroup Controller¶
Base URL: /api/user-group
| Method | Endpoint | Description |
|---|---|---|
| POST | /add |
Adds a user to a group. |
| POST | /add-multiple |
Adds multiple users to a group. |
| GET | /getall/{username} |
Retrieves all group chats for a specific username. |
POST /add
- Body: UserGroupRequest object.
- Response: UserHasGroup object.
POST /add-multiple
- Body: MultiUserGroupRequest object.
- Response: String indicating success or error message.
GET /getall/{username}
- Path Variable: username (String) – Username of the user.
- Response: List of GroupChat objects.
Friends Controller¶
Base URL: /friends
| Method | Endpoint | Description |
|---|---|---|
| GET | /getfriends-by-username/{username} |
Retrieves the list of friend usernames for a given user. |
| POST | /addfriends |
Adds a new friend connection between two users. |
GET /getfriends-by-username/{username}
- Path Variable: username (String) – Username to retrieve friends for.
- Response: List of friend usernames.
POST /addfriends
- Body: AddFriendRequest object.
- Response: Friends object representing the new connection.