SuperDoc SDK (CLI-backed)
Project description
superdoc-sdk
Programmatic SDK for deterministic DOCX operations through SuperDoc's Document API.
Install
pip install superdoc-sdk
The package installs a platform-specific CLI companion package automatically via PEP 508 environment markers. Supported platforms:
| Platform | Architecture |
|---|---|
| macOS | Apple Silicon (arm64), Intel (x64) |
| Linux | x64, ARM64 |
| Windows | x64 |
Quick start
from superdoc import SuperDocClient
with SuperDocClient() as client:
client.doc.open({"doc": "./contract.docx"})
info = client.doc.info({})
print(info["counts"])
results = client.doc.find({"type": "text", "pattern": "termination"})
target = results["items"][0]["context"]["textRanges"][0]
client.doc.replace({"target": target, "text": "expiration"})
client.doc.save({"inPlace": True})
client.doc.close({})
Async
import asyncio
from superdoc import AsyncSuperDocClient
async def main():
async with AsyncSuperDocClient() as client:
await client.doc.open({"doc": "./contract.docx"})
info = await client.doc.info({})
print(info["counts"])
results = await client.doc.find({"type": "text", "pattern": "termination"})
target = results["items"][0]["context"]["textRanges"][0]
await client.doc.replace({"target": target, "text": "expiration"})
await client.doc.save({"inPlace": True})
await client.doc.close({})
asyncio.run(main())
Client lifecycle
The SDK uses a persistent host process for all operations. The host is started on first use and reused across calls, avoiding per-operation subprocess overhead.
Context managers (recommended)
# Sync
with SuperDocClient() as client:
client.doc.find({"query": "test"})
# Async
async with AsyncSuperDocClient() as client:
await client.doc.find({"query": "test"})
The context manager calls connect() on entry and dispose() on exit (including on exception).
Explicit lifecycle
client = SuperDocClient()
client.connect() # Optional — first invoke() auto-connects
result = client.doc.find({"query": "test"})
client.dispose() # Shuts down the host process
connect() is optional. If not called explicitly, the first operation triggers a lazy connection to the host process.
Configuration
client = SuperDocClient(
startup_timeout_ms=10_000, # Max time for host handshake (default: 5000)
shutdown_timeout_ms=5_000, # Max time for graceful shutdown (default: 5000)
request_timeout_ms=60_000, # Per-operation timeout passed to CLI (default: None)
watchdog_timeout_ms=30_000, # Client-side safety timer per request (default: 30000)
default_change_mode="tracked", # Auto-inject changeMode for mutations (default: None)
env={"SUPERDOC_CLI_BIN": "/path/to/superdoc"}, # Environment overrides
)
Thread safety
Client instances are serialized: one operation at a time per client. For parallelism, use multiple client instances. Do not share a single client across threads.
API
Client
from superdoc import SuperDocClient
client = SuperDocClient()
All document operations are on client.doc:
client.doc.open(params)
client.doc.find(params)
client.doc.insert(params)
# ... etc
Operations
| Category | Operations |
|---|---|
| Query | find, get_node, get_node_by_id, info |
| Mutation | insert, replace, delete |
| Format | format.bold, format.italic, format.underline, format.strikethrough |
| Create | create.paragraph |
| Lists | lists.list, lists.get, lists.insert, lists.create, lists.attach, lists.detach, lists.indent, lists.outdent, lists.join, lists.separate, lists.set_level, lists.set_value, lists.continue_previous, lists.set_level_restart, lists.convert_to_text, lists.can_join, lists.can_continue_previous |
| Comments | comments.create, comments.patch, comments.delete, comments.get, comments.list |
| Track Changes | track_changes.list, track_changes.get, track_changes.decide |
| Lifecycle | open, save, close |
| Session | session.list, session.save, session.close, session.set_default |
| Introspection | status, describe, describe_command |
Collaboration
The Python SDK supports realtime collaboration through the same host transport as the Node SDK. Pass collaboration parameters to doc.open:
with SuperDocClient() as client:
client.doc.open({
"doc": "./contract.docx",
"collabUrl": "ws://localhost:4000",
"collabDocumentId": "my-doc-id",
})
# Operations now use the collaborative session
client.doc.find({"query": "test"})
client.doc.close({})
Troubleshooting
Custom CLI binary
If you need to use a custom-built CLI binary (e.g. a newer version or a patched build), set the SUPERDOC_CLI_BIN environment variable:
export SUPERDOC_CLI_BIN=/path/to/superdoc
Debug logging
Enable transport-level debug logging to diagnose connectivity issues:
export SUPERDOC_DEBUG=1
Air-gapped / private index environments
Mirror both superdoc-sdk and the superdoc-sdk-cli-* package for your platform to your private index. For example, on macOS ARM64:
pip download superdoc-sdk superdoc-sdk-cli-darwin-arm64
# Upload both wheels to your private index
Part of SuperDoc
This SDK is part of SuperDoc — an open source document editor bringing Microsoft Word to the web.
License
AGPL-3.0 · Enterprise license available
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file superdoc_sdk-1.0.0a24.tar.gz.
File metadata
- Download URL: superdoc_sdk-1.0.0a24.tar.gz
- Upload date:
- Size: 293.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf441c1186dc2942bf9b58a04a383b760679a7d3a3dfbf887e597ad4cfc31a84
|
|
| MD5 |
663d13d540923297a1516c1b1f478f21
|
|
| BLAKE2b-256 |
2b27474550ebd746e3473651052d9d285e5e2c617aa4bc7a5526903cbdaae527
|
Provenance
The following attestation bundles were made for superdoc_sdk-1.0.0a24.tar.gz:
Publisher:
release-sdk.yml on superdoc-dev/superdoc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
superdoc_sdk-1.0.0a24.tar.gz -
Subject digest:
cf441c1186dc2942bf9b58a04a383b760679a7d3a3dfbf887e597ad4cfc31a84 - Sigstore transparency entry: 1019544191
- Sigstore integration time:
-
Permalink:
superdoc-dev/superdoc@551a6ff70f273274e89e6fa78a4f88f1ed738c4b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/superdoc-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-sdk.yml@551a6ff70f273274e89e6fa78a4f88f1ed738c4b -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file superdoc_sdk-1.0.0a24-py3-none-any.whl.
File metadata
- Download URL: superdoc_sdk-1.0.0a24-py3-none-any.whl
- Upload date:
- Size: 315.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33190dd9206932dd1962a95fa80e128fcf6b4958011e4faa3aca296332b862f9
|
|
| MD5 |
b9c197df6ee00674e3043661b5a06666
|
|
| BLAKE2b-256 |
5432def566e41671d31aa960819fb7d2b2fdf053436a971c7a469fc06bc43a5f
|
Provenance
The following attestation bundles were made for superdoc_sdk-1.0.0a24-py3-none-any.whl:
Publisher:
release-sdk.yml on superdoc-dev/superdoc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
superdoc_sdk-1.0.0a24-py3-none-any.whl -
Subject digest:
33190dd9206932dd1962a95fa80e128fcf6b4958011e4faa3aca296332b862f9 - Sigstore transparency entry: 1019544225
- Sigstore integration time:
-
Permalink:
superdoc-dev/superdoc@551a6ff70f273274e89e6fa78a4f88f1ed738c4b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/superdoc-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-sdk.yml@551a6ff70f273274e89e6fa78a4f88f1ed738c4b -
Trigger Event:
workflow_dispatch
-
Statement type: