weather information app

243 views
Skip to first unread message

Hubert Huller

unread,
Mar 9, 2018, 6:28:33 PM3/9/18
to MIT App Inventor Forum

Hi!
I want to create a weather app where I want to use the json data from http://openweathermap.org/api
Hope someone can help me how I can create an weather app.

I want to chose or insert a city and want see the actual temperature there.
kindly regards

Ghica

unread,
Mar 10, 2018, 10:39:21 AM3/10/18
to MIT App Inventor Forum
Did you do any App Inventor tutorials yet? If not, start with that!
Else, look at this: http://ai2.appinventor.mit.edu/reference/other/xml.html
This description is for another weather service and for xml, but it makes no difference in App Inventor to process JSON or XML.

I made a weather app for the weather service you are referring to, long ago, but I do not want to deny you the joy of trying for yourself first.
So, try, and post some blocks if you have trouble.
Cheers, Ghica

Hubert Holler

unread,
Mar 10, 2018, 3:58:10 PM3/10/18
to mitappinv...@googlegroups.com
kindly regards for your answer.
How can I get the url for a special country automaticle.
For example I want insert only graz and then I need the following link: http://api.wunderground.com/api/KEY/conditions/q/at/graz.xml.
But I notice that not all city I will get a temperature. For example I cannot find fernitz in austria or other cities.
Also I notice that I cannot find wien but vienna. So I must use sometimes the english name.

How can I check if the name of the city is possible to get an xml result. And when the city is not available I will get an suggestion of cities in the near.

Also how can I get the temperature for the next days.
kindly regards



SteveJG

unread,
Mar 10, 2018, 5:16:12 PM3/10/18
to MIT App Inventor Forum
This appears to list the cities that are available on wunderground.   https://www.wunderground.com/about/faq/international_cities.asp     If a city is not listed, assume it is not available.

Regards
Steve

Ghica

unread,
Mar 11, 2018, 7:48:58 AM3/11/18
to MIT App Inventor Forum
Hubert,
To find what you need you have to look at the API documentation here: http://openweathermap.org/api
First of all, you need an API key, you can find in the API documentation how to get one. 
Then look at some samples how to build the URL, first check in a browser (Chrome or Firefox) if you get the desired result and then use the Web component to get your data.
To display a forecast of more days, I would advise to use a simple HTML setup, examples are here: https://puravidaapps.com/table.php

The app I made was for a forecast on my current location, using the LocationSensor, and I used XML, which, I just found has a very different API from JSON for OpenWeatherMap.
I think the XML has much more straightforward set of keywords in its response, and after using call Web1.XMLTextDecode or call Web1.JsonTextDecode, you get a list of lists, which you can search through using "look up in pairs" from the list blocks.

You can find in the API documentation of OpenWeatherMap, for example how to get a 16 day forecast, there is also a list of available cities, which, after some searching, I found here: http://bulk.openweathermap.org/sample/
You will get a g-zipped list in JSON. You could load it as an asset into your app, and search for it when you need it. 

Cheers, Ghica.
Reply all
Reply to author
Forward
0 new messages