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.1.0.tar.gz (42.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.1.0-py3-none-any.whl (80.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hooksniff-1.1.0.tar.gz
  • Upload date:
  • Size: 42.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.1.0.tar.gz
Algorithm Hash digest
SHA256 57667379bf87f66b72b72fd53f16066f6ac16387a90b74feeca0000d84678ccb
MD5 2e503af970699d69cf4d2f9a0cce36b0
BLAKE2b-256 aeb52e732bfee80cfaeaccf462a29d5c030d2cda0532c8d03ffddf87b95e36fa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hooksniff-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 80.8 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e9bf7c3f0810160694b4dbefef84e631e38ee72b150c99220dc132322faec79a
MD5 cc1199c7128464dc03bad1233e3a34a5
BLAKE2b-256 0496ae5011d573a5a2d4404971e0db0a55aa4c41ca61e313d22ae5bc6e3f25b2

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