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

hongkong-pollution

v1.0.6

Published

Simple module to get pollution data from the Hong Kong Enviromental Department.

Downloads

20

Readme

Hong Kong Air Quality Health Data API

What is this for?

Air Quality in Hong Kong is a big deal (mainly because it can vary considerably). I wanted to create a air monitoring solution that would tell me when it was more polluted outside. Luckily the government has a strong scientific team to monitor and give access via an official website an app. As part of the Hong Kong OpenData initiative they also offer RSS feeds for the data.

I've found that the official feed is lacking a lot of detail, so instead of using that, I looked at the unofficial JSON feeds that the mobile app uses and created a helpful node module to parse those. They are a bit strange in terms of the formatting, so I've tried to kind of nudge it into a format that's a bit easier to process.

Install

npm install --save hongkong-pollution

Usage

When creating the instance, you can pass some options, for now, only the language code is supported, possible values are 'en' English, 'tc' Traditional Chinese or 'sc' Simplified Chinese.

var HongKongPollution = require('hongkong-pollution');

var hkPollution = HongKongPollution({lang: 'en'});

hkPollution.getForecast().then(function(forecast){
    console.log(forecast);
});

Supported Methods

Example data

All methods return JSON, please see the examples linked above for more info on how to call each method.

hongKongPollution.getForecast()
  .then(function(forecast) {
    var prettyJSON = JSON.stringify(forecast,null,1);
    console.log(prettyJSON);
});

Gives this response

{
 "GeneralStation": [
  {
   "ForecastPeriod": "Today P.M.",
   "AQHIRisk": "Low to Moderate"
  },
  {
   "ForecastPeriod": "Tomorrow A.M.",
   "AQHIRisk": "Low to Moderate"
  }
 ],
 "RoadsideStation": [
  {
   "ForecastPeriod": "Today P.M.",
   "AQHIRisk": "Low to Moderate"
  },
  {
   "ForecastPeriod": "Tomorrow A.M.",
   "AQHIRisk": "Low to Moderate"
  }
 ],
 "CurrentAQHIReport": [
  {
   "StationType": "Roadside Stations",
   "AQHIRisk": "Low to Moderate",
   "AQHIRange": {
    "Lower": "3",
    "Upper": "4"
   }
  },
  {
   "StationType": "General Stations",
   "AQHIRisk": "Low to Moderate",
   "AQHIRange": {
    "Lower": "3",
    "Upper": "4"
   }
  }
 ],
 "lastBuildDate": "2016-06-07T16:00:00.000Z",
 "pollDate": "2016-06-08T07:57:46.401Z"
}

Other Handy Modules

Contributing

Feel free to submit any pull requests or add functionality, I'm usually pretty responsive.

If you like the module, please consider donating some bitcoin or litecoin.

Bitcoin

LNzdZksXcCF6qXbuiQpHPQ7LUeHuWa8dDW

LiteCoin

LNzdZksXcCF6qXbuiQpHPQ7LUeHuWa8dDW