Minimal REST API for a personal task list.
- Python 3.11
- FastAPI
- Pydantic
- SQLite
- CRUD for categories, statuses, and items
- Sign in at
/api/v1/auth/signinreturns an access token of type bearer - Refresh at
/api/v1/auth/refreshsets a new access token - Database schema is created at startup and can run many times safely
pip install -r requirements.txtCreate a file named .env in the project root.
PROJECT_NAME=ToDo API
API_V1_STR=/api/v1
DATABASE_PATH=/data/app.db
ADMIN_EMAIL=admin@example.com
ADMIN_PASSWORD=changeme
ACCESS_TOKEN_EXPIRE_MINUTES=30
REFRESH_TOKEN_EXPIRE_MINUTES=43200
fastapi dev app/main.pyOpen docs at http://localhost:8000/docs
docker compose build
docker compose upSQLite data is stored in the named volume app_data so it persists across restarts.
Base prefix: /api/v1
Auth
POST /auth/signinaccepts form data with fieldsusernameandpasswordor JSON withemailandpassworddepending on configurationPOST /auth/refreshreads the refresh token from cookie and returns a new access tokenPOST /auth/signoutclears the refresh token cookie
Core
GET /usersand other user routesGET /itemsand item routesGET /categoriesand category routesGET /statusesand status routes
- Initialization uses
CREATE TABLE IF NOT EXISTSand inserts withON CONFLICT DO NOTHING - You can switch to a versioned schema using
PRAGMA user_versionfor future migrations - The refresh token is stored in an HTTP only cookie