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. The supported Python range and classifiers are declared in the package metadata. Continuous integration tests each supported version, 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, PNG, or SVGuv add "marimo-export[charts]"
AnyWidgetuv add "marimo-export[anywidget]"
Parquetuv add "marimo-export[parquet]"
Every built-in exporteruv add "marimo-export[all]"

The media exporter needs the charts extra for Altair charts only. It renders matplotlib figures with the notebook's own matplotlib and other values with their display methods.

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 Python prepared publicationDelivery and publications
Embed marimo-export behavior in a marimo hostHost integration
Discover the version-matched code-mode workflowmarimo_export.agent
Convert portable values or encode canonical JSONPortable JSON
Construct indexes and descriptors or handle typed errorsFormat records and errors
Interpret progress events and cache activityProduce an export
Check lower-level capture record reachabilityNarrow protocol records

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.