openvan 0.3.0__tar.gz → 0.5.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.
- {openvan-0.3.0 → openvan-0.5.0}/PKG-INFO +16 -4
- {openvan-0.3.0 → openvan-0.5.0}/README.md +15 -3
- {openvan-0.3.0 → openvan-0.5.0}/src/openvan/api.py +88 -0
- {openvan-0.3.0 → openvan-0.5.0}/src/openvan/client.py +1 -1
- {openvan-0.3.0 → openvan-0.5.0}/tests/test_openvan.py +40 -0
- {openvan-0.3.0 → openvan-0.5.0}/.gitignore +0 -0
- {openvan-0.3.0 → openvan-0.5.0}/LICENSE +0 -0
- {openvan-0.3.0 → openvan-0.5.0}/pyproject.toml +0 -0
- {openvan-0.3.0 → openvan-0.5.0}/src/openvan/__init__.py +0 -0
- {openvan-0.3.0 → openvan-0.5.0}/src/openvan/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: openvan
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
4
4
|
Summary: Free vanlife & RV travel data: fuel prices in 160+ countries, toll roads, visa rules, holidays, travel hazards, weather scores, currency. No API key.
|
|
5
5
|
Project-URL: Homepage, https://openvan.camp/en/developers?utm_source=pypi&utm_medium=referral&utm_campaign=python-sdk
|
|
6
6
|
Project-URL: Documentation, https://openvan.camp/docs?utm_source=pypi&utm_medium=referral&utm_campaign=python-sdk
|
|
@@ -24,8 +24,8 @@ Description-Content-Type: text/markdown
|
|
|
24
24
|
|
|
25
25
|
# openvan — Python client for the OpenVan.camp API
|
|
26
26
|
|
|
27
|
-
Free vanlife & RV travel data in Python: fuel prices in
|
|
28
|
-
vehicle-import rules, public and school holidays, travel hazards and wildfires, customs rules,
|
|
27
|
+
Free vanlife & RV travel data in Python: whole-trip roadbooks, fuel prices in 170+ countries, toll roads, ferry
|
|
28
|
+
crossings and timetables, biting insects by place and month, visa and vehicle-import rules, public and school holidays, travel hazards and wildfires, customs rules,
|
|
29
29
|
power plugs, weather suitability scores, food cost index, currency rates, events, news and
|
|
30
30
|
license plates of the world.
|
|
31
31
|
|
|
@@ -40,7 +40,7 @@ pip install openvan
|
|
|
40
40
|
```python
|
|
41
41
|
from openvan import OpenVan
|
|
42
42
|
|
|
43
|
-
ov = OpenVan(source="myapp.com") #
|
|
43
|
+
ov = OpenVan(source="myapp.com") # your site or app name; the default "openvan-python" does not identify you
|
|
44
44
|
|
|
45
45
|
# Cheapest diesel in the world right now, EUR per liter
|
|
46
46
|
for c in ov.fuel.cheapest("diesel", 5):
|
|
@@ -67,6 +67,18 @@ print(batumi["day"]["temp_day_c"], batumi["day"]["precipitation_days_of_35"], ba
|
|
|
67
67
|
|
|
68
68
|
# School holidays in Germany this autumn, by federal state
|
|
69
69
|
ov.holidays.country("DE", from_="2026-10-01", to="2026-12-31", kind="school")
|
|
70
|
+
|
|
71
|
+
# Ferries in the Tyrrhenian Sea (OpenStreetMap, ODbL) and the next departures of one line
|
|
72
|
+
lines = [f["properties"] for f in ov.ferries.window((8, 38, 16, 42), zoom=6)["features"] if f["properties"]["kind"] == "route"]
|
|
73
|
+
print(ov.ferries.schedule("r5958961")["directions"][0]["next"])
|
|
74
|
+
|
|
75
|
+
# Who bites near Kiruna in July (Bug Season): level 0-3 for the month; None = not studied
|
|
76
|
+
for g in ov.bites.place(67.85, 20.22, date="2027-07-10")["groups"]:
|
|
77
|
+
print(g["name"], g["level"], g["status"])
|
|
78
|
+
|
|
79
|
+
# A whole trip plan: route, days, budget and rules for every country (waits up to 60 s)
|
|
80
|
+
trip = ov.roadbook.plan(["Munich", "Venice"], inputs={"travelers": ["DE"]})
|
|
81
|
+
print("https://openvan.camp" + trip["url"])
|
|
70
82
|
```
|
|
71
83
|
|
|
72
84
|
### With pandas
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# openvan — Python client for the OpenVan.camp API
|
|
2
2
|
|
|
3
|
-
Free vanlife & RV travel data in Python: fuel prices in
|
|
4
|
-
vehicle-import rules, public and school holidays, travel hazards and wildfires, customs rules,
|
|
3
|
+
Free vanlife & RV travel data in Python: whole-trip roadbooks, fuel prices in 170+ countries, toll roads, ferry
|
|
4
|
+
crossings and timetables, biting insects by place and month, visa and vehicle-import rules, public and school holidays, travel hazards and wildfires, customs rules,
|
|
5
5
|
power plugs, weather suitability scores, food cost index, currency rates, events, news and
|
|
6
6
|
license plates of the world.
|
|
7
7
|
|
|
@@ -16,7 +16,7 @@ pip install openvan
|
|
|
16
16
|
```python
|
|
17
17
|
from openvan import OpenVan
|
|
18
18
|
|
|
19
|
-
ov = OpenVan(source="myapp.com") #
|
|
19
|
+
ov = OpenVan(source="myapp.com") # your site or app name; the default "openvan-python" does not identify you
|
|
20
20
|
|
|
21
21
|
# Cheapest diesel in the world right now, EUR per liter
|
|
22
22
|
for c in ov.fuel.cheapest("diesel", 5):
|
|
@@ -43,6 +43,18 @@ print(batumi["day"]["temp_day_c"], batumi["day"]["precipitation_days_of_35"], ba
|
|
|
43
43
|
|
|
44
44
|
# School holidays in Germany this autumn, by federal state
|
|
45
45
|
ov.holidays.country("DE", from_="2026-10-01", to="2026-12-31", kind="school")
|
|
46
|
+
|
|
47
|
+
# Ferries in the Tyrrhenian Sea (OpenStreetMap, ODbL) and the next departures of one line
|
|
48
|
+
lines = [f["properties"] for f in ov.ferries.window((8, 38, 16, 42), zoom=6)["features"] if f["properties"]["kind"] == "route"]
|
|
49
|
+
print(ov.ferries.schedule("r5958961")["directions"][0]["next"])
|
|
50
|
+
|
|
51
|
+
# Who bites near Kiruna in July (Bug Season): level 0-3 for the month; None = not studied
|
|
52
|
+
for g in ov.bites.place(67.85, 20.22, date="2027-07-10")["groups"]:
|
|
53
|
+
print(g["name"], g["level"], g["status"])
|
|
54
|
+
|
|
55
|
+
# A whole trip plan: route, days, budget and rules for every country (waits up to 60 s)
|
|
56
|
+
trip = ov.roadbook.plan(["Munich", "Venice"], inputs={"travelers": ["DE"]})
|
|
57
|
+
print("https://openvan.camp" + trip["url"])
|
|
46
58
|
```
|
|
47
59
|
|
|
48
60
|
### With pandas
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import math
|
|
6
|
+
import time
|
|
6
7
|
from typing import Any, Dict, List, Optional, Sequence, Tuple
|
|
7
8
|
from urllib.parse import quote
|
|
8
9
|
|
|
@@ -46,6 +47,9 @@ class OpenVan:
|
|
|
46
47
|
self.hazards = Hazards(self.client)
|
|
47
48
|
self.electricity = Electricity(self.client)
|
|
48
49
|
self.customs = Customs(self.client)
|
|
50
|
+
self.roadbook = Roadbook(self.client)
|
|
51
|
+
self.ferries = Ferries(self.client)
|
|
52
|
+
self.bites = Bites(self.client)
|
|
49
53
|
|
|
50
54
|
|
|
51
55
|
class _Resource:
|
|
@@ -225,6 +229,10 @@ class Stories(_Resource):
|
|
|
225
229
|
"""Semantic search over stories."""
|
|
226
230
|
return self.client.get("/api/news/search", {"q": query, **options})
|
|
227
231
|
|
|
232
|
+
def digest(self, locale: Optional[str] = None) -> JSON:
|
|
233
|
+
"""Today's news digest."""
|
|
234
|
+
return self.client.get("/api/news/digest", {"locale": locale})
|
|
235
|
+
|
|
228
236
|
|
|
229
237
|
class Tolls(_Resource):
|
|
230
238
|
def countries(self, locale: Optional[str] = None) -> JSON:
|
|
@@ -373,3 +381,83 @@ class Customs(_Resource):
|
|
|
373
381
|
f"/api/customs/countries/{code.upper()}",
|
|
374
382
|
{"from": from_country.upper() if from_country else None, "locale": locale},
|
|
375
383
|
)
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
class Roadbook(_Resource):
|
|
387
|
+
def create(self, places: Sequence[str], locale: str = "en", name: Optional[str] = None, inputs: Optional[JSON] = None) -> JSON:
|
|
388
|
+
"""Create a roadbook from 2–10 place names — the same trip plan as the OpenVan roadbook wizard.
|
|
389
|
+
|
|
390
|
+
Identical requests return the same roadbook. The route is built in the background: use
|
|
391
|
+
:meth:`status` or :meth:`plan` to wait for it.
|
|
392
|
+
"""
|
|
393
|
+
return self.client.post(
|
|
394
|
+
"/api/roadbook/from-places",
|
|
395
|
+
{"places": list(places), "locale": locale, "name": name or " — ".join(places)[:80], "inputs": inputs or {}},
|
|
396
|
+
)
|
|
397
|
+
|
|
398
|
+
def status(self, code: str) -> JSON:
|
|
399
|
+
"""Build status of a roadbook: ``pending``, ``building``, ``ready`` or ``failed``."""
|
|
400
|
+
return self.client.get(f"/api/roadbook/{quote(code)}/status")
|
|
401
|
+
|
|
402
|
+
def plan(self, places: Sequence[str], timeout: float = 60.0, **options: Any) -> JSON:
|
|
403
|
+
"""Create a roadbook and wait until its route is built (default up to 60 s).
|
|
404
|
+
|
|
405
|
+
Open ``https://openvan.camp`` + ``url`` of the result for the full plan.
|
|
406
|
+
"""
|
|
407
|
+
created = self.create(places, **options)
|
|
408
|
+
deadline = time.monotonic() + timeout
|
|
409
|
+
status = created.get("status")
|
|
410
|
+
while status not in ("ready", "failed") and time.monotonic() < deadline:
|
|
411
|
+
time.sleep(1.5)
|
|
412
|
+
status = self.status(created["code"])["status"]
|
|
413
|
+
return {**created, "status": status}
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
class Ferries(_Resource):
|
|
417
|
+
def window(self, bbox: Tuple[float, float, float, float], zoom: Optional[float] = None) -> JSON:
|
|
418
|
+
"""Ferry and river crossing lines and ports in ``(min_lon, min_lat, max_lon, max_lat)`` as GeoJSON.
|
|
419
|
+
|
|
420
|
+
OpenStreetMap data (ODbL). ``zoom`` (0–22, default 8) sets geometry detail; at most 1400
|
|
421
|
+
features, ``truncated: True`` means zoom in.
|
|
422
|
+
"""
|
|
423
|
+
return self.client.get("/api/ferries", {"bbox": ",".join(str(v) for v in bbox), "zoom": zoom})
|
|
424
|
+
|
|
425
|
+
def get(self, id: str) -> JSON:
|
|
426
|
+
"""One ferry line or port by OSM id (e.g. ``r5958961``): tags, verified operator site, both ends."""
|
|
427
|
+
return self.client.get(f"/api/ferries/{quote(id)}")
|
|
428
|
+
|
|
429
|
+
def schedule(self, id: str) -> JSON:
|
|
430
|
+
"""Timetable digest from open GTFS feeds: next departures, weekdays, rhythm, travel time.
|
|
431
|
+
|
|
432
|
+
``available: False`` means no open timetable is matched, not that the ferry does not run.
|
|
433
|
+
"""
|
|
434
|
+
return self.client.get(f"/api/ferries/{quote(id)}/schedule")
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
class Bites(_Resource):
|
|
438
|
+
"""Bug Season: biting, stinging and burning insects by place and month.
|
|
439
|
+
|
|
440
|
+
``level`` is 0 none, 1 tolerable, 2 many, 3 unbearable. ``None`` means "not studied", never
|
|
441
|
+
"no insects"; a group in ``hidden`` is not confirmed at that place, which is not "absent".
|
|
442
|
+
"""
|
|
443
|
+
|
|
444
|
+
def groups(self, locale: Optional[str] = None) -> JSON:
|
|
445
|
+
"""The 18 groups (name, taxon, when they bite, icon) and ``definitions`` of every level and field."""
|
|
446
|
+
return self.client.get("/api/bites/groups", {"locale": locale})
|
|
447
|
+
|
|
448
|
+
def place(self, lat: float, lng: float, date: Optional[str] = None, locale: Optional[str] = None) -> JSON:
|
|
449
|
+
"""Groups at a point, worst first, with the level for the month of ``date`` (YYYY-MM-DD) and all 12 months."""
|
|
450
|
+
return self.client.get("/api/bites/place", {"lat": lat, "lng": lng, "date": date, "locale": locale})
|
|
451
|
+
|
|
452
|
+
def route(self, stops: Sequence[Tuple[Any, ...]], locale: Optional[str] = None) -> JSON:
|
|
453
|
+
"""Up to 25 stops as ``(lat, lng)`` or ``(lat, lng, "YYYY-MM-DD")``. 30 requests per minute."""
|
|
454
|
+
encoded = "|".join(",".join(str(v) for v in stop) for stop in stops)
|
|
455
|
+
return self.client.get("/api/bites/route", {"stops": encoded, "locale": locale})
|
|
456
|
+
|
|
457
|
+
def country(self, code: str, locale: Optional[str] = None) -> JSON:
|
|
458
|
+
"""Season of every group in a country and each of its regions (status, 12 monthly levels)."""
|
|
459
|
+
return self.client.get(f"/api/bites/countries/{code.upper()}", {"locale": locale})
|
|
460
|
+
|
|
461
|
+
def coverage(self) -> JSON:
|
|
462
|
+
"""What is studied: per country, how many region × group pairs are in each status."""
|
|
463
|
+
return self.client.get("/api/bites/coverage")
|
|
@@ -153,6 +153,42 @@ class OpenVanTest(unittest.TestCase):
|
|
|
153
153
|
query = parse_qs(urlparse(calls[0].full_url).query)
|
|
154
154
|
self.assertEqual(query["from"], ["2026-10-01"])
|
|
155
155
|
|
|
156
|
+
def test_ferries_window_joins_bbox_and_passes_zoom(self):
|
|
157
|
+
fake, calls = respond({"/api/ferries": {"type": "FeatureCollection", "features": []}})
|
|
158
|
+
with mock.patch("openvan.client.urlopen", fake):
|
|
159
|
+
OpenVan().ferries.window((4.9, 58.8, 6.2, 59.4), zoom=9)
|
|
160
|
+
query = parse_qs(urlparse(calls[0].full_url).query)
|
|
161
|
+
self.assertEqual((query["bbox"], query["zoom"]), (["4.9,58.8,6.2,59.4"], ["9"]))
|
|
162
|
+
|
|
163
|
+
def test_ferry_schedule_path(self):
|
|
164
|
+
fake, calls = respond({"/api/ferries/r5958961/schedule": {"available": False}})
|
|
165
|
+
with mock.patch("openvan.client.urlopen", fake):
|
|
166
|
+
self.assertFalse(OpenVan().ferries.schedule("r5958961")["available"])
|
|
167
|
+
|
|
168
|
+
def test_bites_route_encodes_stops(self):
|
|
169
|
+
fake, calls = respond({"/api/bites/route": {"stops": []}})
|
|
170
|
+
with mock.patch("openvan.client.urlopen", fake):
|
|
171
|
+
OpenVan().bites.route([(48.708, 44.513, "2027-06-10"), (43.21, 27.91)])
|
|
172
|
+
query = parse_qs(urlparse(calls[0].full_url).query)
|
|
173
|
+
self.assertEqual(query["stops"], ["48.708,44.513,2027-06-10|43.21,27.91"])
|
|
174
|
+
|
|
175
|
+
def test_bites_place_passes_date(self):
|
|
176
|
+
fake, calls = respond({"/api/bites/place": {"groups": []}})
|
|
177
|
+
with mock.patch("openvan.client.urlopen", fake):
|
|
178
|
+
OpenVan().bites.place(48.708, 44.513, date="2027-06-10")
|
|
179
|
+
query = parse_qs(urlparse(calls[0].full_url).query)
|
|
180
|
+
self.assertEqual((query["lat"], query["date"]), (["48.708"], ["2027-06-10"]))
|
|
181
|
+
|
|
182
|
+
def test_roadbook_plan_polls_until_ready(self):
|
|
183
|
+
fake, calls = respond({
|
|
184
|
+
"/api/roadbook/from-places": {"code": "abc12", "status": "building", "url": "/en/roadbook/abc12"},
|
|
185
|
+
"/api/roadbook/abc12/status": {"status": "ready", "error": None},
|
|
186
|
+
})
|
|
187
|
+
with mock.patch("openvan.client.urlopen", fake), mock.patch("openvan.api.time.sleep"):
|
|
188
|
+
result = OpenVan().roadbook.plan(["Munich", "Venice"])
|
|
189
|
+
self.assertEqual(result["status"], "ready")
|
|
190
|
+
self.assertEqual(json.loads(calls[0].data)["places"], ["Munich", "Venice"])
|
|
191
|
+
|
|
156
192
|
def test_api_error_message_is_kept(self):
|
|
157
193
|
body = io.BytesIO(json.dumps({"message": "Place not found: Atlantis"}).encode())
|
|
158
194
|
error = HTTPError("https://openvan.camp/api/tolls/route", 422, "Unprocessable", {}, body)
|
|
@@ -188,6 +224,10 @@ class LiveSmokeTest(unittest.TestCase):
|
|
|
188
224
|
self.assertIn("advisory", ov.hazards.country("TR"))
|
|
189
225
|
self.assertIn("plugs", ov.electricity.country("GB"))
|
|
190
226
|
self.assertIn("items", ov.customs.country("TR", from_country="DE"))
|
|
227
|
+
self.assertIn("features", ov.ferries.window((4.9, 58.8, 6.2, 59.4), zoom=9))
|
|
228
|
+
self.assertIn("available", ov.ferries.schedule("r5958961"))
|
|
229
|
+
self.assertIn("groups", ov.bites.place(48.708, 44.513, date="2027-06-10"))
|
|
230
|
+
self.assertIn("definitions", ov.bites.groups())
|
|
191
231
|
|
|
192
232
|
|
|
193
233
|
if __name__ == "__main__":
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|