disruptapi 0.2.0__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {disruptapi-0.2.0 → disruptapi-0.3.0}/PKG-INFO +25 -3
- {disruptapi-0.2.0 → disruptapi-0.3.0}/README.md +24 -2
- {disruptapi-0.2.0 → disruptapi-0.3.0}/src/disruptapi/_client.py +4 -0
- disruptapi-0.3.0/src/disruptapi/_version.py +1 -0
- {disruptapi-0.2.0 → disruptapi-0.3.0}/src/disruptapi/resources/_specs.py +27 -0
- {disruptapi-0.2.0 → disruptapi-0.3.0}/src/disruptapi/resources/async_.py +24 -0
- {disruptapi-0.2.0 → disruptapi-0.3.0}/src/disruptapi/resources/sync.py +24 -0
- {disruptapi-0.2.0 → disruptapi-0.3.0}/tests/test_phase6_endpoints.py +24 -0
- disruptapi-0.2.0/src/disruptapi/_version.py +0 -1
- {disruptapi-0.2.0 → disruptapi-0.3.0}/.gitignore +0 -0
- {disruptapi-0.2.0 → disruptapi-0.3.0}/LICENSE +0 -0
- {disruptapi-0.2.0 → disruptapi-0.3.0}/pyproject.toml +0 -0
- {disruptapi-0.2.0 → disruptapi-0.3.0}/src/disruptapi/__init__.py +0 -0
- {disruptapi-0.2.0 → disruptapi-0.3.0}/src/disruptapi/__main__.py +0 -0
- {disruptapi-0.2.0 → disruptapi-0.3.0}/src/disruptapi/_base_client.py +0 -0
- {disruptapi-0.2.0 → disruptapi-0.3.0}/src/disruptapi/_errors.py +0 -0
- {disruptapi-0.2.0 → disruptapi-0.3.0}/src/disruptapi/_rate_limit.py +0 -0
- {disruptapi-0.2.0 → disruptapi-0.3.0}/src/disruptapi/cli.py +0 -0
- {disruptapi-0.2.0 → disruptapi-0.3.0}/src/disruptapi/pagination.py +0 -0
- {disruptapi-0.2.0 → disruptapi-0.3.0}/src/disruptapi/py.typed +0 -0
- {disruptapi-0.2.0 → disruptapi-0.3.0}/src/disruptapi/resources/__init__.py +0 -0
- {disruptapi-0.2.0 → disruptapi-0.3.0}/src/disruptapi/types.py +0 -0
- {disruptapi-0.2.0 → disruptapi-0.3.0}/src/disruptapi/webhooks.py +0 -0
- {disruptapi-0.2.0 → disruptapi-0.3.0}/tests/__init__.py +0 -0
- {disruptapi-0.2.0 → disruptapi-0.3.0}/tests/conftest.py +0 -0
- {disruptapi-0.2.0 → disruptapi-0.3.0}/tests/test_async_and_pagination.py +0 -0
- {disruptapi-0.2.0 → disruptapi-0.3.0}/tests/test_cli.py +0 -0
- {disruptapi-0.2.0 → disruptapi-0.3.0}/tests/test_client.py +0 -0
- {disruptapi-0.2.0 → disruptapi-0.3.0}/tests/test_rate_limit.py +0 -0
- {disruptapi-0.2.0 → disruptapi-0.3.0}/tests/test_webhooks.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: disruptapi
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Official Python client for DisruptAPI, the travel disruption intelligence API.
|
|
5
5
|
Project-URL: Homepage, https://disruptapi.com
|
|
6
6
|
Project-URL: Documentation, https://disruptapi.com/docs/
|
|
@@ -32,8 +32,6 @@ Description-Content-Type: text/markdown
|
|
|
32
32
|
|
|
33
33
|
The official Python client for [DisruptAPI](https://disruptapi.com), the travel disruption intelligence API: live signals (IT outages, aviation programs, weather warnings, natural hazards, advisories, internet outages), exposure checks for flights, trips, places, carriers and providers, and impact forecasts based on past events.
|
|
34
34
|
|
|
35
|
-
> **Not yet published.** This package is not on PyPI yet. Until it is, install it from this repository: `pip install ./python` (or build a wheel, see [Development](#development)).
|
|
36
|
-
|
|
37
35
|
- Python 3.9+, built on `httpx`. Sync `DisruptAPI` and async `AsyncDisruptAPI` clients.
|
|
38
36
|
- `TypedDict` models for every response (`disruptapi.types`), with a `py.typed` marker.
|
|
39
37
|
- Typed errors, automatic retries with backoff, rate-limit info on every response.
|
|
@@ -112,6 +110,9 @@ Parameter names are the API's own. Every method returns the `data` member of the
|
|
|
112
110
|
| `flights.outcome(carrier=, flight_number=, date=, origin=, destination=)` | `GET /v1/flights/outcome` |
|
|
113
111
|
| `flights.outlook(carrier=, origin=, destination=, date=, departure_time=)` | `GET /v1/flights/outlook` |
|
|
114
112
|
| `evidence.get(date=, airport=, origin=, destination=, carrier=, flight_number=)` | `GET /v1/evidence` (JSON) |
|
|
113
|
+
| `claims.check(cases, threshold=, min_delay_minutes=, include_weather=, idempotency_key=)` | `POST /v1/claims/check` (up to 50 cases, billed one request per case; retries reuse one Idempotency-Key) |
|
|
114
|
+
| `claims.coverage()` | `GET /v1/claims/coverage` |
|
|
115
|
+
| `itineraries.parse(text, reference_date=)` | `POST /v1/itineraries/parse` |
|
|
115
116
|
| `carriers.get(code)` | `GET /v1/carriers/{code}` |
|
|
116
117
|
| `sources.list()` | `GET /v1/sources` |
|
|
117
118
|
| `providers.list()` | `GET /v1/providers` |
|
|
@@ -340,3 +341,24 @@ python3 -m venv .venv
|
|
|
340
341
|
## License
|
|
341
342
|
|
|
342
343
|
MIT, copyright Digital Envision LLC.
|
|
344
|
+
|
|
345
|
+
## Claims check
|
|
346
|
+
|
|
347
|
+
```python
|
|
348
|
+
from disruptapi import DisruptAPI
|
|
349
|
+
|
|
350
|
+
client = DisruptAPI()
|
|
351
|
+
results = client.claims.check([
|
|
352
|
+
{"case_id": "CLM-1001", "segments": [
|
|
353
|
+
{"carrier": "AA", "flight_number": 688, "date": "2025-11-26", "origin": "JFK", "destination": "MIA"}]},
|
|
354
|
+
{"case_id": "CLM-1002", "text": open("itinerary.txt").read()}, # a pasted PNR or booking email
|
|
355
|
+
], threshold=90)
|
|
356
|
+
for case in results:
|
|
357
|
+
s = case.get("summary") or {}
|
|
358
|
+
print(case["case_id"], s.get("category"), s.get("confidence"), "review" if s.get("needs_review") else "ok")
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
Each flight comes back with `outcome`, `cause` (`category` is `airline_controllable` or
|
|
362
|
+
`extraordinary`), `confidence`, `meets_threshold`, `evidence` (with source links) and
|
|
363
|
+
`evidence_pdf_url`; `connections` say whether a connection was missed and whether it was a
|
|
364
|
+
self-transfer on separate tickets.
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
The official Python client for [DisruptAPI](https://disruptapi.com), the travel disruption intelligence API: live signals (IT outages, aviation programs, weather warnings, natural hazards, advisories, internet outages), exposure checks for flights, trips, places, carriers and providers, and impact forecasts based on past events.
|
|
4
4
|
|
|
5
|
-
> **Not yet published.** This package is not on PyPI yet. Until it is, install it from this repository: `pip install ./python` (or build a wheel, see [Development](#development)).
|
|
6
|
-
|
|
7
5
|
- Python 3.9+, built on `httpx`. Sync `DisruptAPI` and async `AsyncDisruptAPI` clients.
|
|
8
6
|
- `TypedDict` models for every response (`disruptapi.types`), with a `py.typed` marker.
|
|
9
7
|
- Typed errors, automatic retries with backoff, rate-limit info on every response.
|
|
@@ -82,6 +80,9 @@ Parameter names are the API's own. Every method returns the `data` member of the
|
|
|
82
80
|
| `flights.outcome(carrier=, flight_number=, date=, origin=, destination=)` | `GET /v1/flights/outcome` |
|
|
83
81
|
| `flights.outlook(carrier=, origin=, destination=, date=, departure_time=)` | `GET /v1/flights/outlook` |
|
|
84
82
|
| `evidence.get(date=, airport=, origin=, destination=, carrier=, flight_number=)` | `GET /v1/evidence` (JSON) |
|
|
83
|
+
| `claims.check(cases, threshold=, min_delay_minutes=, include_weather=, idempotency_key=)` | `POST /v1/claims/check` (up to 50 cases, billed one request per case; retries reuse one Idempotency-Key) |
|
|
84
|
+
| `claims.coverage()` | `GET /v1/claims/coverage` |
|
|
85
|
+
| `itineraries.parse(text, reference_date=)` | `POST /v1/itineraries/parse` |
|
|
85
86
|
| `carriers.get(code)` | `GET /v1/carriers/{code}` |
|
|
86
87
|
| `sources.list()` | `GET /v1/sources` |
|
|
87
88
|
| `providers.list()` | `GET /v1/providers` |
|
|
@@ -310,3 +311,24 @@ python3 -m venv .venv
|
|
|
310
311
|
## License
|
|
311
312
|
|
|
312
313
|
MIT, copyright Digital Envision LLC.
|
|
314
|
+
|
|
315
|
+
## Claims check
|
|
316
|
+
|
|
317
|
+
```python
|
|
318
|
+
from disruptapi import DisruptAPI
|
|
319
|
+
|
|
320
|
+
client = DisruptAPI()
|
|
321
|
+
results = client.claims.check([
|
|
322
|
+
{"case_id": "CLM-1001", "segments": [
|
|
323
|
+
{"carrier": "AA", "flight_number": 688, "date": "2025-11-26", "origin": "JFK", "destination": "MIA"}]},
|
|
324
|
+
{"case_id": "CLM-1002", "text": open("itinerary.txt").read()}, # a pasted PNR or booking email
|
|
325
|
+
], threshold=90)
|
|
326
|
+
for case in results:
|
|
327
|
+
s = case.get("summary") or {}
|
|
328
|
+
print(case["case_id"], s.get("category"), s.get("confidence"), "review" if s.get("needs_review") else "ok")
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
Each flight comes back with `outcome`, `cause` (`category` is `airline_controllable` or
|
|
332
|
+
`extraordinary`), `confidence`, `meets_threshold`, `evidence` (with source links) and
|
|
333
|
+
`evidence_pdf_url`; `connections` say whether a connection was missed and whether it was a
|
|
334
|
+
self-transfer on separate tickets.
|
|
@@ -42,6 +42,8 @@ class DisruptAPI(SyncAPIClient):
|
|
|
42
42
|
self.severities = sr.Severities(self)
|
|
43
43
|
self.flights = sr.Flights(self)
|
|
44
44
|
self.evidence = sr.Evidence(self)
|
|
45
|
+
self.claims = sr.Claims(self)
|
|
46
|
+
self.itineraries = sr.Itineraries(self)
|
|
45
47
|
|
|
46
48
|
def with_options(self, *, timeout: Optional[float] = None, max_retries: Optional[int] = None) -> "DisruptAPI":
|
|
47
49
|
"""A copy with other options, sharing the HTTP connection pool."""
|
|
@@ -95,6 +97,8 @@ class AsyncDisruptAPI(AsyncAPIClient):
|
|
|
95
97
|
self.severities = ar.Severities(self)
|
|
96
98
|
self.flights = ar.Flights(self)
|
|
97
99
|
self.evidence = ar.Evidence(self)
|
|
100
|
+
self.claims = ar.Claims(self)
|
|
101
|
+
self.itineraries = ar.Itineraries(self)
|
|
98
102
|
|
|
99
103
|
def with_options(self, *, timeout: Optional[float] = None, max_retries: Optional[int] = None) -> "AsyncDisruptAPI":
|
|
100
104
|
"""A copy with other options, sharing the HTTP connection pool."""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.3.0"
|
|
@@ -209,6 +209,33 @@ def evidence_get(*, date_: Union[str, date], airport: Optional[str], origin: Opt
|
|
|
209
209
|
"carrier": carrier, "flight_number": flight_number})
|
|
210
210
|
|
|
211
211
|
|
|
212
|
+
def claims_check(cases: Iterable[Dict[str, Any]], *, threshold: Optional[int], min_delay_minutes: Optional[int],
|
|
213
|
+
include_weather: Optional[bool], idempotency_key: Optional[str]) -> RequestSpec:
|
|
214
|
+
body = _drop_none({"cases": [_case(c) for c in cases], "threshold": threshold,
|
|
215
|
+
"min_delay_minutes": min_delay_minutes, "include_weather": include_weather})
|
|
216
|
+
# Billed per case: a retry is safe only with the same Idempotency-Key (the API then answers
|
|
217
|
+
# with the first result and bills nothing more).
|
|
218
|
+
return _idempotent(RequestSpec("POST", "/v1/claims/check", body=body), idempotency_key)
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
def _case(c: Dict[str, Any]) -> Dict[str, Any]:
|
|
222
|
+
out = dict(c)
|
|
223
|
+
if out.get("segments") is not None:
|
|
224
|
+
out["segments"] = [{**seg, "date": _day(seg["date"])} if seg.get("date") is not None else dict(seg)
|
|
225
|
+
for seg in out["segments"]]
|
|
226
|
+
return out
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
def claims_coverage() -> RequestSpec:
|
|
230
|
+
return RequestSpec("GET", "/v1/claims/coverage")
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
def itineraries_parse(text: str, reference_date: Union[str, date, None]) -> RequestSpec:
|
|
234
|
+
body = _drop_none({"text": text, "reference_date": _day(reference_date) if reference_date else None})
|
|
235
|
+
# Read-only: safe to retry like a GET.
|
|
236
|
+
return RequestSpec("POST", "/v1/itineraries/parse", body=body, idempotent=True)
|
|
237
|
+
|
|
238
|
+
|
|
212
239
|
def _day(d: Union[str, date]) -> str:
|
|
213
240
|
return d.isoformat()[:10] if isinstance(d, (date, datetime)) else d
|
|
214
241
|
|
|
@@ -313,3 +313,27 @@ class Evidence(_Resource):
|
|
|
313
313
|
``destination``) or a flight (``carrier`` and ``flight_number``) on one day (JSON form)."""
|
|
314
314
|
return await self._data(s.evidence_get(date_=date, airport=airport, origin=origin, # type: ignore[no-any-return]
|
|
315
315
|
destination=destination, carrier=carrier, flight_number=flight_number))
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
class Claims(_Resource):
|
|
319
|
+
async def check(self, cases: Iterable[Dict[str, Any]], *, threshold: Optional[int] = None,
|
|
320
|
+
min_delay_minutes: Optional[int] = None, include_weather: Optional[bool] = None,
|
|
321
|
+
idempotency_key: Optional[str] = None) -> List[Dict[str, Any]]:
|
|
322
|
+
"""``POST /v1/claims/check``: up to 50 cases, each ``{"case_id", "segments": [...]}`` or
|
|
323
|
+
``{"case_id", "text": "<pasted itinerary>"}``. Per flight: what happened, the cause
|
|
324
|
+
(airline_controllable or extraordinary), a confidence 0-100 against ``threshold``, the
|
|
325
|
+
evidence with source links and a PDF link; per pair of flights, missed connections. Billed
|
|
326
|
+
one request per case. Retries reuse one Idempotency-Key, so a retry is never billed twice."""
|
|
327
|
+
return await self._data(s.claims_check(cases, threshold=threshold, min_delay_minutes=min_delay_minutes, # type: ignore[no-any-return]
|
|
328
|
+
include_weather=include_weather, idempotency_key=idempotency_key))
|
|
329
|
+
|
|
330
|
+
async def coverage(self) -> Dict[str, Any]:
|
|
331
|
+
"""``GET /v1/claims/coverage``: claims evidence by type and region, and the accuracy benchmark."""
|
|
332
|
+
return await self._data(s.claims_coverage()) # type: ignore[no-any-return]
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
class Itineraries(_Resource):
|
|
336
|
+
async def parse(self, text: str, *, reference_date: Union[str, date, None] = None) -> Dict[str, Any]:
|
|
337
|
+
"""``POST /v1/itineraries/parse``: flight segments from a pasted PNR/GDS display or booking
|
|
338
|
+
email, read by fixed rules (no AI model) and never stored."""
|
|
339
|
+
return await self._data(s.itineraries_parse(text, reference_date)) # type: ignore[no-any-return]
|
|
@@ -305,3 +305,27 @@ class Evidence(_Resource):
|
|
|
305
305
|
``destination``) or a flight (``carrier`` and ``flight_number``) on one day (JSON form)."""
|
|
306
306
|
return self._data(s.evidence_get(date_=date, airport=airport, origin=origin, # type: ignore[no-any-return]
|
|
307
307
|
destination=destination, carrier=carrier, flight_number=flight_number))
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
class Claims(_Resource):
|
|
311
|
+
def check(self, cases: Iterable[Dict[str, Any]], *, threshold: Optional[int] = None,
|
|
312
|
+
min_delay_minutes: Optional[int] = None, include_weather: Optional[bool] = None,
|
|
313
|
+
idempotency_key: Optional[str] = None) -> List[Dict[str, Any]]:
|
|
314
|
+
"""``POST /v1/claims/check``: up to 50 cases, each ``{"case_id", "segments": [...]}`` or
|
|
315
|
+
``{"case_id", "text": "<pasted itinerary>"}``. Per flight: what happened, the cause
|
|
316
|
+
(airline_controllable or extraordinary), a confidence 0-100 against ``threshold``, the
|
|
317
|
+
evidence with source links and a PDF link; per pair of flights, missed connections. Billed
|
|
318
|
+
one request per case. Retries reuse one Idempotency-Key, so a retry is never billed twice."""
|
|
319
|
+
return self._data(s.claims_check(cases, threshold=threshold, min_delay_minutes=min_delay_minutes, # type: ignore[no-any-return]
|
|
320
|
+
include_weather=include_weather, idempotency_key=idempotency_key))
|
|
321
|
+
|
|
322
|
+
def coverage(self) -> Dict[str, Any]:
|
|
323
|
+
"""``GET /v1/claims/coverage``: claims evidence by type and region, and the accuracy benchmark."""
|
|
324
|
+
return self._data(s.claims_coverage()) # type: ignore[no-any-return]
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
class Itineraries(_Resource):
|
|
328
|
+
def parse(self, text: str, *, reference_date: Union[str, date, None] = None) -> Dict[str, Any]:
|
|
329
|
+
"""``POST /v1/itineraries/parse``: flight segments from a pasted PNR/GDS display or booking
|
|
330
|
+
email, read by fixed rules (no AI model) and never stored."""
|
|
331
|
+
return self._data(s.itineraries_parse(text, reference_date)) # type: ignore[no-any-return]
|
|
@@ -83,3 +83,27 @@ def test_incidents_list_pages(make_client):
|
|
|
83
83
|
])
|
|
84
84
|
assert [i["id"] for i in c.incidents.list(type=["weather", "aviation"], limit=1)] == ["inc_1", "inc_2"]
|
|
85
85
|
assert rec.lines()[0] == "GET /v1/incidents?type=weather%2Caviation&limit=1&offset=0"
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def test_claims_check_coverage_and_itinerary_parse(make_client):
|
|
89
|
+
from datetime import date
|
|
90
|
+
|
|
91
|
+
case = {"case_id": "C-1", "summary": {"category": "airline_controllable", "confidence": 95}}
|
|
92
|
+
c, rec = make_client([
|
|
93
|
+
{"status": 503, "body": {"error": {"code": "internal_error", "message": "x"}}},
|
|
94
|
+
{"body": {"data": [case], "meta": {"cases": 1, "billed_requests": 1}}},
|
|
95
|
+
{"body": {"data": {"evidence_types": [], "regions": [], "benchmark": None}}},
|
|
96
|
+
{"body": {"data": {"segments": [{"carrier": "EK", "flight_number": 202}], "separate_tickets": False}}},
|
|
97
|
+
])
|
|
98
|
+
out = c.claims.check([{"case_id": "C-1", "segments": [{"carrier": "AA", "flight_number": 688,
|
|
99
|
+
"date": date(2025, 11, 26)}]}], threshold=90)
|
|
100
|
+
assert out == [case]
|
|
101
|
+
# Billed per case: retried once, with the same Idempotency-Key, so it is never billed twice.
|
|
102
|
+
assert rec.lines()[:2] == ["POST /v1/claims/check", "POST /v1/claims/check"]
|
|
103
|
+
keys = {rec.requests[i].headers["idempotency-key"] for i in (0, 1)}
|
|
104
|
+
assert len(keys) == 1
|
|
105
|
+
assert rec.body(1) == {"cases": [{"case_id": "C-1", "segments": [{"carrier": "AA", "flight_number": 688,
|
|
106
|
+
"date": "2025-11-26"}]}], "threshold": 90}
|
|
107
|
+
assert c.claims.coverage()["regions"] == []
|
|
108
|
+
assert c.itineraries.parse("EK202 JFK-DXB 15 Mar", reference_date=date(2026, 11, 30))["segments"][0]["flight_number"] == 202
|
|
109
|
+
assert rec.body(3) == {"text": "EK202 JFK-DXB 15 Mar", "reference_date": "2026-11-30"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.2.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|