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.1.tar.gz (41.6 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.1-py3-none-any.whl (84.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hooksniff-1.2.1.tar.gz
  • Upload date:
  • Size: 41.6 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.1.tar.gz
Algorithm Hash digest
SHA256 dc84bdd7948a2788ae7d94f446378d6a1b4a0808e0225a424da7dd63642a4841
MD5 24784dc3a1b6dec9803e102a4700db90
BLAKE2b-256 089a73c23dfca346c6737cfa4117b00e73005884eeff752f656ff6962df7bdc8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hooksniff-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 84.1 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 753aac47ff47af965c0e644900c80514db8f636b7a68df5b2fa65f794e325bb3
MD5 15de3a7e5fb84000a9044c7e0894af18
BLAKE2b-256 c91e91947fe5b60bbbbce02253f08777c247b2de3f6ade410f39cba1ac1682cd

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