Windy Community
    • Unread
    • Categories
    • Groups
    • Go to windy.com
    • Register
    • Login

    Point Forecast request returns Error 404

    Scheduled Pinned Locked Moved Windy API v4
    2 Posts 2 Posters 943 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Mohaimenul IslamM Offline
      Mohaimenul Islam
      last edited by

      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")
      
      SutyS 1 Reply Last reply Reply Quote 0
      • SutyS Offline
        Suty Windy Staff @Mohaimenul Islam
        last edited by

        @Mohaimenul-Islam Hi, you need to send the POST request according to our documentation, but you call .get in your code

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Windy Community  |  Powered by excellent NodeBB
        Terms of Use     Privacy Policy     Windy.com