Skip to content

Python API

The Python package prepares selected marimo notebook states, writes verified notebook exports, and reads the same files that browser applications consume. Python 3.10 or newer is required. Continuous integration tests Python 3.10 through 3.14, and the package metadata pins its exact supported marimo release. See Compatibility for the complete boundary.

Install the base package to produce and read portable JSON, scalar, NumPy, rendered-output, complete-cell, and blob outputs:

bash
uv add marimo-export

Install a producer extra when an ExportSpec uses its exporter:

ExporterInstall
Altair Vega-Lite or PNGuv add "marimo-export[charts]"
AnyWidgetuv add "marimo-export[anywidget]"
Parquetuv add "marimo-export[parquet]"
Every built-in exporteruv add "marimo-export[all]"

Choose a Python path

JobReference
Define states and outputs, plan work, prepare, or buildProduce an export
Open states and decode outputsRead and verify exports
Inspect a notebook or capture a live sessionSessions and inspection
Configure retention or record observed inputsRepository and observations
Commit an application directory or retain a changing publicationDelivery and publications
Embed marimo-export behavior in a marimo hostHost integration
Implement against canonical JSON, indexes, descriptors, or typed errorsFormat records and errors

The common workflow

python
from pathlib import Path

from marimo_export import ExportSpec, OutputSpec, build, open_export

spec = ExportSpec(
    default_state="baseline",
    states={
        "baseline": {},
        "weekly": {"interval": "1wk"},
    },
    outputs={"summary": OutputSpec.json("report.summary")},
)

Path("dist").mkdir(exist_ok=True)
result = build("report.py", spec=spec, output="dist/report")
summary = open_export(result.path).default_state.output("summary").json()

An ExportSpec declares named state rows and named outputs. Planning fills each sparse row from the notebook baseline and creates one complete input vector per state. Preparation stores reusable results in the export repository. Writing creates a notebook export whose index.json and assets can be verified without running notebook code.

The package root exposes the common workflow:

python
from marimo_export import (
    ExportPlan,
    ExportRepository,
    ExportResult,
    ExportSpec,
    NotebookExport,
    OutputSpec,
    PreparedExport,
    ProgressEvent,
    StateSpace,
    VerificationResult,
    build,
    capture,
    open_export,
    plan,
    prepare,
    verify_export,
)

Focused modules own application delivery, live sessions, observations, host integration, output values, and the low-level format records. Their reference pages identify the canonical import path for each API.

Released under the Apache 2.0 License.