GitXplorerGitXplorer
A

Air-Quality-API

public
2 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
ed3a621d07fd3a2ea74e7db14b058bbdbf9bdd16

oops

AArdasak committed 3 years ago
Unverified
11a9ba3fd48627bd95775dcd0aac69205ee51732

Merge branch 'master' of https://github.com/Ardasak/Air-Quality-API

AArdasak committed 3 years ago
Unverified
20a78726048b95170815dfbb6a3e34004a01f8fb

Used if instead of match case

AArdasak committed 3 years ago
Unverified
243e024e54c6cfe9fc97eded4b51321a970552e3

Unimportant fix.

AArdasak committed 3 years ago
Unverified
211653c05bdb69164f7f192301a4c18cc5c90cb5

README Update

AArdasak committed 3 years ago
Unverified
47cb6d28a938f70b85d5fb92f7e234c731e008ab

README Update

AArdasak committed 3 years ago

README

The README file for this repository.

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)