SendRelay Python SDK
The official server SDK for SendRelay, the delivery API. Quote and create deliveries, read them back with the rider's live ETA, manage webhooks, and mint tracking tokens for your apps.
pip install sendrelay
Python 3.9 or newer. Use Relay in regular code and AsyncRelay with asyncio. Both have the same methods.
Quick start
import os
from sendrelay import Relay
relay = Relay(api_key=os.environ["RELAY_API_KEY"]) # sk_test_... or sk_live_..., server only
stages = [
{
"type": "PICKUP",
"location": {"latitude": 6.5244, "longitude": 3.3792, "address": "12 Marina Road, Lagos"},
"items": [{"name": "Phone case", "estimatedValue": 500000, "estimatedWeight": "LIGHT", "estimatedSize": "BOX"}],
},
{"type": "DROPOFF", "location": {"latitude": 6.4474, "longitude": 3.4723, "address": "22 Admiralty Way, Lekki"}},
]
quote = relay.tasks.quote({"taskType": "PACKAGE_DELIVERY", "stages": stages})
print(quote["total"]) # kobo
created = relay.tasks.create(
{"taskType": "PACKAGE_DELIVERY", "stages": stages, "quoteId": quote["quoteId"]},
idempotency_key="order-1042", # retries with the same key never create a second delivery
)
read = relay.tasks.get(created["task"]["id"])
if read["liveEta"]:
print(f"Arriving at stop {read['liveEta']['stageIndex'] + 1} at {read['liveEta']['arrivesAt']}")
Responses are plain dicts with the API's field names (liveEta, totalFee, ...). sendrelay.types has TypedDicts for them.
Asyncio
from sendrelay import AsyncRelay
async with AsyncRelay(api_key=os.environ["RELAY_API_KEY"]) as relay:
async for task in relay.tasks.list_all(limit=50):
print(task["id"], task["status"])
Webhooks
from sendrelay import verify_webhook_signature
result = verify_webhook_signature(raw_body, request.headers["X-Relay-Signature"], os.environ["RELAY_WEBHOOK_SECRET"])
if not result.valid:
return 400
Pass the raw request body exactly as received, not re-serialized JSON.
Errors and retries
ApiErrorhasstatus_code,codeanddetailsfrom the API.NetworkErrormeans the request never got an answer.ValidationErrormeans the SDK rejected the input before sending.
Timeouts, 408, 429 and 5xx responses are retried up to 3 times with exponential backoff. Test-mode quota errors are not retried. Change this with max_retries= or retry=RetryConfig(...).
Tracking in your app
Mint a short-lived token on your server and hand it to your app:
token = relay.auth.create_websocket_token({"scope": [f"task:{task_id}"]})["token"]
Your app then tracks the task live with one of the UI SDKs.
Metadata
Release files for sendrelay 1.14.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sendrelay-1.14.0.tar.gz | 21.8 kB | With provenance | Details for sendrelay-1.14.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sendrelay-1.14.0-py3-none-any.whl | Python 3 | none | any | Details for sendrelay-1.14.0-py3-none-any.whl |
Total release size: 40.7 kB
Release files / sendrelay-1.14.0.tar.gz
| Download URL | sendrelay-1.14.0.tar.gz |
|---|---|
| Size | 21.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
107217d2b57b7b0511a58c33d26fb5634202d19212c3ecc465c0790435ecda44
|
|
BLAKE2b-256 checksum How to use checksums |
8e781be141957022d76363bdcf3c558b0d10dc2c6d34db205ab39b697b5b81b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.
Transparency logRelease files / sendrelay-1.14.0-py3-none-any.whl
| Download URL | sendrelay-1.14.0-py3-none-any.whl |
|---|---|
| Size | 18.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6d49cfd9390a323fd8c6a14ea5833f7d3388eb7af72b58267292d8ea5f90cf0d
|
|
BLAKE2b-256 checksum How to use checksums |
6ef7cc1c3ad4f789f80d50dc2ef5c986c24aa7331bc47f7b8ff4855b2e4f4f95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.
Transparency logSecurity for sendrelay 1.14.0
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for sendrelay-1.14.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.
Transparency logA 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.