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

wunderground

v0.0.0

Published

a simple wrapper around the wunderground API

Downloads

4

Readme

wunderground

A simple wrapper around the Wunderground API for Node.

Installation

Installation is quick and easy via NPM:

npm install wunderground

You will also need a valid Wunderground API key.

Why?

Becuase spending more than a few minutes getting this API up-and-running is better spent making your app awesome.

There are a few other modules out there that integrate the Wunderground API but I wasn't quite satisifed with them.

Usage

The module is designed to be simple and easy to use and follows Wunderground's API verbiage almost exclusively. Please see the Wunderground documentation for a list of all available options.

var wunderground = require('node-wunderground')('my-api-key');

var query = {
	city  : 'San Francisco',
	state : 'CA' // two-letter state code
};

// Print San Francisco's high and low temperatures for the next 10 days
wunderground.forecast10day(query, function(err, forecasts) {
	if(err) {
		// uh-oh!
	} else {
		var forecasts = res.forecast.simpleforecast.forecastday;
		for(var i = 0; i < forecasts.length; i++) {
			var f = forecasts[i];
			console.log([f.date.month, f.date.day, f.date.year].join('/') + ' - High: '+ f.high.fahrenheit +', Low: '+ f.low.fahrenheit);
		}
	}});

// OR:

wunderground.conditions(query, function(err, conditions) {
	// current conditions
	if(!err) {
		console.log('In Sanfrancisco, CA, it currently feels like '+ conditions.current_observation.temp_f);
	}
});

The module accepts a variety of parameters in the query object (formal paramater names included in parenthesis if different):

  • zip
  • city
  • state
  • airport code (airport)
  • PWS code (pws)
  • country
  • latitude (lat)
  • longitude (lng)

NOTE: Latitude and longitude BOTH required. Providing only one is illegal.

You can provide any number of parameters but there is a precedence and established patterns:

  • city & state
  • zip
  • country & city
  • lat & lng
  • airport
  • pws
  • country

Advanced Usage

You can also acess the wunderground.execute method directly--the main advantage of this is you can specify multiple data sources to receive in a single request.

For example:

var query = {
	zip : '20854'
};
var actions = ['forecast', 'forecast10day', 'conditions'];
wunderground.execute(actions, query, function(err, result) {
	// Result has the current forecast, the 10 day forecast, and the current conditions for the US zip code 20854.
});

Localization

The Wunderground API provides results in a large range of languages. You can specify the language for API requests on initlaization. Example:

var wunderground = require('node-wunderground')('my-api-key', 'FR');

All requests will be returned in French. All languages are specified with a two letter, capitalized string. See the official documentation for the full list.

License & Disclaimer

All usage of the Wunderground API is subjet to the API's terms of service, which can be found at: http://www.wunderground.com/weather/api/d/terms.html