Search code examples
swiftwunderground

Using Wunderground API in Swift


My current project needs to be able to display weather forecasts, and I have decided to use Wunderground. Because using an API is completely uncharted territory for me, I have a two-part question. What is the best way to retrieve data from it, and as far as I can tell there are quite a few, and can Wunderground use coordinates? This is the idea I have in mind: http://api.wunderground.com/api/56968011acc3e3eb/conditions/q/+35.70206910,+139.77532690.json


Solution

  • For retrieving data, you'll want to look into SwiftyJSON which will help you parse the json data that the api returns. Then, once it's parsed and you have a JSON object representation of your info, you can access it as a dictionary to get the required fields. As far as using coordinates for accessing the api, I took this straight from their website, so yes you can. It would look like this: http://api.wunderground.com/api/Your_Key/geolookup/q/37.776289,-122.395234.json