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

weatherlink

v1.2.1

Published

A wrapper library for WeatherLink v2 API

Downloads

23

Readme

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

Weatherlink

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