A simple REST API for managing restaurant menu items and categories, built with Django REST Framework.
- RESTful API endpoints
- View all menu items
- Add a new menu item
- View all categories
- Add a new category
- Category and menu item relationship
- Pagination
- Ordering by price and inventory
- Search by category
- Data validation with serializers
- JSON and XML response formats
- Browsable API interface
- Token authentication with Djoser
- User registration and login
- Manager group management
- Delivery crew group management
- Cart API
- Orders API
- Automatic cart price calculation
- Order assignment and delivery status updates
- Python
- Django
- Django REST Framework
- djangorestframework-xml
- SQLite
- Djoser
- Token Authentication
| Method | Endpoint | Description |
|---|---|---|
| POST | /auth/users/ |
Register a new user |
| POST | /auth/token/login/ |
Login and get token |
| POST | /auth/token/logout/ |
Logout user |
| GET | /api/groups/manager/users/ |
View manager users |
| POST | /api/groups/manager/users/ |
Add user to Manager group |
| GET | /api/groups/delivery-crew/users/ |
View delivery crew users |
| POST | /api/groups/delivery-crew/users/ |
Add user to Delivery crew group |
| GET | /api/cart/menu-items/ |
View current user's cart |
| POST | /api/cart/menu-items/ |
Add item to cart |
| DELETE | /api/cart/menu-items/ |
Clear cart |
| GET | /api/orders/ |
View orders |
| POST | /api/orders/ |
Create order |
| GET | /api/orders/{id}/ |
View single order |
| PATCH | /api/orders/{id}/ |
Update order status or assign delivery crew |
Menu items are paginated.
Example:
/api/menu-items/?page=2
You can order menu items by price or inventory.
/api/menu-items/?ordering=price
/api/menu-items/?ordering=-price
/api/menu-items/?ordering=inventory
/api/menu-items/?ordering=-inventory
You can search menu items by category title.
/api/menu-items/?search=Desserts
- price must be at least 2
- inventory must be at least 0
{
"slug": "desserts",
"title": "Desserts"
}{
"title": "Grilled Fish",
"price": "8.50",
"inventory": 20,
"category_id": 3
}{
"id": 1,
"title": "Grilled Fish",
"price": "8.50",
"inventory": 20,
"category": {
"id": 3,
"title": "Appetizers"
}
}{
"menuitem": 1,
"quantity": 2
}
## Example Response
```json
{
"id": 1,
"user": 1,
"menuitem": 1,
"quantity": 2,
"unit_price": "6.00",
"price": "12.00"
}