Simple Todo API

A simple Todo API built with FastAPI and SQLite.

Features

  • CRUD operations for Todo items
  • Filtering and pagination for todos list
  • Health check endpoint
  • OpenAPI documentation

Requirements

  • Python 3.8+
  • FastAPI
  • SQLAlchemy
  • Alembic
  • SQLite
  • Uvicorn

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/simpletodoapi.git
cd simpletodoapi
  1. Install the dependencies:
pip install -r requirements.txt
  1. Apply migrations:
alembic upgrade head

Running the Application

Start the application with:

uvicorn main:app --reload

The API will be available at http://localhost:8000

API Documentation

Once the application is running, you can access the interactive API documentation at:

  • Swagger UI: http://localhost:8000/docs
  • ReDoc: http://localhost:8000/redoc

API Endpoints

Todos

  • GET /api/todos - List all todos with optional filtering and pagination
  • POST /api/todos - Create a new todo
  • GET /api/todos/{todo_id} - Get a specific todo
  • PUT /api/todos/{todo_id} - Update a todo
  • DELETE /api/todos/{todo_id} - Delete a todo

Health

  • GET /health - Check API health status

Examples

Create a Todo

curl -X 'POST' \
  'http://localhost:8000/api/todos' \
  -H 'Content-Type: application/json' \
  -d '{
  "title": "Buy groceries",
  "description": "Milk, eggs, bread",
  "completed": false
}'

List Todos

curl -X 'GET' 'http://localhost:8000/api/todos'

Get a specific Todo

curl -X 'GET' 'http://localhost:8000/api/todos/1'

Update a Todo

curl -X 'PUT' \
  'http://localhost:8000/api/todos/1' \
  -H 'Content-Type: application/json' \
  -d '{
  "completed": true
}'

Delete a Todo

curl -X 'DELETE' 'http://localhost:8000/api/todos/1'

License

MIT

Description
Project: Simple Todo API
Readme 38 KiB
Languages
Python 95.2%
Mako 4.8%