Welcome to the FastAPI Workshop! This repository is designed as a hands-on learning project to help you understand the fundamentals of building REST APIs using FastAPI.
Instead of providing a fully completed application, this project contains guided exercises and TODO sections that you will implement throughout the workshop.
By the end of this workshop, you will learn how to:
- Build a FastAPI application
- Create API endpoints
- Read data from a JSON file
- Use Path Parameters
- Use Query Parameters
- Handle HTTP Exceptions
- Create request models using Pydantic
- Perform CRUD (Create, Read, Update, Delete) operations
- Explore and test APIs using Swagger UI
- Python 3.10+
- FastAPI
- Uvicorn
- Pydantic
- JSON
fastapi-workshop/
│
├── main.py # FastAPI application
├── patients.json # Sample patient dataset
├── pyproject.toml # Project configuration
├── uv.lock # Dependency lock file
├── .gitignore
└── README.md
Before getting started, make sure you have:
- Python 3.10 or later
- Git
- VS Code
git clone https://github.com/AparnaBharani/fastapi-workshop.git
cd fastapi-workshoppython -m venv .venvActivate it:
.venv\Scripts\activatepython3 -m venv .venv
source .venv/bin/activateuv syncpip install fastapi "uvicorn[standard]"Using uv:
uv run uvicorn main:app --reloadOr using uvicorn directly:
uvicorn main:app --reloadIf everything is working correctly, you should see output similar to:
INFO: Uvicorn running on http://127.0.0.1:8000
FastAPI automatically generates interactive API documentation.
Swagger UI
http://127.0.0.1:8000/docs
ReDoc
http://127.0.0.1:8000/redoc
These pages allow you to explore and test your API directly from the browser.
This workshop is divided into small sections. Each section introduces a new FastAPI concept.
- Create a FastAPI application
- Run a FastAPI server
- Read data from a JSON file
- View all patients
- Path Parameters
- HTTP Exceptions
- Query Parameters
- Pydantic Models
- Create a Patient
- Update a Patient
- Delete a Patient
Patient records are stored in patients.json.
As you progress through the workshop, your API will read from and update this dataset.
Possible enhancements include:
- Data validation
- Database integration (SQLite/PostgreSQL)
- Authentication
- Environment variables
- Docker support
- Automated testing
- Logging
- Deployment to a cloud platform
Contributions, suggestions, and improvements are welcome.
If you discover an issue or have an idea for improving the workshop, feel free to open an issue or submit a pull request.