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-api-wrapper

v1.1.0

Published

API wrapper for the provided NWS API

Downloads

6

Readme

NWS API

NWS API is an API wrapper for the API provided by the National Weather Service. The API provides forecasts, alerts, and other weather related data based on location (coordinates, or forecast grids).

More information on the National Weather Service API can be found here.

Installation

npm install nws-api-wrapper

Implementation

const NWS = require('nws-api-wrapper');

Functions & Examples

getStatus();

NWS.getStatus();

Description & Notes:

This function returns the status of the API using the base URL https://api.weather.gov


getLocationInfo();

NWS.getLocationInfo(<latitude>, <longitude>);

Description & Notes:

This function requires 2 parameters (latitude, and longitude), and will return an object of data about the coordinates such as grid coordinates, forecast links, and even the relative city, and state.


getForecast();

NWS.getForecast(<latitude>, <longitude>, <periods>);

Usage Example:

try {
    let response = await NWS.getForecast(39.7456, -97.0892, 3);
    // Handle response here.
}
catch (error) {
    // Handle error here.
}

Description & Notes:

This function has 3 parameters total, the first 2 (latitude, and longitude) are required, while the 3rd parameter (periods) is optional. The 3rd parameter if supplied must be a number between 1-14 otherwise an error will be thrown. If the period parameter is not supplied, the function will return all 14 periods.

This function will return an array of up to 14 forecast periods (each period will be an object). Each period is about a 12 hour timeframe (7AM-7PM & 7PM-7AM EST). If the function is called at 3PM EST, the first period won’t be a full 12 hours, instead that timeframe will be 3PM-7PM EST.


getHourlyForecast();

NWS.getHourlyForecast(<latitude>, <longitude>, <periods>);

Usage Example:

try {
    let response = await NWS.getHourlyForecast(39.7456, -97.0892, 24);
    // Handle response here.
}
catch (error) {
    // Handle error here.
}

Description & Notes:

This function has 3 parameters total, the first 2 (latitude, and longitude) are required, while the 3rd parameter (periods) is optional. The 3rd parameter if supplied must be a number between 1-156, otherwise an error will be thrown. If the period parameter is not supplied, the function will return all 156 periods.

Similar to the getForecast(); function, this will return an array of forecast periods (each period will be an object). Each period is 1 hour, with the exception of the first period if called after the beginning of an hour.