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

weathered

v0.3.6

Published

A JavaScript wrapper for the National Weather Service API

Downloads

357

Readme

weathered 🌤⛈☀️🌨

A JavaScript wrapper for the National Weather Service API - built with TypeScript.

CircleCI

Source code

Documentation

A couple examples are below. There is also extensive typedoc generated documentation.

Installation

npm install weathered

Getting Started

Import and instantiate a client

import { Client } from 'weathered';

const client = new Client();

Get active weather alerts for a location (latitude and longitude)

const active = true;
const latitude = 35.6175667;
const longitude = -80.7709911;
const alerts = await client.getAlerts(active, { latitude, longitude });

alerts.features.forEach(feature => {
  console.log(feature.properties.description);
  console.log(feature.geometry);
});
// At 744 PM EDT, Doppler radar indicated strong thunderstorms along a
// line extending from 11 miles southeast of Yadkinville to 6 miles
// south of Mocksville to 7 miles northwest of Huntersville, and moving
// east at 20 mph.
// {
//   type: 'Polygon',
//   coordinates: [
//     [ [Array], [Array] ]
//   ]
// }

Get all weather alerts (active or inactive) for a region

const alerts = await client.getAlerts(active, { region: 'AL' });
alerts.features.forEach(feature => {
  console.log(feature.properties.description);
  console.log(feature.geometry);
});
// The Flood Warning continues for
// the Pearl River Above Philadelphia ...
// {
//   type: 'Polygon',
//   coordinates: [
//     [ [Array], [Array] ]
//   ]
// }

Get weather forecast for a location (latitude and longitude)

const forecast = await client.getForecast(latitude, longitude, 'baseline');
forecast.properties.periods.forEach(period => {
  console.log(`${period.name}: ${period.detailedForecast}`);
});
// Today Partly sunny, with a high near 86. Northeast wind 2 to 6 mph.
// Tonight Partly cloudy, with a low around 68. South southeast wind around 3 mph.

Get the closest weather stations for a given latitude and longitude

const stations = await client.getStations(latitude, longitude);
stations.features.forEach(station => console.log(station.properties.name));
// San Francisco, San Francisco International Airport
// SAN FRANCISCO DOWNTOWN
// Half Moon Bay Airport

Get the closest weather station for a given latitude and longitude

const nearestStation = await client.getNearestStation(latitude, longitude);
if (nearestStation) {
  console.log(nearestStation.properties.stationIdentifier);
}
// KSFO

Get weather observations for a given station

const nearestStation = await client.getNearestStation(latitude, longitude);
if (nearestStation) {
  const { stationIdentifier } = nearestStation.properties;
  const observations = await client.getStationObservations(stationIdentifier);
  observations.features.forEach(obs => console.log(obs.properties.temperature));
  // { value: 16.1, unitCode: 'unit:degC', qualityControl: 'qc:V' }
  // { value: 16.7, unitCode: 'unit:degC', qualityControl: 'qc:V' }
  // { value: 17.2, unitCode: 'unit:degC', qualityControl: 'qc:V' }
}

Get the latest weather observation for a given station

const latestObservation = await client.getLatestStationObservations('KSFO');
console.log(latestObservation.properties.relativeHumidity);
// { value: 64.486025639597, unitCode: 'unit:percent', qualityControl: 'qc:V' }