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.2
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.2.tar.gz | 28.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| railhook-2.32.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 62.1 kB
Release files / railhook-2.32.2.tar.gz
| Download URL | railhook-2.32.2.tar.gz |
|---|---|
| Size | 28.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bfdcd0e3c0cfed7ea25c4e729712fec0116f4238c3f4c1583ce7ff559a0be5e9
|
|
BLAKE2b-256 checksum How to use checksums |
0f6c2c29559897266553aaece03a23ee63300f3f0fb6a4e756c016b0052ec2d6
|
| 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.2-py3-none-any.whl
| Download URL | railhook-2.32.2-py3-none-any.whl |
|---|---|
| Size | 33.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
db17e3d864fe775454087db54010f4322ef08645206610ef341eca14a7f4987e
|
|
BLAKE2b-256 checksum How to use checksums |
36d905cc8028d8da056ff46f6fee73284bd237503a7b176818ca5710f10446b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.16
|