Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

purpleair

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

purpleair

Retrieve AQI (with AQandU conversion) from a Purpleair sensor via the CLI or as a library to your node script

  • 1.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
increased by60%
Maintainers
1
Weekly downloads
 
Created
Source

purpleair

Retrieve AQI (with AQandU conversion) from a Purpleair sensor via the CLI or as a library to your node script

Most of this code was stolen from https://aqi.wtf

determine your purpleair sensor ID

Open the Purple Air map: https://www.purpleair.com/map?mylocation

and click on the sensor closest to your location.

The URL bar will change to something like:

https://www.purpleair.com/map?opt=1/mAQI/a10/cC0&select=62217#15.69/37.737125/-122.414218

The sensor ID will be the value of the select parameter. In the above URL, the ID is 62217:

https://www.purpleair.com/map?opt=1/mAQI/a10/cC0&select=62217#15.69/37.737125/-122.414218

cli usage

Install the module globally

npm install -g purpleair

Then call:

purpleair [sensor ID]

which will return the AQI.

Example output:

> purpleair 62217
139

With the AQI class:

> purpleair --class 62217
139 (unhealthy-for-sensitive-groups)

library usage

There are three functions:

  • getSensor(sensorId)
  • getAQI(sensor)
  • getAQIClass(aqi)

Example:

const purpleair = require('purpleair');

const main = async () => {
    try {

        var sensor = await purpleair.getSensor(62217);
        var aqi = await purpleair.getAQI(sensor);

        console.log(aqi);

        var aqiClass = purpleair.getAQIClass(aqi);

        console.log(aqiClass);

    } catch (err) {
        console.error(err);
    }
};

main();

License

MIT

Keywords

FAQs

Package last updated on 15 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc