Skip to content

About

A simple Todo List REST API built with FastAPI

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FastAPI TodoList

A simple and efficient Todo List API built with FastAPI, featuring full CRUD operations for managing your tasks.

Features

  • ✅ Create new todos
  • 📝 Read/List all todos
  • ✏️ Update existing todos
  • 🗑️ Delete todos
  • 🚀 Fast and lightweight API
  • 📚 Interactive API documentation (Swagger UI)

Project Structure

TodoList/
├── main.py              # FastAPI application entry point
├── data/
│   └── fake_db.py       # In-memory database simulation
├── models/
│   └── todo.py          # Todo data models
├── routers/
│   └── todo.py          # Todo API routes
└── requirements.txt     # Project dependencies

Installation

  1. Clone the repository

    git clone https://github.com/alifallahrn/fastapi-todolist.git
    cd fastapi-todolist
  2. Create a virtual environment

    python -m venv venv
  3. Activate the virtual environment

    • Windows:
      venv\Scripts\activate
    • macOS/Linux:
      source venv/bin/activate
  4. Install dependencies

    pip install fastapi uvicorn

Usage

  1. Start the development server

    uvicorn main:app --reload
  2. Access the application

API Endpoints

Method Endpoint Description
GET /todos Get all todos
GET /todos/{todo_id} Get a specific todo
POST /todos Create a new todo
DELETE /todos/{todo_id} Delete a todo

Example Usage

Create a new todo

curl -X POST "http://localhost:8000/todos" \
     -H "Content-Type: application/json" \
     -d '{"task": "Learn FastAPI", "completed": false}'

Get all todos

curl -X GET "http://localhost:8000/todos"

Delete a todo

curl -X DELETE "http://localhost:8000/todos/1"

Data Model

The Todo model includes:

  • id: Unique identifier (auto-generated)
  • task: Todo title (required)
  • completed: Completion status (default: false)

Technologies Used

  • FastAPI: Modern, fast web framework for building APIs
  • Python 3.7+: Programming language
  • Pydantic: Data validation using Python type annotations
  • Uvicorn: ASGI server for running the application

Development

Running in Development Mode

uvicorn main:app --reload --host 127.0.0.1 --port 8000

Author

Ali Fallah


⭐ If you found this project helpful, please give it a star!

About

A simple Todo List REST API built with FastAPI

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages