This repository contains a basic API built with FastAPI, a modern Python framework for building high-performance web applications and APIs.
The project demonstrates how to set up a FastAPI app, run it locally, and explore the automatically generated Swagger UI.
- Built with FastAPI (Python 3.12+)
- Automatic interactive API docs using Swagger UI (
/docs) - Type-safe request/response validation with Pydantic
- Runs on Uvicorn ASGI server
D:\Projects_Components\FastAPI\Basic_API
│── main.py # FastAPI application entry point
│── requirements.txt # Dependencies
│── README.md # Project documentation
python -m venv myenv- PowerShell:
.\myenv\Scripts\Activate.ps1
- Command Prompt (cmd.exe):
myenv\Scripts\activate.bat
pip install fastapi uvicornuvicorn main:app --reload- Base URL:
http://127.0.0.1:8000 - Swagger UI (interactive docs):
http://127.0.0.1:8000/docs - ReDoc docs:
http://127.0.0.1:8000/redoc
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def read_root():
return {"message": "Hello, FastAPI!"}
@app.get("/items/{item_id}")
def read_item(item_id: int):
return {"item_id": item_id}- This project is for learning purposes and exploring FastAPI basics.
- You can extend it with database integration, authentication, or more complex routes.
- The auto-generated docs are available at
/docsonce the server is running.