text: Learn how in this tutorial
  Air pollution is a health risk one can no longer ignore. It is one of the major factors responsible for lowering the quality of life in both developed and developing countries. Consequently, a lot of people today are looking for tools that can help them learn more about the contents of the air they are exposed to.
  Airmine’s Air Quality Index API is designed for web, IoT, and mobile app developers who are interested in creating such tools. It is a free API that gives you access to the atmospheric fine particulate matter concentration, commonly known as PM2.5, at any given location. In addition to the current concentration, it offers forecasts up to 8 days in the future.
  In this short tutorial, we help you get started with the Airmine AQI API.
  Prerequisites
  To follow this tutorial, you’ll need:
  - a Rapid API account
  - a basic understanding of JSON and Python
  1. Subscribe to the API
  To be able to use the Airmine AQI API, you must subscribe to it. So log into your RapidAPI account and search for Airmine AQI.
  Once you find it, click on the Subscribe to Test button. In the next screen, choose the Basic plan, which allows you to make 100 free requests per day.
  At this point, you’ll be able to make requests to the following REST endpoint:
  2. Fetch Data From Airmine AQI API
  You must make HTTP GET requests to fetch data from the Airmine AQI API. It expects two parameters in the query string:
  lat and
  lon. As you may have guessed,
  lat is the latitude of a location, and
  lon its longitude.
  Additionally, you must include two custom HTTP headers, named
  x-rapidapi-key and
  x-rapidapi-host while making the request. The value of the
  x-rapidapi-key header should be equal to your secret RapidAPI key. And the value of the
  x-rapidapi-host header should be “pm251.p.rapidapi.com/aqi”. If you’ve used other APIs available on RapidAPI, you may be familiar with these headers already.
  The following sample code shows you how to create and execute a valid request in Python3:
  import requests # Airmine AQI endpoint endpoint = "" # Coordinates of Berlin coordinates = { "lat": "52.520008", "lon": "13.404954" } # Custom headers headers = { 'x-rapidapi-host': "pm251.p.rapidapi.com/aqi", 'x-rapidapi-key': "YOUR-KEY-HERE" } # Execute a GET request response = requests.request( "GET", endpoint, headers = headers, params = coordinates )
  3. Parse the API’s Response
  The response of the API is a JSON document that’s very easy to parse. It has just three outer keys:
  location,
  meta, and
  forecasts. Usually, you’d only be working with the
  forecasts key, whose value is an array containing hourly PM2.5 forecasts. Here’s what the array looks like:
  { "forecasts": [ { "date": "2020-06-13T20:00:00", "values": [ { "parameter": "pm25", "value": 3 } ] }, { "date": "2020-06-13T21:00:00", "values": [ { "parameter": "pm25", "value": 4 } ] } . . . ] }
  For most locations, the array will have 87 items. The first 60 items give you hourly values. The rest give you six-hourly values.
  The following code shows you how to parse the response as a JSON document and determine the number of items in the
  forecasts array:
  data = response.json() n = len(data['forecasts'])
  Each item of the array contains a timestamp and a PM2.5 value. What you actually do with them, of course, depends on the application you’re building. For starters, you could try simply printing them.
  for item in data['forecasts']: date = item['date'] pm25 = item['values'][0]['value'] print("%s | %d" % (date, pm25))
  4. Checking Limits
  Airmine AQI API’s basic plan gives you 100 free requests per day. Your application will fail if you exceed this limit. Here’s how you can determine the number of requests left using the response’s
  x-ratelimit-requests-remaining header:
  remaining = int(response.headers['x-ratelimit-requests-remaining']) print("You have %d requests left" % remaining)
  Conclusion
  You now know how to use the Airmine AQI API. Although we used Python in this tutorial, using the API with any other programming language is just as easy. Whether you’re a professional app developer, a home automation enthusiast, or a hobby programmer, if you’re interested in monitoring air quality, you should consider giving this API a try.