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/
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b1810436c2de5f1f9893e536f91e54ad94f66bbc94d1d3291bec674c86c9f6c
|
|
| MD5 |
cceccce997de945b9bf287f529b0a558
|
|
| BLAKE2b-256 |
6fc5d60bbfca104a0ffd5b745a98c958bd8560dfdd7ac8b656bcfa25ca8ff7f6
|
Provenance
The following attestation bundles were made for onceonly_sdk-1.2.0.tar.gz:
Publisher:
release.yml on mykolademyanov/onceonly-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
onceonly_sdk-1.2.0.tar.gz -
Subject digest:
6b1810436c2de5f1f9893e536f91e54ad94f66bbc94d1d3291bec674c86c9f6c - Sigstore transparency entry: 801047901
- Sigstore integration time:
-
Permalink:
mykolademyanov/onceonly-python@cf4dfa0be2e6a618d9fa5b500137c93c6e3ccf30 -
Branch / Tag:
refs/tags/v1.2.0 - Owner: https://github.com/mykolademyanov
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cf4dfa0be2e6a618d9fa5b500137c93c6e3ccf30 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd90d853699442228d094fd668438109d894061dd8ede5704af723ca45862fce
|
|
| MD5 |
ff9651a083d303edf572382d8d5cbebc
|
|
| BLAKE2b-256 |
0ca8759f39a8e1560fdfbe3d1d54b0165e39ab598df873e0c99c964128933643
|
Provenance
The following attestation bundles were made for onceonly_sdk-1.2.0-py3-none-any.whl:
Publisher:
release.yml on mykolademyanov/onceonly-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
onceonly_sdk-1.2.0-py3-none-any.whl -
Subject digest:
cd90d853699442228d094fd668438109d894061dd8ede5704af723ca45862fce - Sigstore transparency entry: 801047945
- Sigstore integration time:
-
Permalink:
mykolademyanov/onceonly-python@cf4dfa0be2e6a618d9fa5b500137c93c6e3ccf30 -
Branch / Tag:
refs/tags/v1.2.0 - Owner: https://github.com/mykolademyanov
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cf4dfa0be2e6a618d9fa5b500137c93c6e3ccf30 -
Trigger Event:
release
-
Statement type: