node-breezometer

npm module for breezometer's air quality API

Showing:

Popularity

Downloads/wk

16

GitHub Stars

1

Maintenance

Last Commit

2yrs ago

Contributors

5

Package

Dependencies

6

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

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

ParameterDescriptionTypeRequired
latWGS84 standard latitudeNumberYes
lonWGS84 standard latitudeNumberYes
langlanguage used for the requestStringNo
featuresFilter the response fieldsString[]No
metatdataInclude metadata in responseBooleanNo

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

ParameterDescriptionTypeRequired
latWGS84 standard latitudeNumberYes
lonWGS84 standard latitudeNumberYes
langlanguage used for the requestStringNo
featuresFilter the response fieldsString[]No
dateTimeISO8601 date and time you want historical air quality forDateNo
startDateISO8601 start date for a range of historical air quality resultsDateNo
endDateISO8601 end date for a range of historical air quality resultsDateNo
hoursNumber of historical hourly forecasts to receiveNumberNo
metadataInclude metadata in responseBooleanNo

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

ParameterDescriptionTypeRequired
latWGS84 standard latitudeNumberYes
lonWGS84 standard latitudeNumberYes
langlanguage used for the requestStringNo
featuresFilter the response fieldsString[]No
startDateA specific start date range to get predictions for.,Can not be used with hoursDateNo
endDateIA specific end date range to get predictions for.,Can not be used with hoursDateNo
hoursNumber of hourly forecasts to receive from nowNumberNo
dateTimeISO8601 date and time you want forecasted air quality untilDateNo
metadataInclude metadata in responseBooleanNo

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

ParameterDescriptionTypeRequired
latWGS84 standard latitudeNumberYes
lonWGS84 standard latitudeNumberYes
daysNumber of days of forecast to receiveNumberYes
langLanguage used for the requestStringNo
featuresFilter the response fieldsString[]No
metadataInclude metadata in responseBooleanNo

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

ParameterDescriptionTypeRequired
latWGS84 standard latitudeNumberYes
lonWGS84 standard latitudeNumberYes
langlanguage used for the requestStringNo
radiusradius around lat/lon to receive dataNumberNo
unitsunits of radius and responseStringNo
metatdataInclude metadata in responseBooleanNo

Contributing

The more PRs the merrier. :-)

Breezometer Association

node-breezometer npm package is not supported by Breezometer.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial