plotwork
The hosted Plotwork API from Python. Every /v1 operation (validate, draw, render, import a file, publish, patterns, icons) is a typed method generated from the API's OpenAPI document, sent with urllib from the standard library alone. It runs on Python 3.10 and later.
TL;DR
| Question | Answer |
|---|---|
| What does it install? | Nothing else. |
| Where do the types come from? | The API's OpenAPI document, kept in the SDK repository as spec/openapi.json. Every request and answer is a TypedDict. |
| How do I sign in? | An API key from the Plotwork portal (api_key), or an OAuth access token (access_token). |
| Does a mistake in a diagram raise? | No. It is part of the answer, with a line, a column and a hint. Only a failed request raises, as PlotworkApiError with a stable error_code. |
| Does it retry? | A safe call is retried twice on 429 and 503, after the API's Retry-After. Publishing is never retried. |
| Is there a TypeScript client? | Yes, @plotwork.official/sdk, with the same calls in camelCase. |
Install
pip install plotwork
Use
import os
from plotwork import Plotwork
plotwork = Plotwork(api_key=os.environ["PLOTWORK_API_KEY"])
source = 'flow "Checkout"\nnode web service "Web tier"\nnode api service "Orders API"\nweb -> api : "places order"\n'
checked = plotwork.diagrams.validate(source=source)
if not checked["valid"]:
for error in checked["errors"]:
print(error["line"], error["column"], error["message"], error.get("hint"))
published = plotwork.diagrams.publish(source=source, embedSource=True)
# A diagram an organisation's policy keeps private has no public link.
if "url" in published:
print(published["url"])
A method takes the request's fields as keyword arguments, named as the API names them (embedSource, documentPath), and returns the answer as a plain dict typed by a TypedDict. A body you already have as a dict is passed with **body. Keep the key in an environment variable or your CI's secret store, never in a file you commit.
| Group | Calls |
|---|---|
diagrams |
validate, draw, render, outline, read, edit, compare, suggest, convert_mermaid, publish |
import_source |
A diagram from Terraform, OpenAPI, SQL, Kubernetes, Compose and the other formats the API reads |
markdown |
sync, plan |
patterns |
find, get, draw, check |
icons |
search, map |
vocabulary |
The language's statements and limits, for a kind or a topic |
Errors
from plotwork import PlotworkApiError
try:
plotwork.diagrams.render(source=source)
except PlotworkApiError as error:
print(error.status, error.error_code, error.request_id)
error_code |
Means |
|---|---|
auth.missing, auth.invalid_key |
No key, or one the API does not accept |
rate_limit.exceeded |
Too many calls; already retried for a safe call |
http.<status> |
An answer that was not the API's error envelope, such as a proxy's page |
request.timeout, request.failed |
No answer came; status is 0 |
Options
| Option | Default |
|---|---|
api_key |
none |
access_token |
none |
base_url |
https://api.plotwork.dev (https://api-preview.plotwork.dev for preview, or a self-hosted engine) |
timeout |
60 seconds |
max_retries |
2 |
opener |
urllib.request.build_opener().open; pass your own for a proxy or a test |
sleep |
time.sleep, the wait before a retry |
plotwork.with_options(timeout=120) gives a copy with another timeout or number of retries, for a slow call such as a large import.
See also
| Page | Why |
|---|---|
| SDKs guide | Every Plotwork SDK, and which to choose |
| API reference | What each operation does |
| TypeScript client | The same API from TypeScript |
| Viewer | Show what you publish, interactively, in a web page |
| Source | This package, its tests and its generator |
Metadata
Release files for plotwork 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| plotwork-0.1.0.tar.gz | 38.9 kB | With provenance | Details for plotwork-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| plotwork-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for plotwork-0.1.0-py3-none-any.whl |
Total release size: 73.6 kB
Release files / plotwork-0.1.0.tar.gz
| Download URL | plotwork-0.1.0.tar.gz |
|---|---|
| Size | 38.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9c41b5e250d03513fb13d902961aaeb240e8646a7fa7ca58d9d6250d8a233b5d
|
|
BLAKE2b-256 checksum How to use checksums |
c8384a74a00f08bb1a7c48f133b4708c9cfe2eeb84971058286d965ae1bf2f3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Oct 29, 2026.
Transparency logRelease files / plotwork-0.1.0-py3-none-any.whl
| Download URL | plotwork-0.1.0-py3-none-any.whl |
|---|---|
| Size | 34.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
66376ece4d669af1252bf06a8a262579d3aa82d4405bec58ee63d3b977979a79
|
|
BLAKE2b-256 checksum How to use checksums |
001cf6e84f57a89bb3bdfed2a38c93fce35d02024090fce7ef56549d4cd293af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Oct 29, 2026.
Transparency logSecurity for plotwork 0.1.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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for plotwork-0.1.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 Oct 29, 2026.
Transparency logA 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.