Skip to main content

A light weight Python async framework with batteries included

Build Documentation Status image image image image

import dyne
from dyne.ext.auth import authenticate, BasicAuth
from dyne.ext.io.pydantic import input, output, expect
from dyne.ext.openapi import OpenAPI

app = dyne.App()

db = Alchemical(app)
api = OpenAPI(app)
basic_auth = BasicAuth()


@api.route("/book", methods=["POST"])
@authenticate(basic_auth, role="admin")
@input(BookCreateSchema, location="form")
@output(BookSchema, status_code=201)
@expect({401: "Unauthorized", 400: "Invalid file format"})
async def create_book(req, resp, *, data):
    """
    Create a new Book
    ---
    This endpoint allows admins to upload a book cover and metadata.
    """

    image = data.pop("image")
    await image.asave(f"uploads/{image.filename}") # image is already validated for extension, size and filename.

    session = await req.db
    book = await Book.create(**data, cover=image.filename)
    await session.commit()

    resp.obj = book

screenshot

Dyne is a modern async framework for APIs and applications, featuring built-in authentication, validation & serialization (Pydantic & Marshmallow), automatic OpenAPI, GraphQL support (Strawberry & Graphene), and async SQLAlchemy integration via Alchemical all with minimal first class configuration.

It delivers a production-ready ASGI foundation out of the box. It features an integrated static file server powered by (WhiteNoise <http://whitenoise.evans.io/en/stable/>_), Jinja2 templating for dynamic rendering, and a high-performance uvloop-based webserver—all optimized with automatic Gzip compression for reduced latency.

Documentation

See the documentation, for more details on features available in dyne.

Installation

Dyne uses optional dependencies (extras) to keep the core package lightweight.
This allows you to install only the features you need for your specific project.

Core Installation

To install the minimal ASGI core:

pip install dyne

Full Installation

To install all available features:

pip install "dyne[full]"

Installing Specific Feature Sets

Choose the bundle that fits your technology stack. Note that for most shells (like Zsh on macOS), you should wrap the package name in quotes to handle the brackets correctly.

Note: The use of brackets [] is required.

1. OpenAPI + (Request Validation & Response Serialization)

Enable automated OpenAPI (Swagger) documentation, request validation and response serialization using your preferred schema library:

With Pydantic

pip install "dyne[openapi_pydantic]"

With Marshmallow

pip install "dyne[openapi_marshmallow]"

2. GraphQL Engines

Integrate a native GraphQL interface and the GraphiQL IDE:

With Strawberry

pip install "dyne[graphql_strawberry]"

With Graphene

pip install "dyne[graphql_graphene]"

3. Database SQLAlchemy with Alchemical

Database SQLAlchemy support with Alchemical

pip install "dyne[sqlalchemy]"

4. Full Installation

To install all available features, including:

  • Both GraphQL engines
  • SQLAlchemy (Alchemical)
  • Both serialization engines
  • OpenAPI support
pip install "dyne[full]"

The Basic Idea

The primary concept here is to bring the niceties that are brought forth from both Flask and Falcon and unify them into a single framework, along with some new ideas I have. I also wanted to take some of the API primitives that are instilled in the Requests library and put them into a web framework. So, you'll find a lot of parallels here with Requests.

  • Setting resp.content sends back bytes.
  • Setting resp.text sends back unicode, while setting resp.html sends back HTML.
  • Setting resp.media sends back JSON/YAML (.text/.html/.content override this).
  • Setting resp.obj deserializes SQLAlchemy object(s) using Pydantic or Marshmallow schemas
  • Case-insensitive req.headers dict (from Requests directly).
  • resp.status_code, req.method, req.url, and other familiar friends.

Ideas

  • A built in testing client that uses the actual Requests you know and love.

  • A Pleasant Application Experience: Designed for developer happiness with a clean, intuitive, and consistent API.

  • Native ASGI Foundation: Built on the ASGI <https://asgi.readthedocs.io>_ standard for high-performance, fully asynchronous applications.

  • Expressive Routing: Declare routes using familiar f-string syntax <https://docs.python.org/3/whatsnew/3.6.html#pep-498-formatted-string-literals>_, improving readability and maintainability.

  • First-Class Configuration: Strongly typed, auto-casted configuration with .env auto-discovery, environment variable overrides, and validation at startup.

  • Database Integration: First-class SQLAlchemy support powered by Alchemical, providing clean session management, async-friendly patterns, and declarative configuration.

  • Seamless API Documentation: Fully self-generated OpenAPI documentation with an interactive UI and native support for both Pydantic and Marshmallow schemas.

  • Flexible View Layer: Support for function-based or class-based views (without mandatory inheritance) and a mutable response object that simplifies response handling.

  • GraphQL Support: Native integration with Strawberry and Graphene, including GraphiQL for interactive schema exploration.

  • Webhooks & Async Events: First-class webhook definition and documentation via the @webhook decorator, enabling clearly defined outbound callbacks and event-driven workflows.

  • Request & Response Lifecycle: Powerful decorators such as @input for validation, @output for serialization, and @expect for enforcing headers, cookies, and request metadata.

  • Bidirectional Communication: Built-in support for WebSockets alongside traditional HTTP and GraphQL endpoints.

  • Background Tasks: Easily offload long-running or blocking work using a built-in ThreadPoolExecutor.

  • Extensible Architecture: Mount any ASGI-compatible application at a subroute and serve single-page applications (SPAs) natively.

  • Integrated Security: First-class authentication support for BasicAuth, TokenAuth, and DigestAuth.

  • Advanced File Uploads: Robust file handling via a configurable FileField, enabling seamless binary data validation and storage integration for both Pydantic and Marshmallow schemas.

Metadata

Release files for dyne 2.0.5

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

Source distribution (sdist)

Source distribution for dyne 2.0.5
File Size Uploaded Provenance
dyne-2.0.5.tar.gz 9.5 MB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for dyne 2.0.5
File Interpreter ABI Platform
dyne-2.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 9.5 MB

Release files / dyne-2.0.5.tar.gz

Download URL dyne-2.0.5.tar.gz
Size 9.5 MB
Tags Source
SHA-256 checksum
How to use checksums
7b6e648447c95c573adee77b53465c9bfcd1c7cdb94156c7b40d4b2049ea6bec
BLAKE2b-256 checksum
How to use checksums
ff04c5e0392f3df5463394587fd88f0b3c955f1417ff0aeea5c777d567b3ab4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 1, 2026.

Transparency log

Release files / dyne-2.0.5-py3-none-any.whl

Download URL dyne-2.0.5-py3-none-any.whl
Size 56.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
733b542bd4fc3d16caf6b0c89b0227b782ec0d8bebdfaa1ee028bb8afac1c4b2
BLAKE2b-256 checksum
How to use checksums
512b893dd5e8c5ab8718bf17f93b78f0686ca34a946e129937d466ba06404a39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 1, 2026.

Transparency log

Security for dyne 2.0.5

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for dyne-2.0.5.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 1, 2026.

Transparency log

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.

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