How-To Guides#
These guides are task-focused: each one shows how to accomplish a specific goal with FastAPI-Restly. If you are new to the framework, start with Getting Started, read Using RestView for the default CRUD contract, then use Build a Blog API for a complete multi-model example. Come back here when you have a concrete task.
Adopting and Modeling#
These guides cover bringing Restly into a codebase and defining the models and schemas it works from.
Adopt Restly beside existing FastAPI routes, then wire it into your sessions and models.
Lay out a growing application by subject, keep imports pointing one way, and compose views and models from one place each.
Define schemas with field aliases, write-only fields, and read-only computed fields.
Check foreign-key columns with MustExist and resolve relationships with IDRef or IDSchema, with a 404 on missing rows.
Shaping Requests and Responses#
These guides control what list endpoints accept and what your API returns, including errors.
Wrap successful responses in {data} envelopes and add list metadata such as
total counts, while keeping Restly’s handlers and serialization.
Load nested relationships for responses on reads and writes, extend the loaded
set, and resolve MissingGreenlet on async sessions.
Filter, sort, and paginate list endpoints using URL query parameters.
Bind the current user per request. Read the value in application code, column defaults, and tests.
Compose reusable SQLAlchemy predicates. Supply values through context members when applying the clauses to a statement.
Impose a replaceable clause on every read and every reference to a model. Use a default scope for row surfaces such as live and deleted records.
Learn the typed fr.exc exceptions to raise from overrides, the 422-vs-400
split, and app-wide error envelopes (problem+json).
Customizing Views#
These guides change what CRUD views do, from overriding a single method to sharing behaviour across many views.
Find the idiomatic answers for nested resources and sub-resources, a different list schema, restoring soft-deleted rows, webhook receivers, login flows, custom actions, and tenant scoping.
Serve a child resource under its parent, such as
/projects/{project_id}/tasks, with paging, filters, sort and every CRUD
route.
Use Python inheritance to share CRUD overrides, dependencies, URL prefixes, and access control across multiple views.
Put cross-cutting concerns (tenant scoping, soft delete, audit stamping) where they belong: structural fields on the model, verbs on view mixins.
Use IDSchema, optional view generics, and typed CRUD methods without
fighting the framework.
Operating and Testing#
These guides connect the API to the outside world: frontends, OpenAPI consumers, tests, and production deployment.
Use AsyncReactAdminView to get a backend that ra-data-simple-rest connects to out of the box.
Set per-view tags and responses, add metadata to custom routes, replace a
default CRUD route’s documented contract, and use x-resource-ref.
Start from a copy-paste conftest, work with savepoint-isolated fixtures, and consult the full fixture reference.
Configure a production engine, set up Alembic migrations, and follow an ASGI checklist.