Upon submit, the first screen navigates to the second screen that shows the air quality index for the chosen city.įrom an Android app development point of view, these two screens are represented by two activities. On a multi-screen Android app, you can do this by having the first screen display a dropdown of cities to choose from. Wouldn’t it be cool if you can display the air quality data on a mobile phone? Displaying Air Quality Data on an Android App In case you are interested, the daily measurement data on API response also contains the density values for other polluting components of the air. This range is split into different concern levels to indicate the danger posed by air pollutants. The ‘ aqius ’ gives the air quality index within a range of 0 to 500. The first one is the hourly measurement, and the second is daily measurement.Įxpanding an hourly and daily measurement object gives specific values for air quality index values. Triggering the API returns a response with two sets of measurements. Now select the “ GET cities/get-measurements” endpoint under the cities category in the endpoint list, and enter the id of Los Angeles in the ‘ id ’ parameter. The id of this city is “xwJyTC4tyag4svdTe”. The API returns the matching city names, with the first entry representing the city of Los Angeles in the state of California in the US. First, select the “ GET auto-complete” endpoint and key in “Los Angeles” in the ‘query’ parameter for API requests to get a list of matching cities. Let’s take the AirVisual API for a test drive and find the air quality index for Los Angeles. To retrieve the historical air quality data, use the “ GET cities/get-measurements” endpoint. After that, you can invoke the “ GET cities/get-information” to retrieve the current air quality and weather data. The “ GET auto-complete” endpoint lets you search for a city to retrieve the id. However, to do this, you must know the predefined city id associated with the city. As you can imagine, querying the data based on the city name is the most logical way. You can get the data for a place, a city, or a weather station. The API provides three ways to query Air quality data. On the left panel, you can see a list of the endpoints supported by this API. Once subscribed, come back to the “Endpoints” tab on the API console.
Now click on the “Pricing” tab and opt-in for the basic subscription that gives you 500 free API requests, per month. Once signed in, log on to your RapidAPI account and access the AirVisual API Console. Our goal is to help developers find and connect to APIs to help them build amazing apps. RapidAPI is the world’s largest API marketplace, with over 10,000 APIs and a community of over 1,000,000 developers. With this account, you get a universal API Key to access all APIs hosted on RapidAPI. To begin using the AirVisual API, you’ll first need to sign up for a free RapidAPI developer account. It is powered by IQAir, the world’s largest free real-time air quality information platform.įollow the steps below to activate this API with your RapidAPI account. The AirVisual API lets you query for air quality data based on a city. However, with the integration of an API, it is possible to consume air quality data via an Android app. It is not easy to collect this data without the help of sophisticated pollution monitoring stations. With the concerns around rising pollution levels in our cities, it is evident that people across the world would frequently search for air quality data.
Related: How to build an Android App with JavaScript Choosing an API for a multi-screen Android App? How about building a multi-screen Android app? Earlier we covered a tutorial on how to build a simple Android app with an API. Android has the largest share of apps among all the mobile OSes so it is quite evident that app developers would want to target this ecosystem. With the rising user base of mobile phones, app developers have an ever-increasing reach. How do I extract air quality parameters.How do I use an air quality API to retrieve pollution level in my city.How can we get air quality data for a city.
Step 4: Write the Code for the Activities.Step 3: Add the UI Layout for Activities.
Displaying Air Quality Data on an Android App.Choosing an API for a multi-screen Android App?.