Rydmate API
Rydmate Python API
Connect your Python application to Rydmate: read the fleet, hold seats and hear about every change. There is no separate library to install. The API speaks plain HTTPS and JSON, so Python's own tools are enough.
Before you start
- Create an API key in Rydmate under Developers. A key starting with
ryd_test_works on your test account, so nothing you try touches real trips or money. - Set it as
RYDMATE_API_KEYin your environment. Never put the key in your code or your app. - Install requests for the API calls: pip install requests. The webhook check uses only the standard library.
List your vehicles
The simplest request: every vehicle in the business, with its registration and status. If something goes wrong, the error says what, and carries a reference our team can look up.
import os
import requests
API = os.environ.get("RYDMATE_API_URL", "https://api.rydmate.com/api/v1")
res = requests.get(
f"{API}/vehicles",
headers={"Authorization": f"Bearer {os.environ['RYDMATE_API_KEY']}"},
timeout=30,
)
body = res.json()
if not res.ok:
err = body["error"]
raise RuntimeError(f"{err['code']}: {err['message']} ({err['request_id']})")
for vehicle in body["data"]:
print(vehicle["registration_number"], vehicle["status"])Run it with python list.py.
Hold a seat without double bookings
Hold a seat on a departure for a passenger. The Idempotency-Key header means that if the connection drops and you send the same request again, you still get one hold, not two.
If another counter took the seat first, Rydmate answers with a conflict instead of booking it twice. Once the passenger has paid, confirm the hold with POST /bookings/{id}/transition and {"to": "CONFIRMED"}.
import os
import uuid
import requests
API = os.environ.get("RYDMATE_API_URL", "https://api.rydmate.com/api/v1")
res = requests.post(
f"{API}/trips/{os.environ['TRIP_ID']}/bookings",
headers={
"Authorization": f"Bearer {os.environ['RYDMATE_API_KEY']}",
# Keep this key and send it again on a retry: you get one hold, never two.
"Idempotency-Key": str(uuid.uuid4()),
},
json={
"seat_number": "3A",
"passenger": {"full_name": "Ngozi Okafor"},
"channel": "PUBLIC_WEB",
},
timeout=30,
)
body = res.json()
if res.status_code == 409:
print("Seat already taken:", body["error"]["message"])
elif not res.ok:
raise RuntimeError(f"{body['error']['code']}: {body['error']['message']}")
else:
print("Seat held", body["data"]["id"])Check that an update really came from Rydmate
Rydmate tells your system the moment a trip, ticket, delivery or payment changes. Each update is signed with your endpoint's secret. Check the signature before you act on it, and refuse anything older than five minutes.
import hashlib
import hmac
import time
def verify_rydmate_signature(secret: str, header: str, raw_body: bytes, tolerance: int = 300) -> bool:
"""Checks the Rydmate-Signature header on a webhook delivery.
raw_body must be the request body exactly as it arrived.
"""
parts = dict(part.strip().split("=", 1) for part in header.split(",") if "=" in part)
t, v1 = parts.get("t", ""), parts.get("v1", "")
if not t.isdigit() or not v1:
return False
if abs(time.time() - int(t)) > tolerance:
return False
expected = hmac.new(secret.encode(), f"{t}.".encode() + raw_body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, v1)Build on Rydmate
Connect your product to real transport operations
Start on a test account, then go live when your integration is ready. Book a demo to talk through what you are building.