Skip to main content

Muffin‑REST

Muffin‑REST simplifies building RESTful APIs with Muffin by offering:

  • Declarative API class with resource registration
  • Built-in filtering, sorting, pagination, and search
  • Support for:
  • Swagger/OpenAPI autodocumentation
  • Works with asyncio, Trio, and Curio

Tests Status PyPI Version Python Versions

Requirements

  • Python >= 3.11
  • Trio requires Peewee backend

Installation

Install core package:

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)

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

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

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:

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 (Kirill Klenov)

License

Licensed under the MIT license.

Metadata

Release files for muffin-rest 14.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for muffin-rest 14.2.1
File Size Uploaded Provenance
muffin_rest-14.2.1.tar.gz 26.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for muffin-rest 14.2.1
File Interpreter ABI Platform
muffin_rest-14.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 64.2 kB

Release files / muffin_rest-14.2.1.tar.gz

Download URL muffin_rest-14.2.1.tar.gz
Size 26.7 kB
Tags Source
SHA-256 checksum
How to use checksums
5864f046f2d8f10accd5b4bd7f06e9bdcd0ff4f9b7c046bfcd4e82a3a6c5f701
BLAKE2b-256 checksum
How to use checksums
fa3679c4a16cb8fe9ad1bc0d403a93dfdb0ffbdc42ccd251b3c9f777167b0ec6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / muffin_rest-14.2.1-py3-none-any.whl

Download URL muffin_rest-14.2.1-py3-none-any.whl
Size 37.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d6d6abd08c1dd153a542e8e85b3407d10e594b29ddb5509ecd50731fe8d5417c
BLAKE2b-256 checksum
How to use checksums
6ff719e2c45b67e424987a8bd09a8dcf201b045ca353f7fc97e4ad59de3237f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for muffin-rest 14.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

14.2.1 This release

2 release files No provenance

0.0.1

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page