User API - tomassirio/wanderer-backend GitHub Wiki
The User API provides endpoints for creating and querying user information.
Base URL: http://localhost:8081/api/1/users
Create a new user in the system.
Endpoint: POST /api/1/users
Authentication: Not required (public endpoint)
{
"username": "string"
}| Field | Type | Required | Description |
|---|---|---|---|
| username | string | Yes | Unique username |
Status: 201 Created
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"username": "johndoe"
}curl -X POST http://localhost:8081/api/1/users \
-H "Content-Type: application/json" \
-d '{
"username": "johndoe"
}'Base URL: http://localhost:8082/api/1/users
Retrieve a specific user by their UUID.
Endpoint: GET /api/1/users/{id}
Authentication: Required (USER or ADMIN role)
| Parameter | Type | Description |
|---|---|---|
| id | UUID | User's unique identifier |
Status: 200 OK
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"username": "johndoe"
}curl -X GET http://localhost:8082/api/1/users/550e8400-e29b-41d4-a716-446655440000 \
-H "Authorization: Bearer <your-token>"Retrieve a user by their username.
Endpoint: GET /api/1/users/username/{username}
Authentication: Not required (public endpoint)
| Parameter | Type | Description |
|---|---|---|
| username | string | User's username |
Status: 200 OK
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"username": "johndoe"
}curl -X GET http://localhost:8082/api/1/users/username/johndoeRetrieve the profile of the currently authenticated user.
Endpoint: GET /api/1/users/me
Authentication: Required (USER or ADMIN role)
Status: 200 OK
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"username": "johndoe"
}curl -X GET http://localhost:8082/api/1/users/me \
-H "Authorization: Bearer <your-token>"User doesn't exist:
{
"timestamp": "2025-10-16T10:30:00.000Z",
"status": 404,
"error": "Not Found",
"message": "User not found with id: 550e8400-e29b-41d4-a716-446655440000",
"path": "/api/1/users/550e8400-e29b-41d4-a716-446655440000"
}Missing or invalid authentication token:
{
"timestamp": "2025-10-16T10:30:00.000Z",
"status": 401,
"error": "Unauthorized",
"message": "Full authentication is required to access this resource",
"path": "/api/1/users/550e8400-e29b-41d4-a716-446655440000"
}# 1. Register a new user (creates user and returns token)
RESPONSE=$(curl -X POST http://localhost:8083/api/1/auth/register \
-H "Content-Type: application/json" \
-d '{"username":"johndoe","password":"secret123"}')
# Extract token
TOKEN=$(echo $RESPONSE | jq -r '.token')
# 2. Get your own profile
curl -X GET http://localhost:8082/api/1/users/me \
-H "Authorization: Bearer $TOKEN"
# 3. Look up another user by username
curl -X GET http://localhost:8082/api/1/users/username/janedoe- Trip API - Create and manage trips
- Authentication API - Learn about authentication
- Getting Started Guide - Full workflow examples