Simple REST API for Parts Warehouse built with FastAPI and MongoDB.
| Method | Endpoint | Input | Action | Output |
|---|---|---|---|---|
| POST | /part | { "serial_number": [str], "name": [str], "description": [str], "category": [str], "quantity": [int], "price": [float], "location": { "room": [str], "bookcase": [str], "shelf": [int], "cuvette": [int], "column": [int], "row": [int] } } |
Add new part | Part |
| GET | /part/<part_id>/ | Get part by its ID | Part | |
| PUT | /part/<part_id>/ | Selected fields from Add part endpoint. Updating the 'location' field requires providing all subfields. |
Update part details | Part |
| DELETE | /part/<part_id>/ | Delete part | - | |
| GET | /part/search | Query params: -serial_number [str] -name [str] -description [str] -category [str] -min_quantity [int] -max_quantity [int] -min_price [float] -max_price [float] -room [str] -bookcase [str] -shelf [int] -cuvette [int] -column [int] -row [int] |
Search parts by params | List of parts that meet all provided criteria |
| GET | /category | Get all categories | List of categories | |
| POST | /category | { "name": [str], "parent_name": [str] } |
Add new category | Category |
| GET | /category/<category_id>/ | Get category by its ID | Category | |
| PUT | /category/<category_id>/ | Selected fields from Add category endpoint. | Update category details | Category |
| DELETE | /category/<category_id>/ | Delete category | - |
1. Clone the repository.
git clone https://github.com/bartekbednarz013/warehouse-API.git
2. Navigate to the 'warehouse-API' directory.
cd warehouse-API
3. Build the container.
docker compose build
4. Run the container.
docker compose up
5. Go to http://127.0.0.1:8000/docs to conveniently browse the API.