Socket
Socket
Sign inDemoInstall

waqi-js-client

Package Overview
Dependencies
15
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    waqi-js-client

JS client library for the World Air Quality Index (WAQI) APIs. All available API modules are supported - City feed, Geolocalized feed, Search, and Map Queries.


Version published
Weekly downloads
0
Maintainers
1
Created
Weekly downloads
 

Readme

Source

WAQI JavaScript Client

JavaScript client library for the World Air Quality Index (WAQI) APIs. See documentation here. All available API modules are supported - City feed, Geolocalized feed, Search, and Map Queries.

Installation

You can include this package in your JavaScript project using npm or yarn:

npm install waqi-js-client

Get API key

Sign up for an API key here

Making Requests

The primary API class is a factory class that creates objects for each of the API modules, allowing you to make requests to any of them with your desired request parameters. You have to first create an object for it, then access your desired API module via the object. See the code snippets below:

const apiKey = 'YOUR_API_KEY';
const waqiAPI = new API(apiKey);

For City Feed:

const cityFeedEntity = waqiAPI.cityFeed();
cityFeedEntity.setCity("Munich");
cityFeedEntity.fetchItems().then(response => {
    console.log(response);
}).catch(error => {
    console.error(error);
});

For Search:

const searchEntity = waqiAPI.search();
searchEntity.setKeyword("Johannesburg");
searchEntity.fetchItems().then(response => {
    console.log(response);
}).catch(error => {
    console.error(error);
});

For Lat/Lng based Geolocalized feed:

const geoFeedEntity = waqiAPI.geoFeed();
geoFeedEntity.setCoordinates(37.7749, -122.4194);
geoFeedEntity.fetchItems().then(response => {
    console.log(response);
}).catch(error => {
    console.error(error);
});

For IP based Geolocalized feed:

const ipFeedEntity = waqiAPI.ipFeed();
ipFeedEntity.setIP("MY_IP");
ipFeedEntity.fetchItems().then(response => {
    console.log(response);
}).catch(error => {
    console.error(error);
});

For Map Queries:

const mapStationEntity = waqiAPI.mapStation();
mapStationEntity.setMapBounds(40.712, -74.006, 34.052, -118.243);
mapStationEntity.fetchItems().then(response => {
    console.log(response);
}).catch(error => {
    console.error(error);
});

Replace 'YOUR_API_KEY' with your actual API key when using this library.

Keywords

FAQs

Last updated on 14 Sep 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc