|
| 1 | +# Reservation API |
| 2 | + |
| 3 | +## Overview |
| 4 | +The **Reservation API** is a RESTful service for managing room reservations. It allows users to create, retrieve, and delete reservations, register rooms, and check availability. Authentication is required for certain endpoints. |
| 5 | + |
| 6 | +## API Information |
| 7 | +- **Title:** Reservation API |
| 8 | +- **Version:** 0.0.1 |
| 9 | +- **Description:** Room booking API. |
| 10 | +- **Author:** [Marcel Fox](https://marcelfox.com/) |
| 11 | +- **License:** [MIT](https://mit-license.org/) |
| 12 | + |
| 13 | +## Local Development |
| 14 | +**For information regarding how to run the application locally, visit the [development section](./docs/DEVELOPMENT.md)** |
| 15 | + |
| 16 | +## Authentication |
| 17 | +The API uses **OAuth2 Password Bearer Token** authentication for protected endpoints. Users must obtain a token via the `/token/` endpoint. |
| 18 | + |
| 19 | +## Endpoints |
| 20 | + |
| 21 | +### Health Check |
| 22 | +- **GET /** |
| 23 | +- **Description:** Check API health status. |
| 24 | +- **Response:** `{ "message": "ok" }` |
| 25 | + |
| 26 | +### Authentication |
| 27 | +- **POST /token/** |
| 28 | +- **Description:** Authenticate user and obtain an access token. |
| 29 | +- **Request:** `application/x-www-form-urlencoded` (username & password required) |
| 30 | +- **Response:** Access token |
| 31 | + |
| 32 | +### Reservations |
| 33 | +- **POST /reservations/** |
| 34 | + - **Description:** Create a new reservation. |
| 35 | + - **Authentication:** Required |
| 36 | + - **Request Body:** `{ "user_name": "John Doe", "start_time": "2025-01-22T14:00:00", "end_time": "2025-01-22T16:00:00", "room_id": 1 }` |
| 37 | + - **Response:** Reservation details |
| 38 | + |
| 39 | +- **GET /reservations/** |
| 40 | + - **Description:** Retrieve a list of reservations. |
| 41 | + - **Query Parameters:** `skip` (default: 0), `limit` (default: 10) |
| 42 | + - **Response:** List of reservations |
| 43 | + |
| 44 | +- **DELETE /reservations/{id}** |
| 45 | + - **Description:** Remove a reservation by ID. |
| 46 | + - **Authentication:** Required |
| 47 | + |
| 48 | +### Rooms |
| 49 | +- **GET /rooms/** |
| 50 | + - **Description:** Retrieve a list of registered rooms. |
| 51 | + - **Query Parameters:** `skip` (default: 0), `limit` (default: 10) |
| 52 | + - **Response:** List of rooms |
| 53 | + |
| 54 | +- **POST /rooms/** |
| 55 | + - **Description:** Register a new room. |
| 56 | + - **Authentication:** Required |
| 57 | + - **Request Body:** `{ "name": "Conference Room", "capacity": 10, "location": "Floor 1" }` |
| 58 | + - **Response:** Room details |
| 59 | + |
| 60 | +- **GET /rooms/{id}/availability** |
| 61 | + - **Description:** Check room availability for a specific time range. |
| 62 | + - **Query Parameters:** `start_time`, `end_time` |
| 63 | + - **Response:** Availability status |
| 64 | + |
| 65 | +- **GET /rooms/{id}/reservation** |
| 66 | + - **Description:** List reservations for a specific room. |
| 67 | + - **Query Parameters:** `date` (optional), `skip` (default: 0), `limit` (default: 10) |
| 68 | + - **Response:** List of reservations for the room |
| 69 | + |
| 70 | +## Error Handling |
| 71 | +The API returns **422 Validation Error** for invalid requests. Errors include: |
| 72 | +- Missing required fields |
| 73 | +- Invalid data formats |
| 74 | +- Unauthorized access |
| 75 | + |
| 76 | +## License |
| 77 | +This project is licensed under the [MIT License](https://mit-license.org/). |
| 78 | + |
0 commit comments