Hello!
I am attempting to use the point forecast api in a very simple piece of python code. But it returns error 404 everytime. What am I doing wrong? Here's the code, key has been replaced
import requests
def get_wind_data(lat, lon, api_key):
url = f"https://api.windy.com/api/point-forecast/v2"
params = {
"lat": lat,
"lon": lon,
"model": "gfs",
"parameters": ["wind"],
"levels": ["surface"],
"key": api_key,
}
response = requests.get(url, params=params)
if response.status_code == 200:
data = response.json()
wind_speed = data["wind"]["speed"]
wind_direction = data["wind"]["direction"]
return wind_speed, wind_direction
else:
print(f"Error: {response.status_code}")
return None, None
if __name__ == "__main__":
api_key = "1234"
lat = 49.123
lon = 15.008
wind_speed, wind_direction = get_wind_data(lat, lon, api_key)
if wind_speed is not None and wind_direction is not None:
print(f"Wind Speed: {wind_speed} m/s")
print(f"Wind Direction: {wind_direction} degrees")