API Network Exploration: AirVisual

This is part of our blog series on Postman’s API Network – a directory of API publishers running in Postman. We will highlight some member APIs that are part of our API Network and emphasize some key features to help you become familiar with some of these incredibly useful APIs. In this blog, we’ll specifically be looking at the AirVisual API.

The AirVisual API provides the most comprehensive global air quality data available to developers. AirVisual aims to provide accurate historical, real-time, and forecast air quality data for cities around the world.

AirVisual has Postman Collections for each of their three API versions: Community (rree), Startup (paid) and Enterprise (paid). For the course of this post, we will use the most commonly available version: Community (free). You can download all three collections from the Postman API Network, or from within the app.

To use the service, an API key is required. This can be obtained from the AirVisual website.

AirVisual API Postman Collection
(On importing the AirVisual API, the collection of API requests are available)

The Community version of the AirVisual API allows the users to get air quality data for the available list of countries. This data can then be drilled down to respective states and cities.

(GET request to fetch all the supported countries)
(GET request to fetch all the supported states in country – India)
(GET request to fetch all the supported cities for the given state and country – Karnataka, India)

However, one of the most impressive features available is the ability to get the nearest city’s data using just the IP geolocation. Alternatively, this can be achieved by entering the exact latitude and longitude of the place.

(The API automatically picks the nearest city based on the IP geo-location, without having to add any other markers)
(The API can also fetch data by using the GPS coordinates i.e. Latitude, Longitude)

The key feature of the AirVisual API is that it returns detailed air quality reports for every available location.

(The API returns the current weather and pollution data of the selected city)

This is the output returned when we entered the parameters:
City – Bengaluru
State – Karnataka
Country – India

{
    "status": "success",
    "data": {
        "city": "Bengaluru",
        "state": "Karnataka",
        "country": "India",
        "location": {
            "type": "Point",
            "coordinates": [
                77.54583055555555, //longitude
                12.9916694 //latitude            ]
        },
        "current": {
            "weather": {
                "ts": "2019-04-18T20:00:00.000Z", //timestamp
                "hu": 100, //humidity
                "ic": "03n", //weather icon code (scattered clouds)
                "pr": 1014, //atmospheric pressure in hPa
                "tp": 22, //temperature in Celsius
                "wd": 180, //wind direction, as an angle of 360°
                "ws": 6.2 //wind speed (m/s)
            },
            "pollution": {
                "ts": "2019-04-19T00:00:00.000Z",
                "aqius": 90, //AQI value based on US EPA standard
                "mainus": "p2", //main pollutant for US AQI
                "aqicn": 44, //AQI value based on China MEP standard
                "maincn": "p2" //main pollutant for Chinese AQI
            }
        }
    }
}

Note: The community version of the AirVisual API provides only current data. To access historical and forecast data, you’d have to upgrade to the enterprise version.

With the availability of real-time air quality data using the AirVisual API the applications are limitless – be it to update people of the current weather situation or to warn people of unhealthy air.

To play around with this collection, you can download the collection and get the API key and get started building some cool stuff.

To access this collection directly in the Postman app, click the Create button in the top left corner and select the API Network tab. A pop-up screen will then appear. You can either browse all the published APIs or search for a specific API. To know more, visit the Postman Learning Center.

You can check out the other APIs running in Postman by visiting the API Network or search for them within the Postman app.


Comment

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.