railhook
Python SDK for Railhook.
pip install railhook
Before 2.12.0 this package was webhook-platform, imported as hookflow. That package gets no
more updates.
Send an event
import os
from railhook import Railhook, Event
client = Railhook(
api_key=os.environ["RAILHOOK_API_KEY"],
base_url="https://railhook.io", # default http://localhost:8080
)
event = client.events.send(
Event(type="order.completed", data={"order_id": "ord_123", "amount": 99.99}),
idempotency_key="order-123-completed", # optional
)
print(event.event_id, event.deliveries_created)
Verify a webhook
The signature covers the raw body, so verify the bytes as received.
import os
from flask import Flask, request
from railhook import construct_event, RailhookError
app = Flask(__name__)
@app.route("/webhooks", methods=["POST"])
def webhook():
try:
event = construct_event(
request.get_data(as_text=True), dict(request.headers), os.environ["WEBHOOK_SECRET"]
)
except RailhookError:
return "Invalid signature", 400
print(event.event_id, event.data)
return "OK", 200
verify_standard_webhook checks the webhook-* headers instead. During a secret rotation
either secret's signature is accepted.
The client also covers endpoints, subscriptions, deliveries, consumers and portal sessions, and incoming sources and events. It does not retry: one call is one HTTP request.
Full docs: https://railhook.io/docs/tools/sdks/
Develop
pip install -e ".[dev]"
pytest
python scripts/live_api_smoke.py # against a running stack (make up)
License
MIT
Metadata
Release files for railhook 2.32.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| railhook-2.32.1.tar.gz | 28.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| railhook-2.32.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 62.1 kB
Release files / railhook-2.32.1.tar.gz
| Download URL | railhook-2.32.1.tar.gz |
|---|---|
| Size | 28.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8ff3712acfe217e7e5e5276e533c98d45556c1beaa7c87aaa5b0a1ae70c1b0ea
|
|
BLAKE2b-256 checksum How to use checksums |
769864acb61ff4a17ea4374527cb4020a3a8e5a0eb5f59c471d877a8d215a57e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.16
|
Release files / railhook-2.32.1-py3-none-any.whl
| Download URL | railhook-2.32.1-py3-none-any.whl |
|---|---|
| Size | 33.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d309711af7f6bbaf3af8efcdd1d6b46c1502121c3229105904a0a5fb94813db0
|
|
BLAKE2b-256 checksum How to use checksums |
d9b7d072cf2413471279c203fe37ee84a08bde680ef7286e8d36e310926242d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.16
|