Skip to main content

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 3.7.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for railhook 3.7.1
File Size Uploaded Provenance Actions
railhook-3.7.1.tar.gz 28.5 kB Without provenance Details for railhook-3.7.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for railhook 3.7.1
File Interpreter ABI Platform Actions
railhook-3.7.1-py3-none-any.whl Python 3 none any Details for railhook-3.7.1-py3-none-any.whl

Total release size: 61.7 kB

Release files / railhook-3.7.1.tar.gz

Download URL railhook-3.7.1.tar.gz
Size 28.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9869feebc8323b0891ca907326481a1764827263a0cfc9d0d78e37779a0cd717
BLAKE2b-256 checksum
How to use checksums
4f10d888af825376571a499730fc84577f589814670822b4f63a2a7d47934e8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.18

Release files / railhook-3.7.1-py3-none-any.whl

Download URL railhook-3.7.1-py3-none-any.whl
Size 33.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
22d5a25b13d9c6bacff2ca5b5adc9d74a32d4786ba87763600fae2e55095d196
BLAKE2b-256 checksum
How to use checksums
33b060b9338551d37d373e393876516c22ef90b1c8a6994777d4a05272a7e103
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.18

Security for railhook 3.7.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

3.7.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page