Skip to content

Spike: FastAPI

  • Author: Ethaniel
  • Date: 2026-11-25
  • Timebox: 30 minutes
  • Why this timebox: I had already used FastAPI once but no longer remembered how to set it up, so 30 minutes was enough to get back to the shared target. Note: this prior experience makes this spike easier than one on a technology I have never used.
  • Time actually spent: 27 minutes

Where I was when the time ran out

  • Server on port 8080
  • GET /ping answers {"status":"ok"}
  • Port read from the PORT environment variable (through pydantic-settings, default 8080; also tested with PORT=9000)
  • OpenAPI page served (bonus): FastAPI serves /docs out of the box, no code needed
  • OAuth login (bonus): not started

What took the most time

  • Wrong documentation page. I started from the uv guide "Migrating an existing FastAPI project". It assumes FastAPI code already exists and only shows how to manage it with uv. The app code itself comes from the FastAPI "First Steps" tutorial.
  • Project name clash. uv init named the project fastapi, the same name as the dependency. Renaming it with a global find/replace also renamed the dependency and the import (faspoc), which broke the project.
  • Lock file stuck on an old version. After fixing the names, uv.lock still pinned fastapi==0.1.0 (2018). That version has no standard extra, so the fastapi command was not installed: error: Failed to spawn: fastapi. uv only printed a warning (The package fastapi==0.1.0 does not have an extra named standard). Fix: uv lock --upgrade-package fastapi.
  • Reading the port. I declared the Settings class but did not create the settings instance, and I first ran the app with fastapi dev, which ignores the if __name__ == "__main__" block and always listens on 127.0.0.1:8000. The app has to be started with python app/main.py for PORT to be used. I needed help on this step.

What it would take to go further

  • OAuth login with GitHub (for example with Authlib), the next bonus step.
  • Background jobs for AREA hooks: FastAPI has no built-in scheduler, a library is needed (APScheduler, ARQ or Celery). To evaluate.
  • Docker: the server already listens on 0.0.0.0, so only a Dockerfile using uv is missing.
  • Remove the leftover / route and the empty README.md created by uv init.

Running the spike

cd spikes/fastapi
uv sync
PORT=8080 uv run python app/main.py
curl http://localhost:8080/ping
# OpenAPI page: http://localhost:8080/docs

Impressions

  • Liked: it looks very simple. A route is a decorated function that returns a dict, and FastAPI turns it into JSON. The code is easy to read, and the imports are short and clear.
  • Liked: the FastAPI documentation is very well explained, and the documentation site has an AI chat assistant that was pleasant and helpful.
  • Liked: the OpenAPI page is generated automatically from the routes, which matters for AREA (the subject asks for a documented API).
  • Liked: configuration from environment variables is typed and validated with pydantic-settings, which will fit Docker Compose well.
  • Got in the way: there are two ways to start the server (fastapi dev and uvicorn.run), and only one of them reads our port. This was confusing at first.
  • Got in the way: most of the time was lost on uv (project name, lock file), not on FastAPI itself. uv fails silently with only a warning.
  • For AREA: OAuth and background jobs are not built in and need extra libraries; this is the main point to compare with the other backend spikes.