Users
1. Users
POST /auth/login
: This endpoint returns all users stored in the database as a JSON array. Each user object includes fields such asid
,username
,email
, androle
.
Base URL
/users
Authentication
All endpoints require Basic Authentication.
Endpoints
1.1. Get All Users
Retrieves a list of all users in the system.
Endpoint: GET /users
Authentication: Required
Responses:
200 OK
: Successfully retrieved the list of users[
{
"id": "string",
"username": "string",
"email": "string",
"role": "string"
// other user properties
}
]204 No Content
: No users found in the system401 Unauthorized
: Authentication failed
1.2. Get User by ID
Retrieves a specific user by their ID.
Endpoint: GET /users/{id}
Path Parameters:
id
(string, required): The unique identifier of the user
Authentication: Required
Responses:
200 OK
: Successfully retrieved the user{
"id": "string",
"username": "string",
"email": "string",
"role": "string"
// other user properties
}400 Bad Request
: Missing or malformed ID401 Unauthorized
: Authentication failed404 Not Found
: User with specified ID not found
1.3. Create User
Creates a new user in the system.
Endpoint: POST /users
Authentication: Required
Request Body:
{
"username": "string",
"email": "string",
"password": "string",
"role": "string"
// other user properties
}
Responses:
201 Created
: User added successfully400 Bad Request
: Invalid request body401 Unauthorized
: Authentication failed
1.4. Update User
Updates an existing user's information.
Endpoint: PUT /users/{id}
Path Parameters:
id
(string, required): The unique identifier of the user to update
Authentication: Required
Request Body:
{
"username": "string",
"email": "string",
"password": "string",
"role": "string"
// other user properties
}
Responses:
200 OK
: User updated successfully400 Bad Request
: Missing or malformed ID or invalid request body401 Unauthorized
: Authentication failed404 Not Found
: User with specified ID not found
1.5. Delete User
Deletes a user from the system.
Endpoint: DELETE /users/{id}
Path Parameters:
id
(string, required): The unique identifier of the user to delete
Authentication: Required
Responses:
204 No Content
: User deleted successfully400 Bad Request
: Missing or malformed ID401 Unauthorized
: Authentication failed404 Not Found
: User with specified ID not found
Implementation Details
The Users API is implemented in Users.kt
using Ktor framework with the following components:
UsersService
: Handles the business logic and database operations- Basic authentication is required for all endpoints
- SQLite database is used for persistence