Development step 3: Import Data from other sources to Swift
Since my main focus now is creating a weather app, I would need to find a source so i can fetch the data into Xcode. A search through Google (and a suggestion from the popular Daniel Shiffman of coding train: http://hello.p5js.org/ ) led me to Apixu API…
More about Apixu according to their website:
Apixu provides access to weather and geo data via a JSON/XML restful API. It allows developers to create desktop, web and mobile applications using this data very easy.
They provide following data through their API:
- Real-time weather
- 10 day weather forecast
- Astronomy
- Time zone
- Location data
- Search or Autocomplete API
- Historical weather
The reason that I chose Apixu out of other Weather API's is because it offers data for free, with about 5000 API calls/day, which is totally fine for test environment.They also offer weather look up for the past, which somehow benefits my ideas of tracking past weather information. Here's the comparison of 3 weather API I found: https://www.weatherbit.io/blog/post/top-3-free-weather-api-s-in-2017
Step 1: Sign up for Apixu
I created a free account at Apixu pretty quick and easy, then I may jump right in to explore their data:
Step 2: Exploring the data
So what exactly I'm doing here, I would using Apixu data to load to my project. The data here include a whole bunch of weather information input in a simple coding language, JSON.
JSON, or JavaScript Object Notation, is a minimal, readable format for structuring data. It is used primarily to transmit data between a server and web application, as an alternative to XML. — Square Space
Following the source Apixu offers, as seen above, I would go straight to JSON file of current/forecast weather of Paris. I can jump to other cities' JSON data just by changing it in the browser's address bar.
However, i found it really hard to understand this data as well as view the data clearly. To read the JSON data easily, i found a Google extension called “JSON Formatter", which turns the long tl;dr lines of code into digestible ones you can work on later.
Follow this link to download this handy extension: https://chrome.google.com/webstore/search/JSON%20Formatter%EF%BB%BF?hl=en
What’s next…
The starting point to understand API is pretty good so far. I’m curious to find out how to implement those data into a standalone weather app.