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://hooksniff-api-1046140057667.europe-west1.run.app/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.2.0.tar.gz (39.3 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.0-py3-none-any.whl (82.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hooksniff-1.2.0.tar.gz
  • Upload date:
  • Size: 39.3 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.0.tar.gz
Algorithm Hash digest
SHA256 ff0032fc9fe5a47222874b341e729e08aebfae70e768e3b644dd619549006aae
MD5 493efc59a35acca2d71e63f47ebb92de
BLAKE2b-256 a1225a67f763bae2f83aa531e2c9e8f0b1f9a8cda727072345b36a8875874a61

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hooksniff-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 82.6 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 46b9d105658abed5f6d2d44868f4340f4e41726b4e03293119b5ba6deed8344e
MD5 93eca11f88e2553d0b609ec95fe41fb5
BLAKE2b-256 42a6bf4f28b28db256a29fb64394c5b4e02ad63958699cdef3194520d718b796

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