Difference: TheWeatherApp (1 vs. 4)

Revision 42021-02-18 - UliRaich

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

The weather app

Introduction

Line: 30 to 33
 This shows that the nearest city for which I can get a woeid is Zürich with the id:784794

Sending the request,using the method reponse = urequests.get(url) with the url below

Added:
>
>
 
https://www.metaweather.com/api/location/784794/

returns a json string of this type, from which you can pick the information of interest to you:

weatherjson.png

Changed:
<
<
response.status_code gives you the http return code (should be 200 if successful).
data = response.json() gets the json data for you and converts it into a Python dictionary from which you must extract the information relevant to you. I pick up this information and put it into a friendly GUI:
>
>
response.status_code gives you the http return code (should be 200 if successful).
data = response.json() gets the json data for you and converts it into a Python dictionary from which you must extract the information relevant to you. I pick up this information and put it into a friendly GUI:
  metaweather.png

Revision 32021-02-13 - UliRaich

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

The weather app

Introduction

Line: 38 to 38
  response.status_code gives you the http return code (should be 200 if successful).
data = response.json() gets the json data for you and converts it into a Python dictionary from which you must extract the information relevant to you. I pick up this information and put it into a friendly GUI:
Changed:
<
<
metaweather_app.png
>
>
metaweather.png
 
Changed:
<
<
If you compare this with the json string, you should find back the information. Only the wind speed is different because I convert the units from mph to kph.
>
>
If you compare this with the json string, you should find back the information. Only the wind speed is different because I convert the units from mph to kph. You can also see that it is really cold here in Switzerland in February!
 

openweathermap.org

The basic way for getting weather data from openweathermap.org is the same as described above. However the url string is different following a different API. On openweathermap.org you don't need the woeid, but you can use a city name or the GPS data directly. On the other hand you need an extra apikey, which you get with your registration.

Line: 52 to 52
 
<--/commentPlugin-->

META FILEATTACHMENT attachment="nearestCity.png" attr="" comment="" date="1612705529" name="nearestCity.png" path="nearestCity.png" size="68319" user="UliRaich" version="1"
Changed:
<
<
META FILEATTACHMENT attachment="weatherjson.png" attr="" comment="" date="1612706078" name="weatherjson.png" path="weatherjson.png" size="109725" user="UliRaich" version="1"
>
>
META FILEATTACHMENT attachment="weatherjson.png" attr="" comment="" date="1613210898" name="weatherjson.png" path="weatherjson.png" size="121790" user="UliRaich" version="2"
 
META FILEATTACHMENT attachment="metaweather_app.png" attr="" comment="" date="1612815485" name="metaweather_app.png" path="metaweather_app.png" size="16403" user="UliRaich" version="1"
Added:
>
>
META FILEATTACHMENT attachment="metaweather.png" attr="" comment="" date="1613210533" name="metaweather.png" path="metaweather.png" size="103460" user="UliRaich" version="1"

Revision 22021-02-08 - UliRaich

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

The weather app

Introduction

Line: 32 to 29
  This shows that the nearest city for which I can get a woeid is Zürich with the id:784794
Changed:
<
<
Sending the request:
>
>
Sending the request,using the method reponse = urequests.get(url) with the url below
 
https://www.metaweather.com/api/location/784794/

returns a json string of this type, from which you can pick the information of interest to you:

weatherjson.png

Changed:
<
<
If you inspect the string closely, you can see that weather here is very bad at the moment.
>
>
response.status_code gives you the http return code (should be 200 if successful).
data = response.json() gets the json data for you and converts it into a Python dictionary from which you must extract the information relevant to you. I pick up this information and put it into a friendly GUI:

metaweather_app.png

If you compare this with the json string, you should find back the information. Only the wind speed is different because I convert the units from mph to kph.

 

openweathermap.org

The basic way for getting weather data from openweathermap.org is the same as described above. However the url string is different following a different API. On openweathermap.org you don't need the woeid, but you can use a city name or the GPS data directly. On the other hand you need an extra apikey, which you get with your registration.

Line: 53 to 53
 
META FILEATTACHMENT attachment="nearestCity.png" attr="" comment="" date="1612705529" name="nearestCity.png" path="nearestCity.png" size="68319" user="UliRaich" version="1"
META FILEATTACHMENT attachment="weatherjson.png" attr="" comment="" date="1612706078" name="weatherjson.png" path="weatherjson.png" size="109725" user="UliRaich" version="1"
Added:
>
>
META FILEATTACHMENT attachment="metaweather_app.png" attr="" comment="" date="1612815485" name="metaweather_app.png" path="metaweather_app.png" size="16403" user="UliRaich" version="1"

Revision 12021-02-07 - UliRaich

Line: 1 to 1
Added:
>
>
META TOPICPARENT name="WebHome"

The weather app

Introduction

Several weather servers provide weather data and forecasts that can be used by a weather app. Here are the two I had a look into:

openweathermap is probably the more powerful one but you must register (for free) to be able to use it, while you can get weather data from metaweather.com also without registration.

Both sites have their own API (Application Programming Interface) and return the weather data in form of a json string, which must be decoded.Both sites provide a number of icons representing the different weather conditions.

metaweather.com

In order to get weather data from metaweather.com you must perform an HTTP GET request on URL:

https://www.metaweather.com/api/location/{woeid}/

where woeid is the "where on earth id", an integer number corresponding to the place for which you want the weather data. In order to get the woeid you can make a query giving the GPS coordinates of this place:

https://www.metaweather.com/api/location/search/?lattlong={latt},{long}

For my place in Austria the GPS data are

  • lattitude: 47.52637
  • longitude: 9.74882
and sending the request:

https://www.metaweather.com/api/location/search/?lattlong=47.53,9.75

returns:

nearestCity.png

This shows that the nearest city for which I can get a woeid is Zürich with the id:784794

Sending the request:

https://www.metaweather.com/api/location/784794/

returns a json string of this type, from which you can pick the information of interest to you:

weatherjson.png

If you inspect the string closely, you can see that weather here is very bad at the moment.

openweathermap.org

The basic way for getting weather data from openweathermap.org is the same as described above. However the url string is different following a different API. On openweathermap.org you don't need the woeid, but you can use a city name or the GPS data directly. On the other hand you need an extra apikey, which you get with your registration.

-- Uli Raich - 2021-02-07

Comments

<--/commentPlugin-->

META FILEATTACHMENT attachment="nearestCity.png" attr="" comment="" date="1612705529" name="nearestCity.png" path="nearestCity.png" size="68319" user="UliRaich" version="1"
META FILEATTACHMENT attachment="weatherjson.png" attr="" comment="" date="1612706078" name="weatherjson.png" path="weatherjson.png" size="109725" user="UliRaich" version="1"
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback