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

nws-wrapper

v1.0.0

Published

National Weather Service (US) API Wrapper for JS

Downloads

10

Readme

NWS Wrapper

This is a Node.js package that provides a simple API for accessing data from the National Weather Service (NWS) API. npm version license

Installation

To install this package, run the following command: npm install nws-wrapper

Usage

getPointData(lat, lon)

This function retrieves the point data for a given latitude and longitude. It returns a Promise that resolves to an object containing the following properties:

  • id: the URL of the API endpoint for this point
  • type: the type of the API endpoint for this point
  • geometry: an object containing the latitude and longitude of this point
  • properties: an object containing various properties of this point, including the forecast URL, the forecast grid URL, and the observation URL

Default response:

{
  "id": "https://api.weather.gov/points/38.7845,-77.0888",
  "type": "Feature",
  "geometry": {
    "type": "Point",
    "coordinates": [
      -77.0888,
      38.7845
    ]
  },
  "properties": {
    "cwa": "LWX",
    "forecastOffice": "https://api.weather.gov/offices/LWX",
    "gridX": 57,
    "gridY": 74,
    "forecast": "https://api.weather.gov/gridpoints/LWX/57,74/forecast",
    "forecastHourly": "https://api.weather.gov/gridpoints/LWX/57,74/forecast/hourly",
    "forecastGridData": "https://api.weather.gov/gridpoints/LWX/57,74",
    "observationStations": "https://api.weather.gov/gridpoints/LWX/57,74/stations",
    "relativeLocation": {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          -77.091138,
          38.790957
        ]
      },
      "properties": {
        "city": "Merrifield",
        "state": "VA",
        "distance": {
          "value": 3032.8744011284,
          "unitCode": "unit:m"
        },
        "bearing": {
          "value": 82,
          "unitCode": "unit:degrees_true"
        }
      }
    },
    "forecastZone": "https://api.weather.gov/zones/forecast/VAZ052",
    "county": "https://api.weather.gov/zones/county/VAC059",
    "fireWeatherZone": "https://api.weather.gov/zones/fire/VAZ052",
    "timeZone": "America/New_York",
    "radarStation": "KLWX"
  }
}

Example usage:

const { getPointData } = require('nws-wrapper');

getPointData(40.7128, -74.0060)
  .then(pointData => {
    console.log(pointData);
  })
  .catch(error => {
    console.error(error);
  });

getGrid(lat, lon)

This function retrieves the grid coordinates for a given latitude and longitude. It returns a Promise that resolves to a string containing the grid coordinates in the format "x,y".

Default response:

const { getGrid } = require('nws-wrapper');

getGrid(40.7128, -74.0060)
  .then(grid => {
    console.log(grid);
  })
  .catch(error => {
    console.error(error);
  });

checkWeatherWarnings(latitude, longitude)

This function checks for active weather warnings for a given latitude and longitude. It returns a Promise that resolves to an array of objects containing the following properties:

descr: the description of the weather warning hl: the headline of the weather warning If there are no active weather warnings, it returns a string indicating that there are no active weather warnings.

Default response: "No active weather warnings found for this location." Example usage:

const { checkWeatherWarnings } = require('nws-wrapper');

checkWeatherWarnings(40.7128, -74.0060)
  .then(warnings => {
    console.log(warnings);
  })
  .catch(error => {
    console.error(error);
  });

checkKeyword(headline)

This function checks if a given headline contains any of the keywords used for weather warnings. It returns a string containing the keywords found, separated by commas. If no keywords are found, it returns the string "NONE".

Default response:

"NONE" Example usage:

const { checkKeyword } = require('nws-wrapper');

const headline = "Winter Storm Warning in effect";
const keywords = checkKeyword(headline);

console.log(keywords);

getRadarSingle(office)

This function retrieves the URL of a single-frame radar image for a given NWS office. It returns a string containing the URL.

Default response:

"undefined"

Example usage:

const { getRadarSingle, getRadarStation } = require('nws-wrapper');

const radarStation = await getRadarStation(40.7128, -74.0060);
const radarUrl = getRadarSingle(radarStation);
console.log(radarUrl);

getRadarLoop(office)

This function retrieves the URL of a animated radar image for a given NWS office. It returns a string containing the URL.

Default response:

"undefined"

Example usage:

const { getRadarLoop, getRadarStation } = require('nws-wrapper');

const radarStation = await getRadarStation(40.7128, -74.0060);
const radarUrl = getRadarLoop(radarStation);
console.log(radarUrl);

getNWSOffice(lat, lon)

This function retrieves the NWS Office for a given latitude and longitude. It returns a Promise that resolves to a string containing the NWS office in the format “NWS” (NWS being the office ID).

Default response:

"undefined"

Example usage:

const { getNWSOffice } = require('nws-wrapper');

const nwsOffice = await getNWSOffice(40.7128, -74.0060);
console.log(nwsOffice);

getRadarStation(lat, lon)

This function retrieves the radar station for a given latitude and longitude.. It returns a string containing the radar station ID.

Default response:

"undefined"

Example usage:

const { getRadarStation } = require('nws-wrapper');

const radarStation = await getRadarStation(40.7128, -74.0060);
console.log(radarStation);

Thanks for reading!