Skip to main content

GetRatchet Python SDK

Install with pip install getratchet. For local development, use pip install ./python. The package uses only the Python standard library and supports Python 3.10+.

from getratchet import Ratchet

ratchet = Ratchet("https://getratchet.waelfz.com", "YOUR_PRODUCER_API_KEY")
run_id = ratchet.start_run("customer-onboarding", project_id="YOUR_PROJECT_ID", environment_id="YOUR_ENVIRONMENT_ID")
job = ratchet.enqueue(
    "send_welcome_email", "1", {"customerId": "cus_42"},
    idempotency_key="welcome:cus_42",
)
ratchet.finish_run()
print(run_id, job["stepId"])

Run a separate, long-lived worker process with a WORKER scoped API key. Register handlers before starting the worker. Restarting a worker registers it again; leased jobs return to the queue after the lease expires. Register the exact version used by queued jobs.

from getratchet import Ratchet

worker = Ratchet("https://getratchet.waelfz.com", "YOUR_WORKER_API_KEY")

def send_welcome(payload, context):
    context.check_cancelled()
    # Pass context.idempotency_key to the mail/payment provider if it supports one.
    return {"providerMessageId": send_mail(payload, idempotency_key=context.idempotency_key)}

worker.register_tool("send_welcome_email", "1", send_welcome)
worker.worker.start(concurrency=4)

Use worker.worker.stop() for graceful shutdown. Handlers should call context.check_cancelled() around expensive or irreversible operations. Python cannot forcibly terminate a running thread; a handler that blocks forever also blocks worker shutdown. Set explicit timeouts on downstream network calls. A failure between an external side effect and the job report can repeat that effect, so pass the stable idempotency key to the destination service or record it there. Raising NonRetryableError prevents another attempt; other handler errors are retried under the endpoint policy.

Use ratchet.replay_preview(step_id) to review replay risk before calling ratchet.replay(step_id, reason=...). Replay can run an irreversible action again and should use a fresh destination-side deduplication decision.

Pass after_step_id=primary["stepId"], after_status="FAILED" to enqueue for a fallback, or after_status="SUCCEEDED" for a follow-up. Enqueue dependencies before finish_run(). Independent calls may run in parallel. Unused branches are marked SKIPPED without invoking a handler.

Release files for getratchet 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for getratchet 0.1.0
File Size Uploaded
getratchet-0.1.0.tar.gz 7.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for getratchet 0.1.0
File Interpreter ABI Platform
getratchet-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.6 kB

Release files / getratchet-0.1.0.tar.gz

Download URL getratchet-0.1.0.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
77bf504ee1672a929bc4f7b456345d9b06525d05b0b117cf135ea594f2261536
BLAKE2b-256 checksum
How to use checksums
6e97cf47af42da7c4daea59efa7ed2db4c032cd327330ed8c5c3c1a017d90d35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 25, 2026.

Transparency log

Release files / getratchet-0.1.0-py3-none-any.whl

Download URL getratchet-0.1.0-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4a916600a5ae69e2f479d9ba4fd01221f99fa7f26e631df9ff794f9e3dc5bb42
BLAKE2b-256 checksum
How to use checksums
ca9d6edc285d409c4cf4a3a44bd1d12ccae8d1d098ff6c1e7cdbc5fbd3d28edc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 25, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page