Add automatic MessagePack content negotiation to ASGI applications with a single line of code for reduced bandwidth usage.
msgpack-asgi is a Python middleware that adds automatic MessagePack content negotiation to ASGI applications. It allows clients to send and receive data in the compact MessagePack format while the application internally uses JSON, reducing payload sizes and bandwidth usage without modifying existing code.
Backend developers building ASGI-based web applications (e.g., with FastAPI, Starlette, Quart) who need to optimize API bandwidth usage and support MessagePack for client communication.
Developers choose msgpack-asgi for its seamless integration—it requires just one line of code to enable MessagePack support, works with any ASGI framework, and provides automatic content negotiation without disrupting existing JSON-based application logic.
Drop-in MessagePack support for ASGI applications and frameworks
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Detects client Accept and Content-Type headers to seamlessly encode/decode MessagePack, allowing clients to use MessagePack without modifying application logic, as shown in the quickstart examples.
Works with any ASGI-compatible framework like Starlette, FastAPI, or Quart via a single middleware wrapper, minimizing integration effort as demonstrated in the code snippets.
Supports swapping default msgpack with faster alternatives like ormsgpack via packb and unpackb parameters, enabling performance tuning for specific use cases.
Requires just one line to add MessagePack support, reducing setup complexity and allowing quick adoption in existing JSON-based applications.
Adds significant processing cost due to double encoding/decoding (JSON internally, MessagePack externally), which the README explicitly warns against for CPU-sensitive applications.
Streaming support requires buffering entire request or response bodies in memory when allow_naive_streaming=True, leading to high RAM usage for large data, as noted in the advanced usage section.
Breaking changes across major versions necessitate strict version pinning and potential migration efforts, increasing maintenance burden, as highlighted in the installation instructions.