summaryrefslogtreecommitdiff
path: root/windy.py
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-09-22 22:56:29 +0200
committerAki <please@ignore.pl>2022-09-22 22:56:29 +0200
commitdc36c343f493375560350cec3d1beab469f30302 (patch)
tree3888bbd78044fdf58e3dece9534d237a8e7240e6 /windy.py
downloadwindy-dc36c343f493375560350cec3d1beab469f30302.zip
windy-dc36c343f493375560350cec3d1beab469f30302.tar.gz
windy-dc36c343f493375560350cec3d1beab469f30302.tar.bz2
Created stub request to point forecast endpoint
Diffstat (limited to 'windy.py')
-rw-r--r--windy.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/windy.py b/windy.py
new file mode 100644
index 0000000..3938ed6
--- /dev/null
+++ b/windy.py
@@ -0,0 +1,37 @@
+from enum import Enum
+
+import requests
+
+API = "https://api.windy.com/api"
+
+
+class Model(Enum):
+ ICONEU = "iconEu"
+
+ def __str__(self):
+ return self.value
+
+
+class PointForecast:
+ ENDPOINT = "/point-forecast/v2"
+
+ def __init__(self, lat: float, lon: float, model: Model, parameters=None, levels=None, key=None):
+ self.lat = lat
+ self.lon = lon
+ self.model = model
+ self.parameters = parameters or []
+ self.levels = levels or ["surface"]
+ self.key = key
+
+ def request(self, /, key=None):
+ return requests.post(API + self.ENDPOINT, json=self.body(key=key))
+
+ def body(self, /, lat=None, lon=None, model=None, parameters=None, levels=None, key=None):
+ return {
+ 'lat': lat or self.lat,
+ 'lon': lon or self.lon,
+ 'model': str(model or self.model),
+ 'parameters': parameters or self.parameters,
+ 'levels': levels or self.levels,
+ 'key': key or self.key,
+ }