npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

airnow

v1.0.2

Published

npm module for airnowapi.org webservices API.

Downloads

6

Readme

airnow.js

airnow is a module for making HTTP requests to the airnowapi.org webservices API.

Installation

npm install airnow --save

Quick Examples

var airnow = require('airnow');

var client = airnow({ apiKey: 'my airnow.org key' });

// get the forecast by zip
client.getForecastByZipCode({ zipCode: "53703" }, function(err, forecast){
	
});

// get the forecast by latitude and longitude
client.getForecastByLatLong({ latitude: 39.0509, longitude: -121.4453}, function(err, forecast){
	
});

// get the observations by zip
client.getObservationsByZipCode({ zipCode: "53703" }, function(err, observations){
	
});

// get the observations by latitude and longitude
client.getObservationsByLatLng({ latitude: 39.0509, longitude:-121.4453 }, function(err, observations){
	
});

// get the observations by a bounded box monitoring site
client.getObservationsByMonitoringSite({ bbox:{ minX: -122.715607, minY: 38.181254, maxX: -120.012970, maxY: 39.022646}, parameters:["pm25","o3"], datatype:"C"}, function(err, observations){
	
});

// get historical observations by a zip code
client.getHistoricalObservationsByZipCode({ zipCode:"53703", date: new Date(1448984256072) }, function(err, observations){
	
});

// get historical observations by latitude and longitude
client.getHistoricalObservationsByLatLng({ latitude: 39.0509, longitude:-121.4453, date: new Date(1448984256072) }, function(err, observations){
	
});

Features

  1. Forecasts
  2. Observations (current & historical)
  3. Brute force retries of the HTTP calls

getForecastByZipCode

Get a forecast for a zip code on a particular date.

example

var airnow = require('airnow');

var client = airnow({ apiKey: 'my airnow.org key' });

// build my options
var options = {
	zipCode: "53703",
	date: new Date(),
	distance: 100,
	format: "application/json"
};

// get the forecast by zip
client.getForecastByZipCode(options, function(err, forecast){
	if (err){
		console.log('derp! an error calling getForecastByZipCode: ' + err);
	} else {
		// the world is good! start processing the forecast
	}
});

options

| Parameter | Description | Type | Required | |:---------:|----------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|----------| | zipCode | Zip code | String | Yes | | date | Date of forecast. If date is omitted, the current forecast is returned. | Date | No | | distance | If no reporting area is associated with the specified Zip Code, return a forecast from a nearby reporting area within this distance (in miles). | Number | No | | format | Format of the payload returned. Defaults to "application/json" and the response will be a parsed JSON object. "text/csv" "application/json" "application/xml" | String | No |

getForecastByLatLong

Get a forecast for a latitude and longitude pair for a particular date

example

var airnow = require('airnow');

var client = airnow({ apiKey: 'my airnow.org key' });

// build my options
var options = {
	latitude: 38.33,
	longitude: -122.28,
	date: new Date(),
	distance: 100,
	format: "application/json"
};

// get the forecast by latitude and longitude
client.getForecastByLatLong(options, function(err, forecast){
	if (err){
		console.log('derp! an error calling getForecastByZipCode: ' + err);
	} else {
		// the world is good! start processing the forecast
	}
});

options

| Parameter | Description | Type | Required | |:-----------:|----------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|----------| | latitude | Latitude in decimal degrees | Number | Yes | | longitude | Longitude in decimal degrees | Number | Yes | | date | Date of forecast. If date is omitted, the current forecast is returned. | Date | No | | distance | If no reporting area is associated with the specified latitude and longitude, return a forecast from a nearby reporting area within this distance (in miles). | Number | No | | format | Format of the payload returned. Defaults to "application/json" and the response will be a parsed JSON object. "text/csv" "application/json" "application/xml" | String | No |

getObservationsByZipCode

Gets the current observations for a single zip code.

example

var airnow = require('airnow');

var client = airnow({ apiKey: 'my airnow.org key' });

// build my options
var options = {
	zipCode: "53703",
	distance: 100,
	format: "application/json"
};

// get the current observations by zip
client.getObservationsByZipCode(options, function(err, observations){
	if (err){
		console.log('derp! an error calling getObservationsByZipCode: ' + err);
	} else {
		// the world is good! start processing the observations
	}
});

options

| Parameter | Description | Type | Required | |:-----------:|----------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|----------| | zipCode | Zip Code | String | Yes | | distance | If no reporting area is associated with the specified Zip Code, return a forecast from a nearby reporting area within this distance (in miles). | Number | No | | format | Format of the payload returned. Defaults to "application/json" and the response will be a parsed JSON object. "text/csv" "application/json" "application/xml" | String | No |

getObservationsByLatLng

Gets the current observations for a latitude and longitude pair.

example

var airnow = require('airnow');

var client = airnow({ apiKey: 'my airnow.org key' });

// build my options
var options = {
	latitude: 38.33,
	longitude: -122.28,
	distance: 100,
	format: "application/json"
};

// get the current observations by latitude and longitude
client.getObservationsByLatLng(options, function(err, observations){
	if (err){
		console.log('derp! an error calling getObservationsByLatLng: ' + err);
	} else {
		// the world is good! start processing the observations
	}
});

options

| Parameter | Description | Type | Required | |:-----------:|----------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|----------| | latitude | Latitude in decimal degrees | Number | Yes | | longitude | Longitude in decimal degrees | Number | Yes | | distance | If no reporting area is associated with the specified latitude and longitude, return a forecast from a nearby reporting area within this distance (in miles). | Number | No | | format | Format of the payload returned. Defaults to "application/json" and the response will be a parsed JSON object. "text/csv" "application/json" "application/xml" | String | No |

getObservationsByMonitoringSite

Get observations for a bounded box monitoring site.

example

var airnow = require('airnow');

var client = airnow({ apiKey: 'my airnow.org key' });

// build my options
var options = {
	latitude: 38.33,
	longitude: -122.28,
	distance: 100,
	format: "application/json"
};

// get the observations by monitoring site
client.getObservationsByMonitoringSite(options, function(err, observations){
	if (err){
		console.log('derp! an error calling getObservationsByMonitoringSite: ' + err);
	} else {
		// the world is good! start processing the observations
	}
});

options

| Parameter | Description | Type | Required | |:-----------:|----------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|----------| | latitude | Latitude in decimal degrees | Number | Yes | | longitude | Longitude in decimal degrees | Number | Yes | | distance | If no reporting area is associated with the specified latitude and longitude, return a forecast from a nearby reporting area within this distance (in miles). | Number | No | | format | Format of the payload returned. Defaults to "application/json" and the response will be a parsed JSON object. "text/csv" "application/json" "application/xml" | String | No |

getHistoricalObservationsByZipCode

Get historical observations for a zip.

example

var airnow = require('airnow');

var client = airnow({ apiKey: 'my airnow.org key' });

// build my options
var options = {
	zipCode: "53703",
	date: new Date(1448984256072),
	distance: 100,
	format: "application/json"
};

// get the historical observations by zip code
client.getHistoricalObservationsByZipCode(options, function(err, observations){
	if (err){
		console.log('derp! an error calling getHistoricalObservationsByZipCode: ' + err);
	} else {
		// the world is good! start processing the observations
	}
});

options

| Parameter | Description | Type | Required | |:-----------:|----------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|----------| | zipCode | Zip Code | String | Yes | | date | date of observations | Date | Yes | | distance | If no reporting area is associated with the specified Zip Code, return a forecast from a nearby reporting area within this distance (in miles). | Number | No | | format | Format of the payload returned. Defaults to "application/json" and the response will be a parsed JSON object. "text/csv" "application/json" "application/xml" | String | No |

getHistoricalObservationsByLatLng

Get historical observations for a latitude and longitude pair.

example

var airnow = require('airnow');

var client = airnow({ apiKey: 'my airnow.org key' });

// build my options
var options = {
	latitude: 38.33,
	longitude: -122.28,
	date: new Date(1448984256072),
	distance: 100,
	format: "application/json"
};

// get the historical observations by latitude and longitude
client.getHistoricalObservationsByLatLng(options, function(err, observations){
	if (err){
		console.log('derp! an error calling getHistoricalObservationsByLatLng: ' + err);
	} else {
		// the world is good! start processing the observations
	}
});

options

| Parameter | Description | Type | Required | |:-----------:|----------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|----------| | latitude | Latitude in decimal degrees | Number | Yes | | longitude | Longitude in decimal degrees | Number | Yes | | date | date of observations | Date | Yes | | distance | If no reporting area is associated with the specified latitude and longitude, return a forecast from a nearby reporting area within this distance (in miles). | Number | No | | format | Format of the payload returned. Defaults to "application/json" and the response will be a parsed JSON object. "text/csv" "application/json" "application/xml" | String | No |

Contributing

The more PRs the merrier. :-)