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

sg-hazometer

v1.0.1

Published

easy retrieval of pollutant/air quality information/haze levels from NEA APIs at data.gov.sg

Downloads

21

Readme

sg-hazometer

The Singapore Hazometer is a simple npm module allowing for easy retrieval of pollutant data from data.gov.sg, which is in turn sourced from NEA.

`node demo.js`

Demo

const hazometer = require("sg-hazometer")
const apiKey = "xxx" // get one here https://developers.data.gov.sg
	
hazometer.getInfo({apiKey}, function(err, data){
	console.log(data)
})
	

You'll get something like the following:

{
	summary: 'healthy',
	last_update: 2017 - 02 - 09 T14: 00: 00.000 Z,
	east: {
		dailyPM10: 32,
		dailyPM25: 20,
		'8hCO': 0.27,
		'2hNO2': 15,
		dailySO2: 3,
		'8hO3': 56,
		'3hPSI': 53,
		dailyPSI: 60,
		location: {
			latitude: 1.35735,
			longitude: 103.94
		}
	},
	central: {
		dailyPM10: 29,
		dailyPM25: 19,
		'8hCO': 0.58,
		'2hNO2': 60,
		dailySO2: 5,
		'8hO3': 58,
		'3hPSI': 59,
		dailyPSI: 59,
		location: {
			latitude: 1.35735,
			longitude: 103.82
		}
	},
	south: {
		dailyPM10: 28,
		dailyPM25: 18,
		'8hCO': 0.52,
		'2hNO2': 60,
		dailySO2: 137,
		'8hO3': 57,
		'3hPSI': 59,
		dailyPSI: 61,
		location: {
			latitude: 1.29587,
			longitude: 103.82
		}
	},
	north: {
		dailyPM10: 33,
		dailyPM25: 21,
		'8hCO': 0.4,
		'2hNO2': 20,
		dailySO2: 11,
		'8hO3': 63,
		'3hPSI': 56,
		dailyPSI: 61,
		location: {
			latitude: 1.41803,
			longitude: 103.82
		}
	},
	west: {
		dailyPM10: 30,
		dailyPM25: 17,
		'8hCO': 0.78,
		'2hNO2': 39,
		dailySO2: 4,
		'8hO3': 77,
		'3hPSI': 40,
		dailyPSI: 56,
		location: {
			latitude: 1.35735,
			longitude: 103.7
		}
	},
	national: {
		dailyPM10: 33,
		dailyPM25: 21,
		'8hCO': 0.78,
		'2hNO2': 60,
		dailySO2: 137,
		'8hO3': 77,
		'3hPSI': 55,
		dailyPSI: 61,
		location: {
			latitude: 0,
			longitude: 0
		}
	}
}

FAQ

What do all these terms mean?

summary: human-readable assessment of current air quality (see this)

dailyPM10: 24h readings for particulate matter 10 micrometers or less in diameter

dailyPM25: ditto, but for particulate matter 2.5 micrometers or less in diameter

8hCO: 8h readings for Carbon Monoxide levels

2hNO2: 2h readings for Nitrogen Dioxide levels

dailySO2: 24h readings for Sulfur Dioxide levels

8hO3: 8h readings for Ozone levels

3hPSI: 3h readings for the NEA-released Particulate Matter Index (PSI)

dailyPSI: ditto but every 24h

location: coordinates of the points at which the readings are taken at

Why don't the dateTime or date parameters seem to do anything?

The data.gov.sg API seems to be faulty.

Why is data on pollution sub-indexes not included?

The Pollutant Standards Index (PSI) is calculated from sub-indexes using a formula detailed here. This module retrieves the raw data that is used to calculate the index, that is then used to calculate the overall PSI. Unless you plan to check NEA's mathematics, it's unlikely the sub-index itself will be of any interest.