Skip to content

HookFreight/hookfreight-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hookfreight

Official Python SDK for Hookfreight.

Capture, inspect, replay, and reliably deliver webhooks with full visibility.

Installation

pip install hookfreight

Quick Start

Hookfreight Cloud

from hookfreight import Hookfreight

hf = Hookfreight(api_key="hf_sk_...")

result = hf.deliveries.list({"limit": 10})
print(result["deliveries"])

Self-Hosted

from hookfreight import Hookfreight

hf = Hookfreight(base_url="http://localhost:3030/api/v1")

Configuration

Option Type Default Description
api_key str API key for Hookfreight Cloud. Optional for self-hosted.
base_url str https://api.hookfreight.com/v1 Base URL of the API. Override for self-hosted.
timeout int 30000 Request timeout in milliseconds.

Usage

from hookfreight import Hookfreight

hf = Hookfreight(api_key="hf_sk_...")

app = hf.apps.create({"name": "My App"})
endpoint = hf.endpoints.create({
    "name": "Stripe",
    "app_id": app["id"],
    "forward_url": "https://example.com/webhooks/stripe",
})

event = hf.events.get("evt_...")
print(event["body"])

stats = hf.deliveries.queue_stats()
print(stats)

Error Handling

from hookfreight import Hookfreight, NotFoundError, ValidationError, ConnectionError

hf = Hookfreight(api_key="hf_sk_...")

try:
    hf.apps.get("app_nonexistent")
except NotFoundError:
    print("App not found")
except ValidationError as err:
    print(err.errors)
except ConnectionError as err:
    print(err)

Examples

  • examples/basic_usage.py
  • examples/manage_endpoints.py
  • examples/retry_failed_deliveries.py
  • examples/monitor_queue.py

Run an example:

HOOKFREIGHT_API_KEY=hf_sk_... python examples/basic_usage.py

License

Apache-2.0

Packages

 
 
 

Contributors

Languages