Skip to content

Elixir client for retrieving Air Quality data from AirNow.gov

Notifications You must be signed in to change notification settings

rjanja/air_quality

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AirQuality

A wrapper for the AirNow air quality API from the U.S. Environmental Protection Agency.

Installation

If available in Hex, the package can be installed by adding air_quality to your list of dependencies in mix.exs:

def deps do
  [
    {:air_quality, "~> 0.1.0"}
  ]
end

Configuration

Set your AirNow API credentials in your config.exs:

config :air_quality,
  api_key: System.get_env("AIRNOW_API_KEY")

Usage

AirQuality.Current.get_by_latlong({latitude, longitude}, miles)

Use a tuple of latitude and longitude to get_by_latlong, along with a miles parameter for finding a nearby reporting station:

iex> AirQuality.Current.get_by_latlong({42.1946, -122.7095}, 100)
{:ok,
 [
   %{
     "AQI" => 191,
     "Category" => %{"Name" => "Unhealthy", "Number" => 4},
     "DateObserved" => "2018-08-09 ",
     "HourObserved" => 10,
     "Latitude" => 42.1941,
     "LocalTimeZone" => "PST",
     "Longitude" => -122.7086,
     "ParameterName" => "PM2.5",
     "ReportingArea" => "Ashland",
     "StateCode" => "OR"
   }
 ]}

AirQuality.Current.get_by_zip(zip_code, miles)

Use a zip code to find nearby measurements.

iex(2)> AirQuality.Current.get_by_zip(97520, 100)
{:ok,
 [
   %{
     "AQI" => 191,
     "Category" => %{"Name" => "Unhealthy", "Number" => 4},
     "DateObserved" => "2018-08-09 ",
     "HourObserved" => 10,
     "Latitude" => 42.1941,
     "LocalTimeZone" => "PST",
     "Longitude" => -122.7086,
     "ParameterName" => "PM2.5",
     "ReportingArea" => "Ashland",
     "StateCode" => "OR"
   }
 ]}

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/air_quality.

About

Elixir client for retrieving Air Quality data from AirNow.gov

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages