SImple query through the API
-
I used to be a Pro-user of windy and have used other weather services. I need, through the windy API, to know ONLY the:
Temperature
Percentage of clouds
Wind speed and direction
Wind GustOf a spot of specific latitude/longitude.
I do not need more info through the API interface. I am using other services APIs and are relatively easier to use since the data the return is simpler. They use the GET protocol and directly return those values. I have tried the POST method Windy uses, and managed to get some data, but not the 5 previous values… I haven’t found neither an example nor good documentation on it.
Do you know a simple Python script to do it, or a specific piece of documentation?
-
@juanfal Hi, did you check the documentation here.
-
@Suty Thanks! I know where the document is, but it returns arrays of wind vectors, and I only need Wind Speed, Wind Gust, and Wind Direction. I haven't found any examples of those data retrieve.
-
This post is deleted! -
@juanfal
https://github.com/uniquezhiyuan/windy.com_api
Might get you started -
@Norman-Vine Wow, you have found the only example, in Chinese, that I have also found. It tells me that things aren't going any better than I suspected. The GitHub
uniquezhiyuan/windy.com_api
is a forecast based on a sql read of data read from a very particular and personal use of the resulting vectors programmed in something Python-based. Is that the simplest example for using windy on the whole internet?I was asking for something as basic as this:
API = 'weatherapi' APIKEY = 'the api key' weaAPI = requests.get(f'http://api.weatherapi.com/v1/current.json?key={APIKEY}&q={lat},{lon}').json() clouds = float(weaAPI['current']['cloud']) speed = float(weaAPI['current']['wind_kph']) gust = float(weaAPI['current']['gust_kph']) windD = int(weaAPI['current']['wind_degree']) temp = float(weaAPI['current']['temp_c'])
I understand that the answers from windy.com are much more complete and really interesting. But what I need right now is just those simple values. So the answer, I'm afraid, is that there are no examples of simple queries. am I wrong?
The simplest query to
windy.com
I have got from the documentation is:url = "https://api.windy.com/api/point-forecast/v2" post = { "lat": lat, "lon": lon, "model": "gfs", "parameters": ["temp", "wind", "windGust", "lclouds", "mclouds"], "levels": ["surface"], "key": APIKEY } try: windy = requests.post('https://api.windy.com/api/point-forecast/v2', json = post, timeout=3) windy.raise_for_status() except requests.exceptions.HTTPError as errh: print ("Http Error:", errh) except requests.exceptions.ConnectionError as errc: print ("Error Connecting:", errc) except requests.exceptions.Timeout as errt: print ("Timeout Error:", errt) except requests.exceptions.RequestException as err: print ("OOps Windy requests: Some error", err) windy = windy.json()
and the
print(windy)
gives me something like this:{'gust-surface': [2.6194823225185035, 3.0163365604850116, .... lots of lines with shuffled random values 2.4690057168341943], 'lclouds-surface': [0, 0, 0, .... lots of lines with shuffled random values 0, 4.843888058107189], 'mclouds-surface': [0, 0, 0, 0, .... lots of lines with shuffled random values 0, 0], 'temp-surface': [296.4423746203281, 297.58808776929845, 300.3296806435589, .... lots of lines with shuffled random values 298.22235477543, 295.07155453287373], 'ts': [1718874000000, 1718884800000, 1718895600000, .... lots of lines with shuffled random values 1719727200000], 'units': {'gust-surface': 'm*s-1', 'lclouds-surface': '%', 'mclouds-surface': '%', 'temp-surface': 'K', 'wind_u-surface': 'm*s-1', 'wind_v-surface': 'm*s-1'}, 'warning': 'The trial API version is for development purposes only. This data ' 'is randomly shuffled and slightly modified.', 'wind_u-surface': [1.3641749667211287, -2.068869953527833, -1.868909421509168, .... lots of lines with shuffled random values -0.6153779885029739], 'wind_v-surface': [0.6080014487060029, -3.3782315058471184, 1.5184114269056044, .... lots of lines with shuffled random values 2.700416395397793, 3.2247825998125013]}
How to deal with these numbers. I only want these
float
numbers:clouds = float(weaAPI['current']['cloud']) speed = float(weaAPI['current']['wind_kph']) gust = float(weaAPI['current']['gust_kph']) windD = int(weaAPI['current']['wind_degree']) temp = float(weaAPI['current']['temp_c'])
at the surface level, I suppose.
Thanks in advance