Build a Simple CRUD API Using FastAPI (Python)

Build a Simple CRUD API Using FastAPI (Python)

Tinker

Here is how to create a basic CRUD (Create, Read, Update, Delete) API using FastAPI with in-memory storage (no database required for now).


Main target

Create a simple app with FastAPI to manage a list of items with the following features:

+ Create a new item

+ Get all items

+ Get a single item by ID

+ Update an item

+ Delete an item


Implementation steps

pip install fastapi uvicorn

Create main.py
CRUD with FastAPI

uvicorn main:app --reload

Open your browser: http://127.0.0.1:8000/docs, you’ll see a Swagger UI where you can test all the routes (Create, Read, Update, Delete).


Deploy on Render

Push your FastAPI code to GitHub.

Go to render.com and click "New Web Service".

Connect your GitHub repo.

Set these deploy settings:

  1. Build Command:pip install -r requirements.txt
  2. Start Command:uvicorn main:app --host 0.0.0.0 --port 10000

Set Python version and wait for deploy.

You’ll get a public HTTPS URL like:
https://fastapi-crud-example.onrender.com/docs


Project structure overview

Project structure
requirements.txt
Procfile (for Render)
README.md