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
Metadata
Release files for flysafe-api 0.2.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 |
|---|---|---|---|---|
| flysafe_api-0.2.0.tar.gz | 6.2 kB | Without provenance | Details for flysafe_api-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flysafe_api-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for flysafe_api-0.2.0-py3-none-any.whl |
Total release size: 13.2 kB
Release files / flysafe_api-0.2.0.tar.gz
| Download URL | flysafe_api-0.2.0.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8a824260aa354f950128b040c67dd8da382f5974d563371244b48c0f1c85b1e3
|
|
BLAKE2b-256 checksum How to use checksums |
ad5a1a75d212a2e92916a3bdef750569d6b7123fa219ad99c309d5fb12afb16d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / flysafe_api-0.2.0-py3-none-any.whl
| Download URL | flysafe_api-0.2.0-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7533c181bba09e13b688bbf4df0d108ef48d4458a9b7741c1ff7118098e9518f
|
|
BLAKE2b-256 checksum How to use checksums |
d21ab86517ed58466022523ac5b76477a48bc1cf6f9d699d661a199f87f8292a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for flysafe-api 0.2.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.
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.