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

aqicn-api

v1.0.4

Published

Node wrapper for the AQICN Air Quality Index API

Downloads

24

Readme

Aqicn Air Quality Index API

Node wrapper for the AQICN Air Quality Index API (https://aqicn.org/). New module for accessing AQICN global air quality data, now that Aqicn.org provides a REST API. No web scraping, etc.

Installation

npm i -s aqicn-api

Getting an API Token

You should be able to get an API token for 1000 requests per minute, in just a few minutes, using the online form, at: https://aqicn.org/api/

The API token demo can be used for testing, but will only return results for Shanghai (上海).

Usage

Make a request to the Aqicn.org REST API to gather Air Quality data for a given city (One method exposes the current Aqicn API):

Configuration Object Inputs:

  • token (required): Your API token (See above)
  • city (optional): The city name for the lookup
  • lang (optional): Response Explanation Language - currently en (English) & cn (Simplified Chinese) are supported
  • lat (optional): Can be used instead of city for lat/long based location lookup
  • long (optional): Can be used instead of city for lat/long based location lookup

Note: Either city name or lat+long must be used

Example with city name

const aqicn = require('aqicn-api');

aqicn({ city: 'shanghai', lang: 'en', token: 'demo' }, function (data) {
    console.log(data);
});

Example with Lat / long instead of city name

const aqicn = require('aqicn-api');

aqicn({ lat: 31.2047372, long: 121.4489017, lang: 'en', token: 'demo' }, function (data) {
    console.log(data);
});

API Response

{ 
  aqi: 82,
  idx: 1437,
  city: 'Shanghai (上海)',
  dominentpol: 'pm25',
  time: 1577120400000,
  level: 5,
  co: 9.1,
  no2: 20.6,
  o3: 29.3,
  p: 1018.4,
  pm10: 33,
  pm25: 82,
  so2: 3.6,
  t: 11.6,
  w: 0.1,
  url: 'https://aqicn.org/city/shanghai',
  geo: [ 31.2047372, 121.4489017 ],
  label: 'Moderate',
  implications:
   'Air quality is acceptable; however, for some pollutants there may be a moderate health concern for a very small number of people who are unusually sensitive to air pollution.',
  precautions:
   'Active children and adults, and people with respiratory disease, such as asthma, should limit prolonged outdoor exertion.',
  attributions:
   [ { url: 'http://www.semc.gov.cn/',
       name: 'Shanghai Environment Monitoring Center(上海市环境监测中心)' },
     { url: 'http://106.37.208.233:20035/emcpublish/',
       name:
        'China National Urban air quality real-time publishing platform (全国城市空气质量实时发布平台)' },
     { url:
        'https://china.usembassy-china.org.cn/embassy-consulates/shanghai/air-quality-monitor-stateair/',
       name: 'U.S. Consulate Shanghai Air Quality Monitor' },
     { url: 'https://waqi.info/',
       name: 'World Air Quality Index Project' } ]
}

Todos

Pull requests welcome!

  • [x] Add additional languages
  • [x] Lat/long based lookups