|
| 1 | +# superdoc-sdk |
| 2 | + |
| 3 | +Programmatic SDK for deterministic DOCX operations through SuperDoc's Document API. |
| 4 | + |
| 5 | +## Install |
| 6 | + |
| 7 | +```bash |
| 8 | +pip install superdoc-sdk |
| 9 | +``` |
| 10 | + |
| 11 | +The package bundles a native CLI binary for your platform. Supported platforms: |
| 12 | + |
| 13 | +| Platform | Architecture | |
| 14 | +|----------|-------------| |
| 15 | +| macOS | Apple Silicon (arm64), Intel (x64) | |
| 16 | +| Linux | x64, ARM64 | |
| 17 | +| Windows | x64 | |
| 18 | + |
| 19 | +## Quick start |
| 20 | + |
| 21 | +```python |
| 22 | +from superdoc import SuperDocClient |
| 23 | + |
| 24 | +client = SuperDocClient() |
| 25 | + |
| 26 | +await client.doc.open(doc="./contract.docx") |
| 27 | + |
| 28 | +info = await client.doc.info() |
| 29 | +print(info["counts"]) |
| 30 | + |
| 31 | +results = await client.doc.find(query={"kind": "text", "pattern": "termination"}) |
| 32 | + |
| 33 | +await client.doc.replace( |
| 34 | + target=results["context"][0]["textRanges"][0], |
| 35 | + text="expiration", |
| 36 | +) |
| 37 | + |
| 38 | +await client.doc.save(in_place=True) |
| 39 | +await client.doc.close() |
| 40 | +``` |
| 41 | + |
| 42 | +## API |
| 43 | + |
| 44 | +### Client |
| 45 | + |
| 46 | +```python |
| 47 | +from superdoc import SuperDocClient |
| 48 | + |
| 49 | +client = SuperDocClient() |
| 50 | +``` |
| 51 | + |
| 52 | +All document operations are on `client.doc`: |
| 53 | + |
| 54 | +```python |
| 55 | +await client.doc.open(params) |
| 56 | +await client.doc.find(params) |
| 57 | +await client.doc.insert(params) |
| 58 | +# ... etc |
| 59 | +``` |
| 60 | + |
| 61 | +### Operations |
| 62 | + |
| 63 | +| Category | Operations | |
| 64 | +|----------|-----------| |
| 65 | +| **Query** | `find`, `get_node`, `get_node_by_id`, `info` | |
| 66 | +| **Mutation** | `insert`, `replace`, `delete` | |
| 67 | +| **Format** | `format.bold`, `format.italic`, `format.underline`, `format.strikethrough` | |
| 68 | +| **Create** | `create.paragraph` | |
| 69 | +| **Lists** | `lists.list`, `lists.get`, `lists.insert`, `lists.set_type`, `lists.indent`, `lists.outdent`, `lists.restart`, `lists.exit` | |
| 70 | +| **Comments** | `comments.add`, `comments.edit`, `comments.reply`, `comments.move`, `comments.resolve`, `comments.remove`, `comments.set_internal`, `comments.set_active`, `comments.go_to`, `comments.get`, `comments.list` | |
| 71 | +| **Track Changes** | `track_changes.list`, `track_changes.get`, `track_changes.accept`, `track_changes.reject`, `track_changes.accept_all`, `track_changes.reject_all` | |
| 72 | +| **Lifecycle** | `open`, `save`, `close` | |
| 73 | +| **Session** | `session.list`, `session.save`, `session.close`, `session.set_default` | |
| 74 | +| **Introspection** | `status`, `describe`, `describe_command` | |
| 75 | + |
| 76 | +## Part of SuperDoc |
| 77 | + |
| 78 | +This SDK is part of [SuperDoc](https://github.com/superdoc-dev/superdoc) — an open source document editor bringing Microsoft Word to the web. |
| 79 | + |
| 80 | +## License |
| 81 | + |
| 82 | +AGPL-3.0 · [Enterprise license available](https://superdoc.dev) |
0 commit comments