Base URL
/api
Examples:
// Production https://your-domain.com/api // Local http://localhost/api
Root
GET
/api/
Returns a small welcome message.
Response 200
{ "message": "Welcome to the API" }
Users
GET
/api/users
Return list of users (selected columns).
Response 200
{ "users": [ { "user_id": 1, "email": "a@b.com", "name": "Alice", "role": "user", "birthdate": "1990-01-01", "created_at": "...", "notification_enabled": 1 } ] }
GET
/api/users/{id}
Return a single user by ID. 404 if not found.
Response 200
{ "user_id": 1, "email": "a@b.com", "name": "Alice", ... }
Response 404
{ "status": "error", "message": "Resource not found" }
POST
/api/users
Create a new user. Expect JSON body.
Request JSON
{ "email": "a@b.com", "name": "Alice", "password_hash": "<hash>", "birthdate": "1990-01-01" }
Response 201
{ "user_id": 123, "email": "a@b.com", "name": "Alice", "created_at": "..." }
Data resources (lists and single items)
The following resources implement two endpoints each: GET list and GET by id (/{id}). All are read-only in the current controllers.
GET
/api/daily_alcohol
Returns all rows from daily_alcohol.
GET
/api/daily_alcohol/{id}
Returns a single row from daily_alcohol by id.
GET
/api/daily_drinks
Returns all rows from daily_drinks.
GET
/api/daily_drinks/{id}
GET
/api/daily_drugs
GET /api/daily_drugs/{id}
GET /api/daily_entries
GET /api/daily_entries/{id}
GET /api/daily_food
GET /api/daily_food/{id}
GET /api/daily_movement
GET /api/daily_movement/{id}
GET /api/daily_scores
GET /api/daily_scores/{id}
GET /api/daily_sports
GET /api/daily_sports/{id}
GET /api/drink_types
GET /api/drink_types/{id}
GET /api/drug_types
GET /api/drug_types/{id}
GET /api/food_categories
GET /api/food_categories/{id}
GET /api/reset_history
GET /api/reset_history/{id}
GET /api/sleep
GET /api/sleep/{id}
GET /api/sports
GET /api/sports/{id}
GET /api/weekly_reports
GET /api/weekly_reports/{id}
GET /api/work_conditions
GET /api/work_conditions/{id}
Errors
Standard error responses use the project's response helper shape. Examples:
404 Not Found
{ "status": "error", "message": "Resource not found" }
500 Internal Server Error
{ "status": "error", "message": "An error occurred" }
Quick curl examples
# List users
curl -s http://localhost/api/users
# Get user with id 1
curl -s http://localhost/api/users/1
# Create user
curl -s -X POST http://localhost/api/users -H "Content-Type: application/json" -d '{"email":"a@b.com","name":"Alice","password_hash":"<hash>","birthdate":"1990-01-01"}'
# List daily_drinks
curl -s http://localhost/api/daily_drinks