# Muffin‑REST
**Muffin‑REST** simplifies building RESTful APIs with [Muffin](https://github.com/klen/muffin) by offering:
- Declarative `API` class with resource registration
- Built-in filtering, sorting, pagination, and search
- Support for:
- [Peewee ORM](http://docs.peewee-orm.com/en/latest/) via `PeeweeEndpoint`
- [SQLAlchemy Core](https://docs.sqlalchemy.org/en/14/core/) via `SAEndpoint`
- [MongoDB](https://www.mongodb.com/) via `MongoEndpoint`
- [Swagger/OpenAPI](https://swagger.io/) autodocumentation
- Works with asyncio, Trio, and Curio
[](https://github.com/klen/muffin-rest/actions)
[](https://pypi.org/project/muffin-rest/)
[](https://pypi.org/project/muffin-rest/)
## Requirements
- Python >= 3.10
- Trio requires Peewee backend
## Installation
Install core package:
```bash
pip install muffin-rest
```
Add optional backend support:
- SQLAlchemy Core: `pip install muffin-rest[sqlalchemy]`
- Peewee ORM: `pip install muffin-rest[peewee]`
- YAML support for Swagger: `pip install muffin-rest[yaml]`
## Quickstart (Peewee example)
```python
from muffin import Application
from muffin_rest import API
from muffin_rest.peewee import PeeweeEndpoint
from models import User # your Peewee model
app = Application("myapp")
api = API(title="User Service", version="1.0")
@api.route
class UsersEndpoint(PeeweeEndpoint):
class Meta:
model = User
lookup_field = "id"
filters = ["name", "email"]
ordering = ["-created_at"]
api.setup(app, prefix="/api", swagger=True)
```
Endpoints available:
- `GET /api/users/` — list with pagination, search, filtering
- `POST /api/users/` — create
- `GET /api/users/{id}/` — retrieve
- `PUT /api/users/{id}/` — replace
- `PATCH /api/users/{id}/` — update
- `DELETE /api/users/{id}/` — remove
- Docs: `/api/docs/`, OpenAPI spec: `/api/openapi.json`
## Usage with SQLAlchemy
```python
from muffin_rest import API
from muffin_rest.sqlalchemy import SAEndpoint
from models import my_table, db_engine
api = API()
@api.route
class MySAEndpoint(SAEndpoint):
class Meta:
table = my_table
database = db_engine
api.setup(app)
```
## Usage with MongoDB
```python
from muffin_rest import API
from muffin_rest.mongo import MongoEndpoint
from models import mongo_collection
api = API()
@api.route
class MyMongoEndpoint(MongoEndpoint):
class Meta:
collection = mongo_collection
api.setup(app)
```
## Advanced Configuration
Customize Swagger and routes via constructor:
```python
api = API(
title="Service API",
version="2.1",
swagger_ui=True,
openapi_path="/api/openapi.json",
docs_path="/api/docs/"
)
```
## Contributing & Examples
- See `examples/` for live application demos
- Tests in `tests/` focus on filtering, pagination, status codes
- Check `CHANGELOG.md` for latest changes
## Bug Tracker
Report bugs or request features:
https://github.com/klen/muffin-rest/issues
## Contributing
Repo: https://github.com/klen/muffin-rest
Pull requests, example additions, docs improvements welcome!
## Contributors
- [klen](https://github.com/klen) (Kirill Klenov)
## License
Licensed under the [MIT license](http://opensource.org/licenses/MIT).
Raw data
{
"_id": null,
"home_page": "https://github.com/klen/muffin-rest",
"name": "muffin-rest",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": null,
"keywords": "rest, api, muffin, asgi, asyncio, trio",
"author": "Kirill Klenov",
"author_email": "horneds@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/e2/b5/5d4571c3c89c87a1247e94cc0d61dc9f61c4208b2c5a932393c6e45e6061/muffin_rest-13.0.2.tar.gz",
"platform": null,
"description": "# Muffin\u2011REST\n\n**Muffin\u2011REST** simplifies building RESTful APIs with [Muffin](https://github.com/klen/muffin) by offering:\n\n- Declarative `API` class with resource registration\n- Built-in filtering, sorting, pagination, and search\n- Support for:\n - [Peewee ORM](http://docs.peewee-orm.com/en/latest/) via `PeeweeEndpoint`\n - [SQLAlchemy Core](https://docs.sqlalchemy.org/en/14/core/) via `SAEndpoint`\n - [MongoDB](https://www.mongodb.com/) via `MongoEndpoint`\n- [Swagger/OpenAPI](https://swagger.io/) autodocumentation\n- Works with asyncio, Trio, and Curio\n\n[](https://github.com/klen/muffin-rest/actions)\n[](https://pypi.org/project/muffin-rest/)\n[](https://pypi.org/project/muffin-rest/)\n\n## Requirements\n\n- Python >= 3.10\n- Trio requires Peewee backend\n\n## Installation\n\nInstall core package:\n\n```bash\npip install muffin-rest\n```\n\nAdd optional backend support:\n\n- SQLAlchemy Core: `pip install muffin-rest[sqlalchemy]`\n- Peewee ORM: `pip install muffin-rest[peewee]`\n- YAML support for Swagger: `pip install muffin-rest[yaml]`\n\n## Quickstart (Peewee example)\n\n```python\nfrom muffin import Application\nfrom muffin_rest import API\nfrom muffin_rest.peewee import PeeweeEndpoint\nfrom models import User # your Peewee model\n\napp = Application(\"myapp\")\napi = API(title=\"User Service\", version=\"1.0\")\n\n@api.route\nclass UsersEndpoint(PeeweeEndpoint):\n class Meta:\n model = User\n lookup_field = \"id\"\n filters = [\"name\", \"email\"]\n ordering = [\"-created_at\"]\n\napi.setup(app, prefix=\"/api\", swagger=True)\n```\n\nEndpoints available:\n\n- `GET /api/users/` \u2014 list with pagination, search, filtering\n- `POST /api/users/` \u2014 create\n- `GET /api/users/{id}/` \u2014 retrieve\n- `PUT /api/users/{id}/` \u2014 replace\n- `PATCH /api/users/{id}/` \u2014 update\n- `DELETE /api/users/{id}/` \u2014 remove\n- Docs: `/api/docs/`, OpenAPI spec: `/api/openapi.json`\n\n## Usage with SQLAlchemy\n\n```python\nfrom muffin_rest import API\nfrom muffin_rest.sqlalchemy import SAEndpoint\nfrom models import my_table, db_engine\n\napi = API()\n@api.route\nclass MySAEndpoint(SAEndpoint):\n class Meta:\n table = my_table\n database = db_engine\n\napi.setup(app)\n```\n\n## Usage with MongoDB\n\n```python\nfrom muffin_rest import API\nfrom muffin_rest.mongo import MongoEndpoint\nfrom models import mongo_collection\n\napi = API()\n@api.route\nclass MyMongoEndpoint(MongoEndpoint):\n class Meta:\n collection = mongo_collection\n\napi.setup(app)\n```\n\n## Advanced Configuration\n\nCustomize Swagger and routes via constructor:\n\n```python\napi = API(\n title=\"Service API\",\n version=\"2.1\",\n swagger_ui=True,\n openapi_path=\"/api/openapi.json\",\n docs_path=\"/api/docs/\"\n)\n```\n\n## Contributing & Examples\n\n- See `examples/` for live application demos\n- Tests in `tests/` focus on filtering, pagination, status codes\n- Check `CHANGELOG.md` for latest changes\n\n## Bug Tracker\n\nReport bugs or request features:\nhttps://github.com/klen/muffin-rest/issues\n\n## Contributing\n\nRepo: https://github.com/klen/muffin-rest\nPull requests, example additions, docs improvements welcome!\n\n## Contributors\n\n- [klen](https://github.com/klen) (Kirill Klenov)\n\n## License\n\nLicensed under the [MIT license](http://opensource.org/licenses/MIT).\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "The package provides enhanced support for writing REST APIs with Muffin framework",
"version": "13.0.2",
"project_urls": {
"Homepage": "https://github.com/klen/muffin-rest",
"Repository": "https://github.com/klen/muffin-rest"
},
"split_keywords": [
"rest",
" api",
" muffin",
" asgi",
" asyncio",
" trio"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "25a67961ee0b3c76558b5c9c6f5f07af631f153c67e1c48027b3c021148db9d0",
"md5": "d58b34bcbc4f66730915c4993200def4",
"sha256": "8b9d18582f1a14fe2c724353e69c621fe03b2120a3728e9ff48badeb0e375ffe"
},
"downloads": -1,
"filename": "muffin_rest-13.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d58b34bcbc4f66730915c4993200def4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 36654,
"upload_time": "2025-08-12T12:40:36",
"upload_time_iso_8601": "2025-08-12T12:40:36.418174Z",
"url": "https://files.pythonhosted.org/packages/25/a6/7961ee0b3c76558b5c9c6f5f07af631f153c67e1c48027b3c021148db9d0/muffin_rest-13.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e2b55d4571c3c89c87a1247e94cc0d61dc9f61c4208b2c5a932393c6e45e6061",
"md5": "fae43e9a3dffd24cc322623289de46d9",
"sha256": "f6c96e4319e2d3f05874bc1788f6ae7e4dae2fafe209ec69ac9f0537dddc2be8"
},
"downloads": -1,
"filename": "muffin_rest-13.0.2.tar.gz",
"has_sig": false,
"md5_digest": "fae43e9a3dffd24cc322623289de46d9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 24757,
"upload_time": "2025-08-12T12:40:37",
"upload_time_iso_8601": "2025-08-12T12:40:37.858781Z",
"url": "https://files.pythonhosted.org/packages/e2/b5/5d4571c3c89c87a1247e94cc0d61dc9f61c4208b2c5a932393c6e45e6061/muffin_rest-13.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-12 12:40:37",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "klen",
"github_project": "muffin-rest",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "muffin-rest"
}