Skip to main content
Change of provenance

The repository or configuration that created this release differ from a previous release. View details.

Dinja Python Client

HTTP client for the Dinja MDX rendering service.

Installation

pip install dinja

Async Support (Optional)

For async support, install with your preferred HTTP library:

pip install dinja[httpx]    # recommended
pip install dinja[aiohttp]  # alternative

Requirements

Start the Dinja service via Docker:

docker pull ghcr.io/hlop3z/dinja:latest
docker run -p 8080:8080 ghcr.io/hlop3z/dinja:latest

Sync Usage

from dinja import Renderer

# Connect to the service
renderer = Renderer("http://localhost:8080")

# Check health
if renderer.health():
    print("Service is running!")

# Render MDX to HTML
result = renderer.html(
    views={"page.mdx": "# Hello World\n\nThis is **bold** text."},
    utils="export default { greeting: 'Hello' }",
)

# Get the output
print(result.get_output("page.mdx"))
# Output: <h1>Hello World</h1><p>This is <strong>bold</strong> text.</p>

Async Usage

import asyncio
from dinja import AsyncRenderer

async def main():
    # Use as async context manager
    async with AsyncRenderer("http://localhost:8080") as renderer:
        # Check health
        if await renderer.health():
            print("Service is running!")

        # Render MDX to HTML
        result = await renderer.html(
            views={"page.mdx": "# Hello World"},
        )
        print(result.get_output("page.mdx"))

asyncio.run(main())

Specifying Backend

# Auto-detect (uses httpx if available, then aiohttp)
renderer = AsyncRenderer("http://localhost:8080")

# Or specify explicitly
renderer = AsyncRenderer("http://localhost:8080", backend="httpx")
renderer = AsyncRenderer("http://localhost:8080", backend="aiohttp")

Render Methods

Both Renderer and AsyncRenderer support the same methods:

# Render to HTML
result = renderer.html(views={...})

# Render to JavaScript
result = renderer.javascript(views={...})

# Extract schema (component names)
result = renderer.schema(views={...})

# Render to JSON tree
result = renderer.json(views={...})

# Generic render with output format
result = renderer.render("html", views={...})

For async, just add await:

result = await renderer.html(views={...})

Components

result = renderer.html(
    views={"app.mdx": "# App\n\n<Button>Click me</Button>"},
    components={
        "Button": "export default function Component(props) { return <button>{props.children}</button>; }"
    },
)

Options

All render methods accept these parameters:

  • views: Dict mapping view names to MDX content (required)
  • components: Dict mapping component names to code (optional)
  • utils: JavaScript utilities code (optional)
  • minify: Enable minification (default: True)
  • directives: List of directive prefixes for schema extraction (optional)

Result Object

result = renderer.html(views={...})

# Check success
result.is_all_success()  # True if all files succeeded

# Get output for a file
result.get_output("page.mdx")

# Get metadata for a file
result.get_metadata("page.mdx")

# Access individual files
result.files["page.mdx"].success
result.files["page.mdx"].output
result.files["page.mdx"].metadata
result.files["page.mdx"].error  # If failed

Types

from dinja import (
    Renderer,       # Sync HTTP client class
    AsyncRenderer,  # Async HTTP client class (requires httpx or aiohttp)
    Input,          # Input dataclass
    Result,         # Batch result dataclass
    FileResult,     # Individual file result
    Component,      # Component definition
    Output,         # Type alias: "html" | "javascript" | "schema" | "json"
)

License

BSD-3-Clause

Metadata

Release files for dinja 0.5.0

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

Change of provenance

The repository or configuration that created these release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Source distribution (sdist)

Source distribution for dinja 0.5.0
File Size Uploaded Provenance
dinja-0.5.0.tar.gz 7.4 kB With provenance Details

Built distribution (wheel)

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

Total release size: 16.1 kB

Release files / dinja-0.5.0.tar.gz

Change of provenance

This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Download URL dinja-0.5.0.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
77d0e90651a64e93ad2f81d6829c9b89bbd2f0ad939d63aec296917ddb89856b
BLAKE2b-256 checksum
How to use checksums
34a6f2e6a4ee57923417661c06d5f022db81b580307d603e0ab3fa9b839fa99d
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 Nov 28, 2025.

Transparency log

Release files / dinja-0.5.0-py3-none-any.whl

Change of provenance

This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Download URL dinja-0.5.0-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
197c1c7a99d9316ebb30d269a4b1a4371a1f2a4d023acdc4ed77e55dab41d01f
BLAKE2b-256 checksum
How to use checksums
36f89dc2be6f5bf4af4842aaae6fc376e9368888d4d520f1ceeae21cfba78ae4
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 Nov 28, 2025.

Transparency log

Security for dinja 0.5.0

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.

Change of provenance

The configuration that created this release differs from a previous release.

While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.

Configuration

  • Removed 0.4.3 release.yml
  • Added 0.5.0 publish-python-manual.yml
Select from 2 files

Attestation for dinja-0.5.0.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 Nov 28, 2025.

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