Muffin-REST documentation¶
Muffin-REST adds REST resources to Muffin.
A handler declares a model or table in Meta; the library builds list and
detail routes, query handling, validation, and an OpenAPI spec around it.
The docs are split by the question you are trying to answer.
Start here¶
- Tutorial: build a working API in ten minutes.
- Handlers and lifecycle: what happens on a request and where to plug in your own code.
- Backends: pick Peewee, SQLAlchemy Core, or MongoDB and see the differences.
- Writing a backend: add support for another storage system.
Reference¶
- Querying:
where,sort,limit,offset, field selection. - Schemas: generated schemas, validation, custom fields.
- OpenAPI: spec generation, docstrings, authorization.
- Errors: error bodies and status codes.
- API reference: classes, options, and hook signatures.
Practice¶
- Cookbook: auth, scoping, soft delete, custom filters, file upload, tests.
- Development: local setup, tests, examples, release.
How the pieces fit¶
Application
└── API routing, auth, OpenAPI
└── RESTHandler request lifecycle, CRUD, query handling
├── PWRESTHandler
├── SARESTHandler
└── MongoRESTHandler
API owns the router and the authorization callback. A RESTHandler subclass
owns one resource. Backend handlers implement the storage-specific parts:
loading a collection, loading one resource, pagination, saving, and deleting.
The core is muffin_rest.handler.RESTBase. Read it once; every guide refers to
its hooks.