briandconnelly / airnow-py

Python interface for the AirNow air quality API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

airnow

airnow is a Python package that provides access to the AirNow API, which reports air quality data throughout the United States. To use airnow, you will first need to create an API token by signing up for an account.

Note: AirNow measurements are updated hourly (generally between 10 and 30 past the hour). Please be kind to this free service and use caching and/or rate limiting.

Installation

You can install airnow by running the following command from this directory:

pip install .

If you'd like to use development mode, install with

pip install -e .

Usage

Let's get the current air quality conditions for Seattle, Washington (ZIP code 98101):

import airnow

airnow.get_conditions_zip(98101)

A dict is returned containing current ozone (O3) and fine particulate matter (PM2.5) readings and associated metadata:

[{'DateObserved': '2020-09-21 ',
  'HourObserved': 7,
  'LocalTimeZone': 'PST',
  'ReportingArea': 'Seattle-Bellevue-Kent Valley',
  'StateCode': 'WA',
  'Latitude': 47.562,
  'Longitude': -122.3405,
  'ParameterName': 'O3',
  'AQI': 1,
  'Category': {'Number': 1, 'Name': 'Good'}},
 {'DateObserved': '2020-09-21 ',
  'HourObserved': 7,
  'LocalTimeZone': 'PST',
  'ReportingArea': 'Seattle-Bellevue-Kent Valley',
  'StateCode': 'WA',
  'Latitude': 47.562,
  'Longitude': -122.3405,
  'ParameterName': 'PM2.5',
  'AQI': 40,
  'Category': {'Number': 1, 'Name': 'Good'}}]

Environment Variables

Most airnow functions support reading the API token from the AIRNOW_API_KEY environment variable.

Disclaimer

Neither this package nor its author(s) are affiliated with AirNow or its participating agencies. Please follow the U.S. EPA AirNow Data Exchange Guidelines.

About

Python interface for the AirNow air quality API

License:MIT License


Languages

Language:Python 100.0%