Tags:
view all tags
---+ 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: * [[https://www.metaweather.com/][metaweather..com]] * [[https://openweathermap.org/][openweathermap.org]] _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 (<b>A</b>pplication <b>P</b>rogramming <b>I</b>nterface) 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<i> metaweather.com </i>you must perform an HTTP GET request on URL: <verbatim>https://www.metaweather.com/api/location/{woeid}/</verbatim> 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 <i>woeid </i>you can make a query giving the GPS coordinates of this place: <verbatim>https://www.metaweather.com/api/location/search/?lattlong={latt},{long}</verbatim> For my place in Austria the GPS data are * lattitude: 47.52637 * longitude: 9.74882 and sending the request: <verbatim>https://www.metaweather.com/api/location/search/?lattlong=47.53,9.75</verbatim> returns: <img alt="nearestCity.png" height="507" src="%ATTACHURL%/nearestCity.png" title="nearestCity.png" width="1119" /> This shows that the nearest city for which I can get a woeid is Zürich with the id:784794 Sending the request: <verbatim>https://www.metaweather.com/api/location/784794/</verbatim> returns a json string of this type, from which you can pick the information of interest to you: <img alt="weatherjson.png" src="%ATTACHURL%/weatherjson.png" title="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. -- %USERSIG{UliRaich - 2021-02-07}% ---++ Comments %COMMENT%
Attachments
Attachments
Topic attachments
I
Attachment
History
Action
Size
Date
Who
Comment
png
nearestCity.png
r1
manage
66.7 K
2021-02-07 - 13:45
UliRaich
png
weatherjson.png
r1
manage
107.2 K
2021-02-07 - 13:54
UliRaich
Edit
|
Attach
|
Watch
|
P
rint version
|
H
istory
:
r4
<
r3
<
r2
<
r1
|
B
acklinks
|
V
iew topic
|
Raw edit
|
More topic actions...
Topic revision: r1 - 2021-02-07
-
UliRaich
Home
Site map
AFNOG web
Embedded_Systems web
IoT_Course_English web
IoT_Course_French web
Main web
Sandbox web
TWiki web
IoT_Course_English Web
Create New Topic
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
View
Raw View
Print version
Find backlinks
History
More topic actions
Edit
Raw edit
Attach file or image
Edit topic preference settings
Set new parent
More topic actions
Account
Log In
Register User
Edit
Attach
Copyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback