Skip to main content

snappedcut

Python SDK for the Snapped Cut cloud render API. The standard library and nothing else — no dependencies, so it installs into a locked-down CI image or a Lambda without pulling a tree behind it.

pip install snappedcut
from pathlib import Path
from snappedcut import SnappedCut

snapcut = SnappedCut()                      # reads SNAPCUT_KEY

clip = snapcut.upload("clip.webm", "video/webm")   # a path streams, chunk by chunk
design = {"width": 1080, "height": 1920, "clips": [{"type": "video", "asset": clip["id"]}]}
outputs = [{"format": "mp4", "preset": "vertical"}, {"format": "webm", "preset": "hd720"}]
created = snapcut.render_design(design, {"outputs": outputs}, idempotency_key="order-42")

job = snapcut.wait_for_job(created["job"]["id"])
for output in job["outputs"]:
    data = snapcut.download_output(job["id"], output["index"])
    Path(f"out-{output['index']}.{output['format']}").write_bytes(data)

The same idempotency_key sent twice returns the first job (created["idempotent"]) instead of charging again, so a retry after a dropped connection is safe. Presets: source, vertical, square, portrait, landscape, hd720, uhd2160 — snapcut.operations() lists them live.

Get a key from your account page — it looks like sk_snapcut_…. Keep it on a server; it spends credits.

Verifying webhooks

from snappedcut import verify_webhook

if not verify_webhook(secret, raw_body, request.headers["X-Snappedcut-Signature"]):
    return 400

Pass the body exactly as it arrived, not re-serialised JSON. A signature more than five minutes from now is refused, so a captured delivery cannot be replayed.

API

SnappedCut(key=None, base=..., timeout=120.0) key falls back to $SNAPCUT_KEY. base defaults to https://snappedcut.com.
account() AccountSummary — who the key belongs to, credits left, the price list.
render(bundle, kind="cloud-render") Queue a render of a project bundle. bundle is bytes or any file object.
job(id) / jobs() One Job, or every job on the account.
output(id) The rendered bytes. Raises unless the job is done.
wait(id, timeout=1800, on_state=None) Polls to completion, returns the bytes.
create_job(request, idempotency_key=None) A JSON job: a design, an uploaded bundle, or a tool over uploaded media.
create_batch(jobs, defaults=None) Many jobs in one request; each succeeds or is refused on its own.
get_job(id) / list_jobs() / wait_for_job(id, timeout=1800) The job as a dict, with every output.
download_output(id, index=0) One output's bytes.
compile_design(design, vars=None) / render_design(design, options=None, idempotency_key=None) Check a design, or render it.
upload(data, content_type, name=None) / get_asset(id) / delete_asset(id) Upload once, use by id. data is bytes, a path or a binary file.
operations() Every operation and output preset.
usage(from_=None, to=None, end_user_id=None, group_by=None) / delete_end_user(id) Spend, grouped; and erasing one end user.
create_embed_token(pk, end_user_id, ...) A session token for the embedded editor.
list_destinations() / create_destination / get_destination / update_destination / delete_destination / test_destination / presign_destination Your own S3-compatible buckets as render targets. A failed test_destination is returned (ok: False), not raised.
list_webhooks() / create_webhook(url, events=None) / get_webhook / update_webhook / delete_webhook / rotate_webhook / webhook_deliveries / test_webhook Webhook endpoints. The secret comes back once, from create and rotate.
verify_webhook(secret, raw_body, header, now_ms=None) Also SnappedCut.verify_webhook.

account(), render(), job() and wait() return frozen dataclasses, and py.typed ships, so an editor and mypy --strict both see real types. The calls added in 0.2 return the JSON as plain dicts, so a field the API adds within a version simply appears rather than breaking anything.

Large bundles resume themselves

render() sends a bundle under 64 MiB in one request. Above that it uploads in chunks, and if the connection drops it carries on from the server's count of what it holds, not its own — a 409 carries the expected offset and the client believes it. Three attempts per chunk; a 4xx that is not 409 is a real refusal (no credits, bad bundle, bad key) and stops immediately rather than retrying its way through your balance.

You cannot set the price

There is no seconds argument, deliberately. The server reads the timeline duration out of the bundle's own project.json and prices on that, because a duration supplied by the caller is a price supplied by the caller. What you were actually charged comes back as charged, with the server's reasoning in priced.

Errors

Every failure raises SnappedCutError with the HTTP status, the server's message and code, and retry_after_ms on it, and the two failures you actually branch on have properties so you need not parse a message (is_out_of_credits / is_rate_limited are the same, under the names every Snapped Cut SDK shares):

from snappedcut import SnappedCutError

try:
    snapcut.render(bundle)
except SnappedCutError as error:
    if error.out_of_credits:        # 402
        top_up()
    elif error.rate_limited:        # 429
        time.sleep(error.retry_after_ms / 1000)
    else:
        raise

A server that cannot be reached at all is status == 0, which is the one case worth sending again. A job that fails server-side has already been refunded by the time wait() raises, so there is nothing to reconcile.

repr() never contains the key — a repr ends up in logs and tracebacks.

What this is not

Snapped Cut edits video on the device: decode, cut, filter and encode all run in a browser on WebCodecs. There is no API for them and there cannot be — no SDK can make Python do that. What this covers is the one thing that does happen on our machines: a cloud render, which is opt-in and costs credits.

To build the bundles this takes, see @snappedcut/mcp or the editor's Share → Export bundle. A bundle whose media is missing is refused at submit, before any charge — it would otherwise render successfully as the right number of blank frames, and nothing downstream could tell.

Releases

Published from CI through PyPI trusted publishing, which signs an attestation linking each wheel back to the commit and workflow run that built it. Nothing is published from anyone's laptop.

MIT

Metadata

Release files for snappedcut 0.2.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 snappedcut 0.2.0
File Size Uploaded Provenance Actions
snappedcut-0.2.0.tar.gz 16.7 kB Without provenance Details for snappedcut-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 29.7 kB

Release files / snappedcut-0.2.0.tar.gz

Download URL snappedcut-0.2.0.tar.gz
Size 16.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8c666b936a727b6e5b7fd167f562f8c111132ad8f234130b85cd93e43e621ffb
BLAKE2b-256 checksum
How to use checksums
5b870eb80e16062cd9a7a1f3dd15595889debf22749716234e67fff0dd73cf20
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / snappedcut-0.2.0-py3-none-any.whl

Download URL snappedcut-0.2.0-py3-none-any.whl
Size 13.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
caf3b641fa1f66a7decaa7f788376d58fee3d55d08ae040eb1293b79604ef3a1
BLAKE2b-256 checksum
How to use checksums
239e05fc58f92bdd232593f24ecffdce07efc6b71e78e04b2e06f25bb9e1ebdd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for snappedcut 0.2.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

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