Welcome to the API-repository — a personal playground of modern API design and development using Flask and FastAPI frameworks.
This project demonstrates how to build and consume RESTful APIs using Python and SQLite. It's ideal for beginners learning backend development, and for anyone interested in understanding the differences between Flask and FastAPI.
- ✅ RESTful API with both Flask and FastAPI
- 🗃️ Uses SQLite as a lightweight, file-based database
- 🧪 Endpoints for:
- Creating a drink
- Fetching all drinks
- Fetching a drink by ID
- Deleting a drink
- 📬 Tested via Postman
- 💡 SQLAlchemy ORM for database models
API-repository/
│
├── app/
│ ├── application.py # Flask-based API
│ ├── application_fastapi.py # FastAPI version of the same API
│ ├── instance/
│ │ └── drinks.db # SQLite DB file (auto-created)
│ └── consume_api.py # (Optional) API consumer script
│
├── requirements.txt
└── README.md- Python 3.9+
- Flask
- FastAPI
- SQLAlchemy
- SQLite
- Uvicorn (for FastAPI dev server)
- Postman (for testing)
git clone https://github.com/19ankita/API-repository.git
cd API-repository/apppython -m venv venv
# On Windows:
venv\Scripts\activate
# On Unix/Mac:
source venv/bin/activatepip install -r ../requirements.txtflask --app application.py --debug runVisit: http://127.0.0.1:5000/
uvicorn application_fastapi:app --reload| Method | Endpoint | Description |
|---|---|---|
| GET | / |
Hello World |
| GET | /drinks |
List all drinks |
| GET | /drinks/{id} |
Get a drink by ID |
| POST | /drinks |
Create a new drink |
| DELETE | /drinks/{id} |
Delete a drink |
- Difference between
from_attributesvsmodel_validatein Pydantic v2 - How FastAPI handles dependency injection with
Depends(get_db) - How to use SQLAlchemy with both frameworks
- Testing APIs with Postman and handling 500/404 errors