SendItWhenever Python SDK — 초정밀 예약 웹훅을 3줄로.
Project description
sendithq — SendItWhenever Python SDK
초정밀 예약 웹훅(HTTP)을 3줄로. Node SDK(@sendithq/sdk)와 동일한
표면을 Python 관용구로 제공합니다. 동기(SendIt) + 비동기(AsyncSendIt), 의존성은 httpx 하나.
pip install sendithq
Quickstart (sync)
from sendithq import SendIt
sendit = SendIt("sw_live_xxx")
ref = sendit.schedule(
url="https://api.myapp.com/hook",
in_="2h", # 또는 fire_at=datetime(...) / "2026-01-01T00:00:00Z"
payload={"user_id": 42}, # dict → JSON + Content-Type 자동, str → 그대로
idempotency_key="trial-end:42",
)
print(ref.id, ref.fire_at, ref.status)
in은 Python 예약어라 상대 시간 인자는in_을 씁니다(in_="30s" | "15m" | "2h" | "1d").
Quickstart (async)
import asyncio
from sendithq import AsyncSendIt
async def main():
async with AsyncSendIt("sw_live_xxx") as sendit:
ref = await sendit.schedule(url="https://api.myapp.com/hook", in_="2h")
print(ref.id)
asyncio.run(main())
Constructor
SendIt(
api_key, # "sw_live_…" / "sw_test_…" — 형식 오류 시 즉시 예외
base_url="https://api.sendit-whenever.com",
timeout=30.0, # 초
max_retries=2, # 멱등 경로 한정 재시도
signing_secret=None, # verify_signature 기본 시크릿
)
Methods
| 메서드 | 반환 | 비고 |
|---|---|---|
schedule(url, *, fire_at|in_, payload, method, headers, idempotency_key, early_fire) |
ScheduleRef |
idempotency_key 있을 때만 자동 재시도. early_fire 로 Early Firing opt-in |
schedule_many(items) |
BulkScheduleResult |
부분성공. items 는 schedule() 키의 dict 리스트 |
list(*, status, q, limit, offset) |
ListResult |
멱등 재시도 |
get(id) |
Schedule |
fired_at·offset_ms(실측 정시성, 미발사 시 None)·early_fire 포함 |
get_attempts(id) |
list[DeliveryAttempt] |
발송 시도 로그 |
reschedule(id, *, fire_at|in_, early_fire) |
Schedule |
scheduled 상태에서만 |
replay(id) |
ScheduleRef |
동일 암호문 재발송(비멱등) |
clone(id, *, payload, fire_at|in_, early_fire) |
ScheduleRef |
새 페이로드(비멱등) |
cancel(id) |
Schedule |
멱등 |
verify_signature(body, headers, *, secrets|secret, tolerance_sec) |
bool |
나가는 웹훅 HMAC 검증 |
signing_secrets.get() / .rotate() |
SigningSecretPair |
2키 회전 |
AsyncSendIt 은 동일 표면이며 메서드가 코루틴입니다(await).
Verifying incoming webhooks
SendItWhenever 가 보내는 웹훅에는 항상 X-SendIt-Signature 헤더(HMAC-SHA256)가 붙습니다.
서명 대상은 raw 본문이므로 파싱 전 원본 바이트를 넘기세요.
# Flask 예시
from flask import request
from sendithq import SendIt
sendit = SendIt("sw_live_xxx")
@app.post("/hook")
def hook():
secrets = sendit.signing_secrets.get() # 무중단 회전 대비 2키
ok = sendit.verify_signature(
request.get_data(), # raw bytes
request.headers,
secrets=[secrets.current.secret, secrets.next.secret],
)
if not ok:
return ("bad signature", 400)
...
Errors
모든 실패는 SendItError(code, message, status) 를 던집니다.
from sendithq import SendItError
try:
sendit.get("missing")
except SendItError as err:
if err.code == "NOT_FOUND":
...
code ∈ UNAUTHORIZED | FORBIDDEN | NOT_FOUND | VALIDATION | CONFLICT | RATE_LIMITED | INTERNAL | NETWORK.
Links
- 문서: https://www.sendit-whenever.com/docs/sdk-reference
- 대시보드(API Key 발급): https://www.sendit-whenever.com
MIT License.
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 sendithq-0.2.0.tar.gz.
File metadata
- Download URL: sendithq-0.2.0.tar.gz
- Upload date:
- Size: 19.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f15461c27a110ce6fae61ed57b98f17600b701bd687802824f3ef713e9ffeb3
|
|
| MD5 |
1fa29165af8c71889c24a0f6559b4654
|
|
| BLAKE2b-256 |
50e93b16f44db931e88e8e7da44035d9b94d6ca0727f1376f4eef840b14cc215
|
File details
Details for the file sendithq-0.2.0-py3-none-any.whl.
File metadata
- Download URL: sendithq-0.2.0-py3-none-any.whl
- Upload date:
- Size: 22.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0581e12b348dbfca0a4fc2c4bd1f55e5708ba9cd4e2fc22ed366a0c5cc211865
|
|
| MD5 |
789cbfaf27eb1c81dea02021bc8c5024
|
|
| BLAKE2b-256 |
a468c6f5609b24fa3f970c43cfcebcbeca09d1c604d5bb1a1b72ebda0e8d3c3b
|