FlySafe airspace risk API client (Python)
Project description
flysafe-api (Python)
Lightweight Python client for the FlySafe airspace
risk API. Synchronous, ~200 lines, only depends on requests.
Install
pip install flysafe-api
Quickstart
from flysafe import Client
fs = Client(api_key="...")
# Score a route
risk = fs.route_risk("LHR", "DXB")
print(risk["score"], risk["risk_level"])
# 54 high
# Engine v2 — adds reroute analysis + adjusted_score
fs2 = Client(api_key="...", engine_version="v2")
r = fs2.route_risk("LHR", "DXB", carrier="IL")
print(r["adjusted_score"])
print(r["reroute_analysis"]["best_alternative"]["path"])
# 53
# ['LCCC', 'OJAC', 'OEJD', 'OTBD', 'OMAE']
# Self-serve introspection
print(fs.usage()["daily_quota"])
print(fs.queries(status="429", limit=10))
Webhooks
Verify incoming webhook signatures:
from flysafe import verify_webhook
@app.post("/flysafe-hooks")
def receive():
if not verify_webhook(SECRET, request.get_data(), request.headers["X-FlySafe-Signature"]):
return "", 401
event = request.headers["X-FlySafe-Event"]
payload = request.get_json()
# ...
Register a webhook:
created = fs.create_webhook(
url="https://hooks.example.com/flysafe",
events=["score.changed", "score.critical", "webhook.test"],
description="Production OCC dashboard",
)
SECRET = created["signing_secret"] # save it — shown only once
# Test it end-to-end
fs.fire_webhook_test(created["id"])
Errors
from flysafe import Client, FlySafeError, RateLimitError
try:
fs.route_risk("LHR", "DXB")
except RateLimitError as e:
print("retry after", e.retry_after, "seconds")
except FlySafeError as e:
print("api error:", e.status, e.body)
Reference
| Method | Endpoint |
|---|---|
route_risk(origin, destination, ...) |
/v1/route/risk |
route_risk(..., detailed=True) |
/v1/route/risk/detailed |
firs() |
/v1/firs |
signals(limit=50) |
/v1/signals |
health() |
/v1/health |
usage() |
/v1/me/usage |
queries(...) |
/v1/me/queries |
list_webhooks() |
GET /v1/me/webhooks |
create_webhook(url, events, ...) |
POST /v1/me/webhooks |
delete_webhook(id) |
DELETE /v1/me/webhooks/:id |
fire_webhook_test(id) |
POST /v1/me/webhooks/:id/test |
webhook_deliveries(id) |
GET /v1/me/webhooks/:id/deliveries |
Full API documentation: https://flysafe.zone/docs
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
flysafe_api-0.2.0.tar.gz
(6.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flysafe_api-0.2.0.tar.gz.
File metadata
- Download URL: flysafe_api-0.2.0.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a824260aa354f950128b040c67dd8da382f5974d563371244b48c0f1c85b1e3
|
|
| MD5 |
b2a3af3fabfe4d6d86979fe6eea08922
|
|
| BLAKE2b-256 |
ad5a1a75d212a2e92916a3bdef750569d6b7123fa219ad99c309d5fb12afb16d
|
File details
Details for the file flysafe_api-0.2.0-py3-none-any.whl.
File metadata
- Download URL: flysafe_api-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7533c181bba09e13b688bbf4df0d108ef48d4458a9b7741c1ff7118098e9518f
|
|
| MD5 |
6c590c2ea78ea290ba2a06f81a5a58a4
|
|
| BLAKE2b-256 |
d21ab86517ed58466022523ac5b76477a48bc1cf6f9d699d661a199f87f8292a
|