Weather API resources

Weather API resources
0.0 0

#1

Hello all!

I’m having a very difficult time with the Local Weather challenge. I’ve looking at other campers’ code and modeling the call after what I successfully implemented in the quotes challenge - and nothing seems to be super stable. I gave up to work on other challenges and now I’m back and determined to get this to work.

So - I want to start from the bottom up here. Are there any good basic resources for making these types of API calls? Do I need to test this somewhere other than Chrome? I know there is a known issue with making this call in Chrome.

Any information and resources would be helpful. I’m not sure why I’m having such a hard time with this. Thank you!!


#2

You really need two main things for the weather app:

1.) Reliable location
2.) A weather API to call.

Chrome is a pain because of the requirement for https to use geolocation in the browser (I appreciate their security conscientiousness, but it’s a pain in this particular instance).

So, if you want to support Chrome, you need a different method for getting location.

People have posted a number of options for alternatives to the native geolocation API, I wound up implementing a two pronged approach:

1.) Try to use the geolocation API.
That API takes two callbacks - success and error. If it’s successful, do the normal processing to display the page.

2.) If it’s not successful, in the error callback, use the alternate API. This one worked well for me: http://ipinfo.io

I decided on using this approach mostly to see if it worked and practice coding in situations where a fallback option was needed, but also because I found the geolocation API to give me much more accurate location coordinates than the free options.

Once you have accurate location coordinates, you can make your call to the weather API.

For weather, I used http://api.openweathermap.org which worked out just fine.

They document their JSON responses on their site and, once you have signed up for a free API key, you can start making calls and checking out the results.

An important final thing to remember is that both the location and weather calls are asynchronous - so you have to make sure you work within their callbacks to process the data returned.

I hope that helps a bit!

If you want, I posted my Weather App here:

My Weather App

I went pretty heavily overboard - way more than the challenge called for, but I wanted to play a bit.


#3

Thank you SO much! http://ipinfo.io/ was the missing piece from my app.