Socket
Socket
Sign inDemoInstall

weatherlink

Package Overview
Dependencies
11
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    weatherlink

A wrapper library for WeatherLink v2 API


Version published
Weekly downloads
1
decreased by-80%
Maintainers
1
Install size
7.12 MB
Created
Weekly downloads
 

Readme

Source

https://nodei.co/npm/weatherlink.png?downloads=true&downloadRank=true&stars=true

Unofficial js wrapper library for WeatherLink v2 API

Install

npm install weatherlink

or

yarn add weatherlink

Usage

const Weatherlink = require('weatherlink');

const apiKey = '<replace with your api key>';
const apiSecret = '<replace with your api secret>';

const weatherLink = WeatherLink({apiKey, apiSecret});

Methods

Metadata about the weather stations and sensors, as well as the different types of sensors

GET/stations Get all weather stations associated with your API Key

weatherLink.getAllStations().then(console.log).catch(console.error);

GET /stations​/{station-ids} Get weather stations for one or more station IDs provided

weatherLink
  .getStations({stationIds: ['102882']})
  .then(console.log)
  .catch(console.error);

GET /sensors Get all sensors attached to all weather stations associated with your API Key

weatherLink.getAllSensors().then(console.log).catch(console.error);

GET /sensors​/{sensor-ids} Get sensors for one or more sensor IDs provided

weatherLink
  .getSensors({sensorIds: ['371124', '371125']})
  .then(console.log)
  .catch(console.error);

GET /sensor-catalog Get a catalog of all types of sensors

weatherLink.getSensorCatalog().then(console.log).catch(console.error);

This call is not in the official weatherlink documentation

This returns all sensors attached to all weather stations associated with your API Key with their very own specs from sensor catalog. It's just a mix of /sensors + /sensor-catalog

weatherLink
  .getAllSensorsWithSpecs()
  .then((data) => console.log(JSON.stringify(data, null, 2)))
  .catch(console.error);

Weather Data

Weather sensor observation data

GET /current​/{station-id} Get current conditions data for one station

weatherLink
  .getCurrent({stationId: '102882'})
  .then(console.log)
  .catch(console.error);

GET /historic​/{station-id} Get historic data for one station ID within a given timerange

Using date-fns

const subDays = require('date-fns/subDays');
const getUnixTime = require('date-fns/getUnixTime');

const now = new Date();
const yesterday = subDays(now, 1);
const startTimestamp = getUnixTime(yesterday);
const endTimestamp = getUnixTime(now);

weatherLink
  .getHistoric({stationId: '102882', startTimestamp, endTimestamp})
  .then((r) => console.log(JSON.stringify(r, null, 2)))
  .catch(console.log);

Examples

Here

Keywords

FAQs

Last updated on 10 Jan 2021

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