Skip to main content

HookSniff Python SDK — Webhook delivery platform

Project description

HookSniff Python SDK

PyPI License

Python SDK for the HookSniff webhook delivery platform.

Installation

pip install hooksniff

Quick Start

from hooksniff import HookSniff

# API anahtarınızı https://hooksniff.vercel.app adresinden alın
hs = HookSniff("hooksniff_xxx")

# Endpoint'leri listele
endpoints = hs.endpoint.list()

# Yeni endpoint oluştur
endpoint = hs.endpoint.create(
    EndpointIn(url="https://example.com/webhook", description="My endpoint")
)

# Webhook gönder
delivery = hs.message.create(
    endpoint_id="ep_xxx",
    event="order.created",
    data={"order_id": "123", "amount": 99.99}
)

# Teslimat denemelerini gör
attempts = hs.message_attempt.list_by_delivery(delivery.id)

Authentication

from hooksniff.api.authentication import Authentication

auth = hs.authentication

# Giriş yap
result = auth.login("user@example.com", "password123")
token = result["token"]

# Kayıt ol
result = auth.register("user@example.com", "password123", name="Servet")

# Profilimi gör
me = auth.get_me()

# 2FA etkinleştir
qr = auth.enable_2fa("password123")

Endpoints

from hooksniff.models import EndpointIn, EndpointUpdate, EndpointPatch

# Listele
endpoints = hs.endpoint.list()

# Oluştur
ep = hs.endpoint.create(EndpointIn(
    url="https://example.com/webhook",
    description="Order notifications",
    event_filter=["order.*"],
    routing_strategy="round-robin"
))

# Güncelle
ep = hs.endpoint.update(ep.id, EndpointUpdate(
    url="https://new-url.com/webhook",
    description="Updated endpoint"
))

# Kısmi güncelleme
ep = hs.endpoint.patch(ep.id, EndpointPatch(description="Patched"))

# Sil
hs.endpoint.delete(ep.id)

# Secret rotate
hs.endpoint.rotate_secret(ep.id)

Webhooks

from hooksniff.models import MessageIn

# Tek webhook gönder
delivery = hs.message.create(
    endpoint_id="ep_xxx",
    event="order.created",
    data={"order_id": "123"}
)

# Toplu gönder
result = hs.message.batch([
    {"endpoint_id": "ep_xxx", "event": "order.created", "data": {"order_id": "1"}},
    {"endpoint_id": "ep_xxx", "event": "order.shipped", "data": {"order_id": "2"}},
])

# Teslimat listesi
deliveries = hs.message.list()

# Tekrar gönder
hs.message.replay("del_xxx")

Other Resources

# Background tasks
tasks = hs.background_task.list()
task = hs.background_task.get("task_xxx")

# Environments
envs = hs.environment.list()
env = hs.environment.create(EnvironmentIn(name="production"))

# Connectors
connectors = hs.connector.list()

# Integrations
integrations = hs.integration.list()

# Streaming
channels = hs.stream.list_channels()

# Statistics
stats = hs.statistics.get_account_stats()

Webhook Verification

from hooksniff import Webhook

wh = Webhook("whsec_xxx")

# Gelen webhook'u doğrula
try:
    payload = wh.verify(raw_body, headers)
    print("Valid webhook:", payload)
except Exception:
    print("Invalid signature!")

Async Support

from hooksniff import HookSniffAsync

hs = HookSniffAsync("hooksniff_xxx")
endpoints = await hs.endpoint.list()

Error Handling

from hooksniff import (
    HookSniffError,
    NotFoundError,
    RateLimitError,
    UnauthorizedError,
)

try:
    hs.endpoint.get("nonexistent")
except NotFoundError:
    print("Endpoint bulunamadı")
except RateLimitError as e:
    print(f"Rate limit aşıldı, {e.retry_after}s bekle")
except UnauthorizedError:
    print("Geçersiz API anahtarı")
except HookSniffError as e:
    print(f"Hata: {e.status_code} - {e}")

Links

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

hooksniff-1.2.2.tar.gz (54.4 kB view details)

Uploaded Source

Built Distribution

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

hooksniff-1.2.2-py3-none-any.whl (90.9 kB view details)

Uploaded Python 3

File details

Details for the file hooksniff-1.2.2.tar.gz.

File metadata

  • Download URL: hooksniff-1.2.2.tar.gz
  • Upload date:
  • Size: 54.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for hooksniff-1.2.2.tar.gz
Algorithm Hash digest
SHA256 81bc5962396b42553d3827e1a3ef18bce5ad75977eff21b56da8ce8115fa5b38
MD5 9e13017bc1a21d6d690f421f01349194
BLAKE2b-256 b598bd2488db5fd3cfd5e368a0f78023ef2a024e5269aba0e44a36bbc0daed3d

See more details on using hashes here.

File details

Details for the file hooksniff-1.2.2-py3-none-any.whl.

File metadata

  • Download URL: hooksniff-1.2.2-py3-none-any.whl
  • Upload date:
  • Size: 90.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for hooksniff-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7eedd66002338acbacf8072ccc6d58112b84d68c315bc41ef8b85b5a908a830f
MD5 7f189562bc475b68e77bda5a4b87a11e
BLAKE2b-256 6917715281f32426d6ff7acb7ada98388659d0757cc3c24b8e17ec72d46a9a95

See more details on using hashes here.

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