Skip to main content

Python SDK for OnceOnly idempotency API

Project description

OnceOnly Python SDK

The Idempotency Layer for AI Agents, Webhooks, and Distributed Systems.

OnceOnly is a high-performance Python SDK designed to ensure exactly-once execution. It prevents duplicate actions (payments, emails, tool calls) in unstable environments like AI agents, webhooks, or background workers.

Website - https://onceonly.tech/ai/

PyPI version License: MIT


Features

  • Sync + Async Client — built on httpx for modern Python stacks
  • Connection Pooling — high performance under heavy load
  • Fail-Open Mode — business logic keeps running even if API is unreachable
  • Smart Decorator — automatic idempotency based on function arguments
  • Typed Results & Exceptions

Installation

pip install onceonly-sdk

Quick Start

from onceonly import OnceOnly

client = OnceOnly(api_key="once_live_...")

result = client.check_lock(
    key="order:123",
    ttl=300, # 300 seconds = 5 minutes (clamped by your plan)
)

if result.duplicate:
    print("Duplicate blocked")
else:
    print("First execution")

Async Usage

async def handler():
    result = await client.check_lock_async("order:123")
    if result.locked:
        print("Locked")

TTL Behavior

  • TTL is specified in seconds
  • If ttl is not provided, the server applies the plan default TTL
  • If ttl is provided, it is automatically clamped to your plan limits

Metadata

You can optionally attach metadata to each check-lock call. Metadata is useful for debugging, tracing, and server-side analytics.

Rules:

  • JSON-serializable only
  • Size-limited
  • Safely logged on the server

Decorator

The SDK provides an optional decorator that automatically generates an idempotency key based on the function name and arguments.

This allows you to add exactly-once guarantees to existing code with zero manual key management.

from onceonly.decorators import idempotent

@idempotent(client, ttl=3600)
def process_order(order_id):
    ...

Fail-Open Mode

Enabled by default.

If a network error, timeout, or server error (5xx) occurs, the SDK returns a locked result instead of breaking your application.

Fail-open never triggers for:

  • Authentication errors (401 / 403)
  • Plan limits (402)
  • Validation errors (422)
  • Rate limits (429)

Exceptions

Exception HTTP Status Description
UnauthorizedError 401 / 403 Invalid or disabled API key
OverLimitError 402 Plan limit reached
RateLimitError 429 Too many requests
ValidationError 422 Invalid input
ApiError 5xx / other Server or unexpected API error

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

onceonly_sdk-1.2.0.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

onceonly_sdk-1.2.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file onceonly_sdk-1.2.0.tar.gz.

File metadata

  • Download URL: onceonly_sdk-1.2.0.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for onceonly_sdk-1.2.0.tar.gz
Algorithm Hash digest
SHA256 6b1810436c2de5f1f9893e536f91e54ad94f66bbc94d1d3291bec674c86c9f6c
MD5 cceccce997de945b9bf287f529b0a558
BLAKE2b-256 6fc5d60bbfca104a0ffd5b745a98c958bd8560dfdd7ac8b656bcfa25ca8ff7f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for onceonly_sdk-1.2.0.tar.gz:

Publisher: release.yml on mykolademyanov/onceonly-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file onceonly_sdk-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: onceonly_sdk-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for onceonly_sdk-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cd90d853699442228d094fd668438109d894061dd8ede5704af723ca45862fce
MD5 ff9651a083d303edf572382d8d5cbebc
BLAKE2b-256 0ca8759f39a8e1560fdfbe3d1d54b0165e39ab598df873e0c99c964128933643

See more details on using hashes here.

Provenance

The following attestation bundles were made for onceonly_sdk-1.2.0-py3-none-any.whl:

Publisher: release.yml on mykolademyanov/onceonly-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page