openvan 0.1.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: openvan
3
- Version: 0.1.1
3
+ Version: 0.3.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
@@ -56,6 +56,15 @@ print(ov.tolls.route(["Rome", "Paris"], vehicle_class="van"))
56
56
  for c in ov.weather.top(5):
57
57
  print(c["code"], c["van_score"], c["score_label"])
58
58
 
59
+ # Countries of Europe by the score of the coming week (the site ranking), one city with its place
60
+ for c in ov.weather.ranking(region="europe", limit=5):
61
+ print(c["rank"], c["name"], c["week_score"])
62
+ print(ov.weather.city("GE", "batumi")["rank"])
63
+
64
+ # Typical weather (climate) in Batumi on 18 September and the best month to go
65
+ batumi = ov.weather.city_climate("GE", "batumi", date="09-18")
66
+ print(batumi["day"]["temp_day_c"], batumi["day"]["precipitation_days_of_35"], batumi["best_month"])
67
+
59
68
  # School holidays in Germany this autumn, by federal state
60
69
  ov.holidays.country("DE", from_="2026-10-01", to="2026-12-31", kind="school")
61
70
  ```
@@ -32,6 +32,15 @@ print(ov.tolls.route(["Rome", "Paris"], vehicle_class="van"))
32
32
  for c in ov.weather.top(5):
33
33
  print(c["code"], c["van_score"], c["score_label"])
34
34
 
35
+ # Countries of Europe by the score of the coming week (the site ranking), one city with its place
36
+ for c in ov.weather.ranking(region="europe", limit=5):
37
+ print(c["rank"], c["name"], c["week_score"])
38
+ print(ov.weather.city("GE", "batumi")["rank"])
39
+
40
+ # Typical weather (climate) in Batumi on 18 September and the best month to go
41
+ batumi = ov.weather.city_climate("GE", "batumi", date="09-18")
42
+ print(batumi["day"]["temp_day_c"], batumi["day"]["precipitation_days_of_35"], batumi["best_month"])
43
+
35
44
  # School holidays in Germany this autumn, by federal state
36
45
  ov.holidays.country("DE", from_="2026-10-01", to="2026-12-31", kind="school")
37
46
  ```
@@ -143,6 +143,33 @@ class Weather(_Resource):
143
143
  """Vanlife weather of one country: ``van_score`` 0–100, ``score_label``, 7-day ``forecast``."""
144
144
  return self.client.get(f"/api/vansky/weather/{code.upper()}")["data"]
145
145
 
146
+ def city(self, code: str, city_slug: str, locale: Optional[str] = None, hourly: bool = False) -> JSON:
147
+ """One city, as on its page: score today and for the coming 7 days, place among the cities of the
148
+ country (``rank``), per-day score breakdown, worst day, best stretch, air quality, recommendations.
149
+ ``hourly=True`` adds 3-hour steps.
150
+ """
151
+ params = {"locale": locale, "include": "hourly" if hourly else None}
152
+ return self.client.get(f"/api/vansky/weather/{code.upper()}/{quote(city_slug)}", params)["data"]
153
+
154
+ def cities(
155
+ self, code: str, sort: str = "week", limit: Optional[int] = None, offset: Optional[int] = None,
156
+ locale: Optional[str] = None,
157
+ ) -> JSON:
158
+ """Cities of a country ranked by the score of the coming 7 days (``sort="week"``, as on the site) or today."""
159
+ params = {"sort": sort, "limit": limit, "offset": offset, "locale": locale}
160
+ return self.client.get(f"/api/vansky/weather/{code.upper()}/cities", params)
161
+
162
+ def ranking(
163
+ self, by: str = "week", region: Optional[str] = None, limit: Optional[int] = None, locale: Optional[str] = None
164
+ ) -> List[JSON]:
165
+ """Countries ranked by the score of the coming 7 days (``by="week"``) or today, optionally in one region."""
166
+ params = {"by": by, "region": region, "limit": limit, "locale": locale}
167
+ return self.client.get("/api/vansky/ranking", params)["data"]
168
+
169
+ def methodology(self) -> JSON:
170
+ """How the VanSky score is calculated: curves, weights, adjustments, week score."""
171
+ return self.client.get("/api/vansky/methodology")
172
+
146
173
  def all(self) -> List[JSON]:
147
174
  """Every country with weather data (one request, ~1 MB)."""
148
175
  return self.client.get("/api/vansky/weather")["data"]
@@ -151,6 +178,21 @@ class Weather(_Resource):
151
178
  """Top countries by vanlife weather suitability today, best first."""
152
179
  return sorted(self.all(), key=lambda c: c.get("van_score") or 0, reverse=True)[:limit]
153
180
 
181
+ def climate(self, lat: float, lng: float, date: Optional[str] = None) -> JSON:
182
+ """Typical weather (climate) at any point: median of 35 archive days (the date ±3 days over
183
+ 2021–2025, ERA5). With ``date`` (``MM-DD`` or ``YYYY-MM-DD``) the result has ``day``; without it,
184
+ ``days`` holds all 366 days. ``months``, ``best_month`` and ``good_months`` are always included.
185
+ """
186
+ return self.client.get("/api/vansky/climate", {"lat": lat, "lng": lng, "date": date})
187
+
188
+ def city_climate(
189
+ self, code: str, city_slug: str, date: Optional[str] = None, locale: Optional[str] = None
190
+ ) -> JSON:
191
+ """The same as :meth:`climate` for a VanSky city, plus the city name and page URL."""
192
+ return self.client.get(
193
+ f"/api/vansky/climate/{code.upper()}/{quote(city_slug)}", {"date": date, "locale": locale}
194
+ )
195
+
154
196
 
155
197
  class Events(_Resource):
156
198
  def list(self, **filters: Any) -> JSON:
@@ -8,7 +8,7 @@ from urllib.error import HTTPError, URLError
8
8
  from urllib.parse import urlencode
9
9
  from urllib.request import Request, urlopen
10
10
 
11
- __version__ = "0.1.1"
11
+ __version__ = "0.3.0"
12
12
 
13
13
  DEFAULT_BASE_URL = "https://openvan.camp"
14
14
 
@@ -104,6 +104,33 @@ class OpenVanTest(unittest.TestCase):
104
104
  with mock.patch("openvan.client.urlopen", fake):
105
105
  self.assertEqual([c["code"] for c in OpenVan().weather.top(2)], ["B", "C"])
106
106
 
107
+ def test_weather_city_hourly_and_ranking(self):
108
+ fake, calls = respond({
109
+ "/api/vansky/weather/GE/batumi": {"data": {"rank": {"position": 10, "total": 32}}},
110
+ "/api/vansky/ranking": {"data": [{"rank": 1, "code": "CL"}]},
111
+ })
112
+ with mock.patch("openvan.client.urlopen", fake):
113
+ self.assertEqual(OpenVan().weather.city("ge", "batumi", hourly=True)["rank"]["position"], 10)
114
+ self.assertEqual(OpenVan().weather.ranking(region="europe", limit=5)[0]["code"], "CL")
115
+ self.assertEqual(parse_qs(urlparse(calls[0].full_url).query)["include"], ["hourly"])
116
+ q = parse_qs(urlparse(calls[1].full_url).query)
117
+ self.assertEqual((q["by"], q["region"], q["limit"]), (["week"], ["europe"], ["5"]))
118
+
119
+ def test_climate_point_passes_lat_lng_and_date(self):
120
+ fake, calls = respond({"/api/vansky/climate": {"period": "2021–2025", "day": {"date": "09-18"}}})
121
+ with mock.patch("openvan.client.urlopen", fake):
122
+ self.assertEqual(OpenVan().weather.climate(41.64, 41.63, "09-18")["day"]["date"], "09-18")
123
+ q = parse_qs(urlparse(calls[0].full_url).query)
124
+ self.assertEqual((q["lat"], q["lng"], q["date"]), (["41.64"], ["41.63"], ["09-18"]))
125
+
126
+ def test_city_climate_without_date_drops_empty_params(self):
127
+ fake, calls = respond({"/api/vansky/climate/GE/batumi": {"period": "2021–2025", "months": []}})
128
+ with mock.patch("openvan.client.urlopen", fake):
129
+ OpenVan().weather.city_climate("ge", "batumi")
130
+ url = urlparse(calls[0].full_url)
131
+ self.assertEqual(url.path, "/api/vansky/climate/GE/batumi")
132
+ self.assertNotIn("date", parse_qs(url.query))
133
+
107
134
  def test_route_cost_posts_json(self):
108
135
  fake, calls = respond({"/api/route-cost": {"distance_km": 345}})
109
136
  with mock.patch("openvan.client.urlopen", fake):
File without changes
File without changes
File without changes
File without changes
File without changes