Python bindings for Automerge - a CRDT library for building collaborative applications.
Spork provides Pythonic bindings to Automerge, enabling you to interact with real-time collaborative applications in Python. It supports:
- Text CRDTs for collaborative text editing
- WebSocket sync for real-time collaboration
- Offline-first architecture with automatic conflict resolution
Note: these instructions are aspirational until published.
pip install spork --preFor development:
git clone <repository-url>
cd spork
pip install -e .import spork
repo = spork.Repo()
doc = await repo.create()
# String fields
await doc.set_string("title", "My Document")
print(await doc.get_string("title")) # "My Document"
# Text fields with collaborative editing
text = await doc.put_text("content", "Hello World")
await text.insert(6, "Beautiful ")
print(await text.get()) # "Hello Beautiful World"
await repo.stop()# Connect to sync server
await repo.connect_websocket("wss://sync.automerge.org")
# Create synced document
doc = await repo.create()
print(f"Share this URL: {doc.url}")
# Changes sync automatically!
text = await doc.put_text("notes", "Hello from Python!")
await repo.stop()# Full test suite
pytest -vSpork uses:
- Rust: Core automerge bindings via PyO3
- Samod: Automerge-repo for Rust
- Tokio: Async runtime for networking
- Python ≥ 3.8
- Rust (for building from source)
- Automerge: https://automerge.org
- Automerge Docs: https://automerge.org/docs/
- PyO3: https://pyo3.rs
Contributions welcome! See examples and tests for patterns.
Check out the demo/ directory for an example of a realtime document with an agentic text editor:
- CodeMirror frontend with real-time cursor tracking
- AI Collaborator edits the document alongside you
Quick start:
# Start frontend in one terminal
cd demo && npm install && npm run dev
# In another terminal, build spork and start the demo bot with your automerge URL from above
maturin develop
uv run --with ./target/wheels/spork-*.whl demo/bot.py "automerge:j1khGXyZuHf5tgb5EKoAGdUGHuN"MIT