# Python FastAPI API

A FastAPI todo service gives you generated API docs, request validation, a health check, and routes for listing or adding todos. Tokay runs it at a live URL as one Web Service.

Use this example when your Python project already looks like a normal FastAPI app. Tokay reads the source and requirements, then handles the running service around them.

## Facts

- Runtime: Python
- Framework: FastAPI
- Service types: Web Service
- Resources: None
- Required secrets: None

## What it does

Open `/docs` to explore every route and send requests from FastAPI's interactive page.

The todo list begins with three samples. Add a nonempty title and the API returns a new item. Empty or oversized titles are rejected before they reach the list.

The root response shows the Python version. `/health` returns a compact liveness result.

## Deploy it

Bring this folder to Tokay any way you like. Paste or upload it in the dashboard, push it with git, or hand it to your AI agent along with [our agent instructions](https://app.tokay.io/llms.txt). Tokay figures out the rest.

Working in Claude, ChatGPT, VS Code, or another MCP client? Connect the [Tokay MCP server](https://tokay.io/docs/platform-mcp) and ask your agent to deploy this example. It signs in through your browser, so there is no token to paste.

New to Tokay? The [getting started guide](https://tokay.io/getting-started) walks you through your first deploy.

## Try it

Set your live URL, create one todo, then confirm FastAPI saved it in the running process.

```sh
export APP_URL="https://your-app.tokay.app"
curl -X POST "$APP_URL/todos" \
  -H 'Content-Type: application/json' \
  -d '{"title":"ship the next thing"}'
curl "$APP_URL/todos"
```

The response list now includes your todo. Restart or deploy again and the samples return because this small starter has no database.

## How it works

Wondering how the docs and validation appear? FastAPI and Pydantic generate them from the route and model definitions in `main.py`. Tokay installs the requirements and starts that app without changing its structure.

## Secrets

This starter has no secrets. Every endpoint is ready to try after deployment.

## Grow from here

Try the [AI research queue](/examples/python-fastapi-postgres-ai-research-queue) when your FastAPI app needs saved jobs and a Background Worker.

## Source files

- [main.py](https://tokay.io/examples/src/python-fastapi-api/main.py)
- [requirements.txt](https://tokay.io/examples/src/python-fastapi-api/requirements.txt)

## Download and source

- [Download the complete project](https://tokay.io/examples/downloads/python-fastapi-api.zip)
- Last updated: 2026-07-31
- Example revision: `52c7b7f`
- [View this revision on GitHub](https://github.com/tokayio/tokay-examples/tree/52c7b7ffd52e157375b08f1f11ff4fbe6c498642/python-fastapi-api)
- [Deploy a FastAPI app](https://tokay.io/use-cases/deploy-fastapi)
