Skip to content

Ardasak/Air-Quality-API

Repository files navigation

Usage

This library is developed using AirVisualAPI and tested using Windows and Linux(Parrot).

To use this library, you have to make sure that you have an api key. If you don't have one, you can have it on the same link above.

If you want to see API docs, visit AirVisualAPI Docs.

You can see the basic usage of the API below.

import json
import air_quality_lib

# Here is an example community api key
api_key = "4732196d-a1af-40a0-af2e-023f6b6a225d"

country_obj = air_quality_lib.Country(api_key)
city_obj = air_quality_lib.City(api_key)
state_obj = air_quality_lib.State(api_key)
station_obj = air_quality_lib.Station(api_key)

def test_app():
    print(city_obj.get_supported_cities("USA", "Alaska", asJson=True))
    print(city_obj.get_supported_cities("USA", "Alaska"))

    print(state_obj.get_supported_states("USA", asJson=True))
    print(state_obj.get_supported_states("USA"))

    print(country_obj.get_supported_countries(asJson=True))
    print(country_obj.get_supported_countries())

test_app()

Exceptions

  • InvalidApiKey: When the api key you logged is invalid.
  • PermissionError: When your key does not have permission to execute that method.
  • CallLimitReached: There is a minute/monthy limit, this exception is raised if you reach that limit.
  • ApiKeyExpired: This is raised when your api key is expired, you have to renew it.
  • IpLocationFailed: If the service can not locate the ip address of request, this exception is raised.
  • TooManyRequests: Returned when more than 10 calls per second are made with the same api key.
  • NoNearestStation: Raised when there is no nearest station to the latitude and longitude you have given as parameter.
  • CountryNotFound: Raised when the country is not found.
  • StateNotFound: Raised when the state is not found.
  • CityNotFound: Raised when the city is not found.
  • StationNotFound: Raised when the station is not found.

Some of the Terms

Comment: Data is returned according to your api plan. So if you can't get some of the datas specified below. That could be the reason.

  • ts: timestamp
  • aqius: AQI value based on US EPA standard
  • aqicn: AQI value based on Chinese Mep standard
  • tp: Air temperature in Celcius
  • tp_min: Minimum air temperature in Celsius
  • pr: Atmospheric pressure in hPa
  • hu: Humidity in %
  • ws: Wind speed in m/s
  • wd: Wind direction as an angle of 360° (N=0, E=90, S=180, W=270)
  • ic: Weather icon code (if you visit https://airvisual.com/images/iconcode.png, you will find the icon according to the weather condition)
  • mainus: Main pollutant for US AQI
  • maincn: Main pollutant for Chinese AQI
  • conc: Concentration of particulate matter in ug/m3
  • p2: ugm3 (pm2.5)
  • p1: ugm3 (pm10)
  • o3: ppb (Ozone O3)
  • n2: ppb (Nitrogen dioxide NO2)
  • s2: ppb (Sulfur dioxide SO2)
  • co: ppm (Carbon monoxide CO)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages