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
Release files for railhook 2.31.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.31.1.tar.gz | 28.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| railhook-2.31.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 62.1 kB
Release files / railhook-2.31.1.tar.gz
| Download URL | railhook-2.31.1.tar.gz |
|---|---|
| Size | 28.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
99f8019dbe09a63a6186a9b83c3a2428ceedc4c9e707521c9c147ad96f23346c
|
|
BLAKE2b-256 checksum How to use checksums |
90cdc9f6aafa4a07dff6e7eca6ed0eb2e2403e110962014454356362b8907e37
|
| 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.31.1-py3-none-any.whl
| Download URL | railhook-2.31.1-py3-none-any.whl |
|---|---|
| Size | 33.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
899ce652976f86dacc658e103106a1c9570ea329567c11ea905f0936aece1088
|
|
BLAKE2b-256 checksum How to use checksums |
32feb6dd2ad1fe37b4982c5fac99610a5ffe1123dc28185f83a9bd632dda24cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.16
|