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

client = HookSniff("hs_xxx")

# List endpoints
endpoints = client.endpoint.list()
print(endpoints)

# Create an endpoint
endpoint = client.endpoint.create(
    url="https://example.com/webhook",
    description="My endpoint",
)

# Send a webhook
message = client.message.create(
    event="order.created",
    data={"order_id": "123", "amount": 99.99},
)

# Get delivery attempts
attempts = client.message_attempt.list_by_msg(message.id)

Webhook Verification

from hooksniff import Webhook

wh = Webhook("whsec_xxx")

try:
    payload = wh.verify(raw_body, headers)
    # Payload is valid
    print(payload)
except Exception as err:
    # Invalid signature
    print(f"Verification failed: {err}")

Error Handling

from hooksniff import HookSniff
from hooksniff.exceptions import HookSniffError, NotFoundError

try:
    client.endpoint.get("invalid_id")
except NotFoundError:
    print("Endpoint not found")
except HookSniffError as err:
    print(f"Error: {err.code}{err.message}")

Configuration

client = HookSniff(
    "hs_xxx",
    base_url="https://api.hooksniff.com/v1",  # optional
    timeout=30,                                 # seconds
    retries=3,                                  # auto-retry on 429/5xx
)

Async Support

import asyncio
from hooksniff import HookSniff

async def main():
    client = HookSniff("hs_xxx")
    endpoints = await client.endpoint.list()
    print(endpoints)

asyncio.run(main())

Resources

Resource Methods
endpoint list, create, get, update, delete
message create, list, get
message_attempt list, list_by_msg, get, resend
authentication dashboard_access
event_type list
statistics aggregate

Links

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.0.0.tar.gz (38.8 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.0.0-py3-none-any.whl (75.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for hooksniff-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d5d5474fa723bc17339e69b5067fac6ed08132f12d2f41bbd90664251a2978ac
MD5 4f0fc1871111486950a23a08030af994
BLAKE2b-256 76325a0b309904de611ba06762ebdca4bf0236aa1618ff4f1706ad2acc9c7604

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hooksniff-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 75.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.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 68fca4373a40b0e8801131fae056a72703aa3463ae106649c26936fc7161a895
MD5 a01f2ac050e343edb4ebcdb9d2a45c7b
BLAKE2b-256 7c1e8156bd08850f3eae9c741407551840ffe5e8c9d98ff7523efd66becdbd10

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