A simple and efficient todo list API built with FastAPI
Project description
FastAPI Todo List Package
A simple and efficient todo list API built with FastAPI, featuring full CRUD operations with timestamps for creation, updates, and completion tracking. Packaged for easy distribution and deployment to feeds.
Features
- ✅ Add todo items with title and optional description
- ✅ Mark items as completed with automatic completion timestamps
- ✅ Remove items from the list
- ✅ View active todos with creation and modification dates
- ✅ View completed todos with completion dates
- ✅ Update existing todos (title, description, status)
Project Structure
fastapi/
├── pyproject.toml # Project metadata and dependencies
├── README.md # Project documentation
├── test_api.py # API testing script
├── tests/ # Test suite
└── src/
└── fastapi_todo_list/
├── __init__.py # Package initialization
├── main.py # FastAPI application and API endpoints
├── database.py # Database setup and models
├── schemas.py # Pydantic models for request/response
├── crud.py # Database operations
└── config.py # Configuration settings
🚀 Automated CI/CD
This repository includes automated workflows for building, testing, and publishing the FastAPI Todo List package.
🔄 Workflows
1. Continuous Integration (ci-fastapi-todo.yml)
- Triggers: Push/PR to main branches, changes in
python/web-frameworks/fastapi/ - Actions:
- Tests on Python 3.8-3.12 across Ubuntu/Windows/macOS
- Code linting with flake8
- Security scanning with safety & pip-audit
- Package build verification
2. Build, Tag & Publish (publish-fastapi-todo.yml)
- Triggers: Push to main/master branch, manual dispatch
- Actions:
- Version detection from
pyproject.toml - Automatic Git tagging
- Package building and testing
- PyPI publication
- GitHub Release creation
- Artifact upload
- Version detection from
🔐 Required Secrets & Configuration
For PyPI Publishing
Option A: Trusted Publishing (Recommended)
- Configure PyPI Trusted Publishing:
- Go to PyPI → Account Settings → Publishing
- Add publisher:
amalieshi/amalie_projects - Workflow:
publish-fastapi-todo.yml - Environment:
pypi
Option B: API Token
-
Create PyPI API Token:
- Go to PyPI → Account Settings → API Tokens
- Create token for
todolist_fastapiproject
-
Add GitHub Secret:
Repository Settings → Secrets → Actions → New repository secret Name: PYPI_API_TOKEN Value: pypi-your-token-here -
Update workflow (uncomment line in
publish-fastapi-todo.yml):password: ${{ secrets.PYPI_API_TOKEN }}
For GitHub Releases
- No configuration needed - uses
GITHUB_TOKENautomatically
🚀 How It Works
Automatic Publishing
- Edit version in
python/web-frameworks/fastapi/pyproject.toml - Commit & push to main branch
- Workflow automatically:
- Detects version change
- Creates Git tag (e.g.,
v1.0.1) - Builds package
- Publishes to PyPI
- Creates GitHub Release
Manual Publishing
- Go to:
Actions→Build, Tag, and Publish FastAPI Todo Package - Click:
Run workflow - Choose: Force publish option if needed
📋 Version Management
The workflows automatically read the version from:
# python/web-frameworks/fastapi/pyproject.toml
[project]
version = "1.0.1" # ← Update this to trigger new release
Version Bump Examples:
# Patch release (1.0.0 → 1.0.1)
sed -i 's/version = "1\.0\.0"/version = "1.0.1"/' python/web-frameworks/fastapi/pyproject.toml
# Minor release (1.0.1 → 1.1.0)
sed -i 's/version = "1\.0\.1"/version = "1.1.0"/' python/web-frameworks/fastapi/pyproject.toml
# Major release (1.1.0 → 2.0.0)
sed -i 's/version = "1\.1\.0"/version = "2.0.0"/' python/web-frameworks/fastapi/pyproject.toml
🎯 Workflow Status
✅ What's Configured
- Automated testing on multiple Python versions
- Cross-platform compatibility testing (Linux/Windows/macOS)
- Security scanning
- Automatic Git tagging
- PyPI publishing (with trusted publishing)
- GitHub Release creation
- Package artifact uploads
🔄 Manual Steps Required
- Set up PyPI trusted publishing (one-time setup)
- Update version in pyproject.toml (per release)
- Commit and push (triggers automatic publishing)
📊 Monitoring
- Check workflow status:
Actionstab in GitHub - View releases:
Releasestab in GitHub - Monitor PyPI: https://pypi.org/project/todolist_fastapi/
- View logs: Click on any workflow run for detailed logs
🛠️ Troubleshooting
Common Issues:
- Version already exists → Bump version in pyproject.toml
- PyPI authentication fails → Check trusted publishing or API token
- Tests fail → Fix code and re-push
- Security warnings → Update vulnerable dependencies
Debug Commands:
# Test locally before pushing
cd python/web-frameworks/fastapi
python -m pytest tests/
python -m build
twine check dist/*
Installation & Setup
Development Installation
-
Clone and install in development mode:
cd todolist-fastapi pip install -e .
-
Install with development dependencies:
pip install -e ".[dev]"
Package Installation from Feed
-
Install from PyPI or private feed:
pip install todolist_fastapi
-
Run using the installed command:
todo-api
Direct Development Run
-
Run from source:
python -m src.fastapi_todo_list.main
Or using uvicorn directly:
uvicorn src.fastapi_todo_list.main:app --reload --host 0.0.0.0 --port 8000
-
Access the API:
- API: http://localhost:8000
- Interactive docs: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
API Endpoints
Overview
GET /- Welcome message with endpoint overview
Todo Operations
GET /todos- Get all active (incomplete) todosGET /todos/completed- Get all completed todosGET /todos/all- Get all todos regardless of statusGET /todos/{id}- Get a specific todo by IDPOST /todos- Create a new todoPUT /todos/{id}- Update an existing todoDELETE /todos/{id}- Delete a todo
Building & Distribution
Build the Package
# Install build tools
pip install build twine
# Build the package
python -m build
This creates distribution files in the dist/ directory:
fastapi_todo_list-1.0.0-py3-none-any.whl(wheel)fastapi_todo_list-1.0.0.tar.gz(source distribution)
Publish to Feed
Option 1: PyPI (Public Registry)
# Test PyPI (recommended first)
twine upload --repository testpypi dist/*
# Production PyPI
twine upload dist/*
Option 2: GitHub Packages
# Configure GitHub token first
# Then upload to GitHub Packages
twine upload --repository-url https://upload.pypi.org/legacy/ dist/*
Option 3: GitHub Releases
# Manual upload to: https://github.com/amalieshi/amalie_projects/releases
# Or use GitHub CLI:
gh release create v1.0.0 dist/* --title "FastAPI Todo List v1.0.0"
Option 4: Private Feed/Repository
# Azure DevOps, JFrog Artifactory, Nexus, etc.
twine upload --repository-url https://your-private-feed-url dist/*
Your GitHub Repository Feed URLs:
- Releases:
https://github.com/amalieshi/amalie_projects/releases - Repository:
https://github.com/amalieshi/amalie_projects.git - Package Directory:
python/web-frameworks/fastapi/
Development Tools
The project includes configuration for development tools:
# Code formatting with black
black src/
# Type checking with mypy
mypy src/
# Linting with flake8
flake8 src/
# Run tests
pytest
Usage Examples
Create a new todo
curl -X POST "http://localhost:8000/todos" \
-H "Content-Type: application/json" \
-d '{"title": "Buy groceries", "description": "Milk, bread, and eggs"}'
Get all active todos
curl "http://localhost:8000/todos"
Mark a todo as completed
curl -X PUT "http://localhost:8000/todos/1" \
-H "Content-Type: application/json" \
-d '{"completed": true}'
Get completed todos
curl "http://localhost:8000/todos/completed"
Delete a todo
curl -X DELETE "http://localhost:8000/todos/1"
Data Model
Each todo item contains:
id: Unique identifier (auto-generated)title: Todo title (required)description: Optional descriptioncompleted: Boolean completion statuscreated_at: Creation timestampupdated_at: Last modification timestampcompleted_at: Completion timestamp (null if not completed)
Database
The application uses SQLite with SQLAlchemy ORM for data persistence. The database file (todos.db) is created automatically when the application starts.
Interactive Documentation
FastAPI automatically generates interactive API documentation:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
These interfaces allow you to test all endpoints directly from your browser.
Development
To extend the application:
- Add new database models in
database.py - Create corresponding Pydantic schemas in
schemas.py - Implement CRUD operations in
crud.py - Add new endpoints in
main.py
Technologies Used
- FastAPI: Modern, fast web framework for building APIs
- SQLAlchemy: SQL toolkit and ORM
- Pydantic: Data validation using Python type hints
- SQLite: Lightweight database engine
- Uvicorn: ASGI server for running the application
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file todolist_fastapi-1.0.2.tar.gz.
File metadata
- Download URL: todolist_fastapi-1.0.2.tar.gz
- Upload date:
- Size: 16.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c50163c5a10af7a4fa21335171c7a796e0590dd6085c3001bfb82477611b3f54
|
|
| MD5 |
eedd7aa4de72f74325f9b21561ad4b0e
|
|
| BLAKE2b-256 |
45486a5b34fca7d91eb6c76c2a1412e6ce5c8f050e2d9901dae62891ee90f2b3
|
Provenance
The following attestation bundles were made for todolist_fastapi-1.0.2.tar.gz:
Publisher:
publish-fastapi-todo.yml on amalieshi/amalie_projects
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
todolist_fastapi-1.0.2.tar.gz -
Subject digest:
c50163c5a10af7a4fa21335171c7a796e0590dd6085c3001bfb82477611b3f54 - Sigstore transparency entry: 1327925018
- Sigstore integration time:
-
Permalink:
amalieshi/amalie_projects@a5a63e12134fc573a47288bd7987d0680fcdfff4 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/amalieshi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-fastapi-todo.yml@a5a63e12134fc573a47288bd7987d0680fcdfff4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file todolist_fastapi-1.0.2-py3-none-any.whl.
File metadata
- Download URL: todolist_fastapi-1.0.2-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
239e4c5f33e9156b1d78e246516e205ad68d115c7843dbe0228d9ce266e09282
|
|
| MD5 |
5908f03b20e11ced31bcb0b51b1f0fa1
|
|
| BLAKE2b-256 |
40b387195114908825d59ea7f79a031e1ef65230c290395686563004a93b7c4d
|
Provenance
The following attestation bundles were made for todolist_fastapi-1.0.2-py3-none-any.whl:
Publisher:
publish-fastapi-todo.yml on amalieshi/amalie_projects
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
todolist_fastapi-1.0.2-py3-none-any.whl -
Subject digest:
239e4c5f33e9156b1d78e246516e205ad68d115c7843dbe0228d9ce266e09282 - Sigstore transparency entry: 1327925098
- Sigstore integration time:
-
Permalink:
amalieshi/amalie_projects@a5a63e12134fc573a47288bd7987d0680fcdfff4 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/amalieshi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-fastapi-todo.yml@a5a63e12134fc573a47288bd7987d0680fcdfff4 -
Trigger Event:
push
-
Statement type: