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

node-breezometer

v3.1.0

Published

npm module for breezometer's air quality API

Downloads

14

Readme

node-breezometer

node-breezometer is a module for making HTTP requests to the breezometer.com webservices API.

Installation

npm install node-breezometer --save

Quick Examples

const breezometer = require('node-breezometer');

const client = breezometer({ apiKey: 'my breezometer API key' });

// get the current AQI by geocode

// w/callback
client.getAirQuality({ lat: 43.067475, lon:-89.392808 }, function(err, data){
	
});

// w/async await
data = await client.getAirQuality({ lat: 43.067475, lon:-89.392808 });

// get the historical air quality for a dateTime

// w/callback
client.getHistoricalAirQuaility({ lat: 43.067475, lon:-89.392808, dateTime: new Date(Date.now() - 864000000) }, function(err, data){
	
});

// w/async await
data = await client.getHistoricalAirQuaility({ lat: 43.067475, lon:-89.392808, dateTime: new Date(Date.now() - 864000000) });

// get the historical air quality for a timespan

// w/callback
client.getHistoricalAirQuaility({ lat: 43.067475, lon:-89.392808, startDate: new Date(Date.now() - 864000000), endDate: new Date(Date.now() - 432000000)}, function(err, data){
	
});

// w/async await
data = await client.getHistoricalAirQuaility({ lat: 43.067475, lon:-89.392808, hours:8 });

// get the historical air quality for the last 8 hours

// w/callback
client.getHistoricalAirQuaility({ lat: 43.067475, lon:-89.392808, hours:8 }, function(err, data){
	
});

// w/async await
data = await client.getHistoricalAirQuaility({ lat: 43.067475, lon:-89.392808, hours:8 });


// get a forecast for the next 8 hours

// w/callback
client.getForecast({ lat: 43.067475, lon:-89.392808, hours:8 }, function(err, data){
	
});

// w/async await
data = await client.getForecast({ lat: 43.067475, lon:-89.392808, hours:8 });

// get a forecast for a date range

// w/callback
client.getForecast({ lat: 43.067475, lon:-89.392808, startDate: new Date(Date.now() + 3600000), endDate: new Date(Date.now() + 864000000) }, function(err, data){
	
});

// w/async await
data = await client.getForecast({ lat: 43.067475, lon:-89.392808, startDate: new Date(Date.now() + 3600000), endDate: new Date(Date.now() + 864000000) });

// get a forecast ending at a datetime

// w/callback
client.getForecast({ lat: 43.067475, lon:-89.392808, dateTime: new Date(Date.now() + 864000000)}, function(err, data){
	
});

// w/async await
data = await client.getForecast({ lat: 43.067475, lon:-89.392808, dateTime: new Date(Date.now() + 864000000)});

Air Quality Features

  1. Current Air Quality
  2. Historical Air Quality
  3. Forecasts
  4. Exponential backoff for retrying failed requests

getAirQuality

Get the current air quality for a location.

example

const breezometer = require('node-breezometer');

const client = breezometer({ apiKey: 'my breezometer API key' });

// build my options
var options = {
	lat: 43.067475,
	lon:-89.392808,
	lang: 'en',
	features:['breezometer_aqi', 'local_aqi','pollutants_aqi_information']
};

// get the air quality by geocode
client.getAirQuality(options, function(err, body){
	if (err){
		console.log('derp! an error calling getAirQuality: ' + err);
	} else if (!body.data){
		// location does not have data
	} else {
		// the world is good! start processing the air quality
	}
});

options

| Parameter | Description | Type | Required | |-----------|-------------------------------|-----------|----------| | lat | WGS84 standard latitude | Number | Yes | | lon | WGS84 standard latitude | Number | Yes | | lang | language used for the request | String | No | | features | Filter the response fields | String[] | No | | metatdata | Include metadata in response | Boolean | No |

getHistoricalAirQuaility

Gets air quality data for a location at a single date and time or a date range.

example single date and time

const breezometer = require('node-breezometer');

const client = breezometer({ apiKey: 'my breezometer API key' });

// build my options
var options = {
	lat: 43.067475,
	lon:-89.392808,
	dateTime: new Date(Date.now() - 864000000)
};

// get the historical air quality for a dateTime
client.getHistoricalAirQuaility(options, function(err, body){
	if (err){
		console.log('derp! an error calling getHistoricalAirQuaility: ' + err);
	} else if (!body.data){
		// location does not have data
	} else {
		// the world is good! start processing the air quality
	}
});

example date range

const breezometer = require('node-breezometer');

const client = breezometer({ apiKey: 'my breezometer API key' });

// build my options
var options = {
	lat: 43.067475,
	lon:-89.392808,
	lang: 'en',
	fields:['breezometer_aqi', 'country_aqi','pollutants'],
	startDate: new Date(Date.now() - 1728000000),
	endDate: new Date(Date.now() - 864000000),
	interval: 1
};

// get the historical air quality for a date range
client.getHistoricalAirQuaility(options function(err, body){
	if (err){
		console.log('derp! an error calling getHistoricalAirQuaility: ' + err);
	} else if (!body.data){
		// location does not have data
	} else {
		// the world is good! start processing the air quality reports
	}
});

options

| Parameter | Description | Type | Required | |-----------|------------------------------------------------------------------|------------|----------| | lat | WGS84 standard latitude | Number | Yes | | lon | WGS84 standard latitude | Number | Yes | | lang | language used for the request | String | No | | features | Filter the response fields | String[] | No | | dateTime | ISO8601 date and time you want historical air quality for | Date | No | | startDate | ISO8601 start date for a range of historical air quality results | Date | No | | endDate | ISO8601 end date for a range of historical air quality results | Date | No | | hours | Number of historical hourly forecasts to receive | Number | No | | metadata | Include metadata in response | Boolean | No |

getForecast

Gets future forecast(s) for a location.

example hours

const breezometer = require('node-breezometer');

const client = breezometer({ apiKey: 'my breezometer API key' });

// build my options
var options = {
	lat: 43.067475,
	lon:-89.392808,
	lang: 'en',
	features:['breezometer_aqi', 'local_aqi','pollutants_aqi_information'],
	hours: 8
};

// get an hourly forecast for a location for the next 8 hours
client.getForecast(options function(err, body){
	if (err){
		console.log('derp! an error calling getForecast: ' + err);
	} else if (!body.data){
		// location does not have data
	} else {
		// the world is good! start processing the hourly air quality forecasts
	}
});

example date range

const breezometer = require('node-breezometer');

const client = breezometer({ apiKey: 'my breezometer API key' });

// build my options
var options = {
	lat: 43.067475,
	lon:-89.392808,
	startDate: new Date(),
	endDate: new Date(Date.now() + 864000000)
};

// get an hourly forecast for the next 24 hours
client.getForecast(options function(err, body){
	if (err){
		console.log('derp! an error calling getForecast: ' + err);
	} else if (!body.data){
		// location does not have data
	} else {
		// the world is good! start processing the hourly air quality forecasts
	}
});

options

| Parameter | Description | Type | Required | |-----------|--------------------------------------------------------------------------------|----------|----------| | lat | WGS84 standard latitude | Number | Yes | | lon | WGS84 standard latitude | Number | Yes | | lang | language used for the request | String | No | | features | Filter the response fields | String[] | No | | startDate | A specific start date range to get predictions for.,Can not be used with hours | Date | No | | endDate | IA specific end date range to get predictions for.,Can not be used with hours | Date | No | | hours | Number of hourly forecasts to receive from now | Number | No | | dateTime | ISO8601 date and time you want forecasted air quality until | Date | No | | metadata | Include metadata in response | Boolean | No |

Pollen Features

  1. Forecasts

getDailyPollenForecast

Gets future daily pollen forecast(s) for a location.

example

const breezometer = require('node-breezometer');

const client = breezometer({ apiKey: 'my breezometer API key' });

// build my options
var options = {
	lat: 43.067475,
	lon:-89.392808,
	days: 3,
	features:['types_information', 'plants_information']
};

// get a daily forecast for a location for the next 3 days
client.getDailyPollenForecast(options, function(err, body) {
	if (err){
		console.log('derp! an error calling getDailyPollenForecast: ' + err);
	} else if (!body.data){
		// location does not have data
	} else {
		// the world is good! start processing the daily pollen forecasts
	}
});

Options

| Parameter | Description | Type | Required | |-----------|--------------------------------------------------------------------------------|----------|----------| | lat | WGS84 standard latitude | Number | Yes | | lon | WGS84 standard latitude | Number | Yes | | days | Number of days of forecast to receive | Number | Yes | | lang | Language used for the request | String | No | | features | Filter the response fields | String[] | No | | metadata | Include metadata in response | Boolean | No |

Fire Features

  1. Current Fire Conditions

getCurrentFireConditions (Beta)

Gets the current fire conditions for a location. Breezometer's Fire API is still in Beta.

example

const breezometer = require('node-breezometer');

const client = breezometer({ apiKey: 'my breezometer API key' });

// build my options
var options = {
	lat: 43.067475,
	lon:-89.392808,
	units: 'imperial',
	radius: 50
};

// get the current fire conditions by geocode
client.getCurrentFireConditions(options, function(err, body){
	if (err){
		console.log('derp! an error calling getCurrentFireConditions: ' + err);
	} else if (!body.data){
		// location does not have data
	} else {
		// the world is good! start processing the surrounding fires
	}
});

options

| Parameter | Description | Type | Required | |-----------|-------------------------------|-----------|----------| | lat | WGS84 standard latitude | Number | Yes | | lon | WGS84 standard latitude | Number | Yes | | lang | language used for the request | String | No | | radius | radius around lat/lon to receive data | Number | No | | units | units of radius and response | String | No | | metatdata | Include metadata in response | Boolean | No |

Contributing

The more PRs the merrier. :-)

Breezometer Association

node-breezometer npm package is not supported by Breezometer.