Guides/ Packs

Create a REST API

Create a REST API with FastAPI, PostgreSQL, SQLAlchemy, Pydantic, and Ruff using the Better Fullstack REST API pack.

Updated 2026-05-21

rest-apifastapipythonsqlalchemypydantic

Use the REST API pack when you need a focused backend service: routes, validation, persistence, and linting without a frontend.

Generate the REST API starter

Open the REST API pack in the Stack Builder, or run:

bun create better-fullstack@latest my-rest-api \
  --ecosystem python \
  --python-web-framework fastapi \
  --python-orm sqlalchemy \
  --python-validation pydantic \
  --python-quality ruff

What the pack includes

  • FastAPI for REST endpoints and OpenAPI docs.
  • SQLAlchemy for database models and queries.
  • Pydantic for request and response validation.
  • Ruff for Python linting and formatting.
  • A small project layout that is easy to deploy as an API service.

First things to customize

  1. Replace sample resources with your domain models.
  2. Add authentication if the API is not public.
  3. Decide which routes are read-only and which mutate data.
  4. Add integration tests for the routes that define your contract.

When this is the right pack

Choose this for public APIs, service backends, internal platform APIs, webhook receivers, and products where a frontend will be built separately.

For a stack-level walkthrough, read FastAPI with PostgreSQL and SQLAlchemy.