New Weather Underground API
This page documents some PHP scripts I have written to work
New Weather Underground
API. Specifically, the scripts consist of a base script
which contains functions to access the API, a user data include script
that contains the user api key & settings, and several scripts to call
the functions. At the time of this writing the scripts will access
the conditions, forecast, or a combined conditions&forecast. I
have also included a brief documentation file that outlines how to
install and use the scripts. The documentation is displayed on
Some notable features:
The main scripts will access the API by postal code.
- Specific weather stations can be associated with postal codes for
observed weather conditions.
document.write () statement which can be used within an html page.
- The script supports the full 5 day Weather Underground forecasts.
- A cache file is used to minimize API accesses. Using the cache greatly reduces
- The scripts include multiple icon sets for the forecast icons.
- The scripts support CSS. The user specifies the css prefix and
the returned html code contains class definitions.
- The scripts include a Weather Underground/ IBM logo. The logo can
be resized, turned off, or replaced by the user.
- The scripts include an API driven weather sticker gadget that uses
- The script uses cURL for http accesses and will work on almost all
- Output can be either English or Metric units. F temp., in/Hg
baro, inch rain, mph wind -or- C temp, mb baro, mm rain, km/h wind.
- Sun/Moon rise/set times and icons can be switched on or off in the forecast.
- The code is extensively commented and can be modified by any competent
- Now shows a link to National Weather Service alerts for US zip codes
if an alert is detected.
- The new scripts
are fairly compatible with my older WU API
scripts. Install these scripts then place an uppercase N in front
of the calling script names on your web pages. This new version
only supports postal codes and provides a 5 day forecast. Some
things in the old API were removed from the new API such as weather
alerts, UV index,
barometer trend, and weather condition text (Windy, Cloudy, etc.).
With this version alerts for US zip codes have been restored using an
Icons are now hosted locally on your server and I have included many sets.
Two icon sets are derived from the old API styles with one for light and
one for dark backgrounds. The other sets consists of stock
icons offered by IBM as well as variations on them and Weather
Underground inspired designs. Astute users can now easily create their own
icon set. The IBM Cloud servers and the local icons make the new
API run a bit faster. The new API also supports many
languages and postal codes. The full IBM Cloud documentation for it is here:
- The free API key is only available to Weather
Underground active weather station owners/uploaders. Get yours
while they last!
|The script requires PHP >= 5.3 be installed on your server.
It also requires you have a valid
The inline frame below is displaying the output from
the combined conditions and forecast script.
You can also see
this running live
on my weather station
site. Conditions: logo=on, Alerts=off --- Forecast: logo=off,
Please note that you
can display just conditions, just the forecast, or a combination using these
Note: Lately the WU API pws lookup has been
returning bad results. If the demo doesn't return the conditions it is
due to this bad data.
When using this script for your personal
station you can specify your station ID for your zip code and bypass this
Where's the beef? --- How to get the code...
I offer most of the
code on this site free and allow it to be downloaded directly from the site. All I ask for in
return is an unspecified small donation. The problem is, I get lots of
downloads but very few donations. I put a lot of time into
developing this API code so I am using a different method for delivering it to the public. For a
PayPal donation of just $10.00, which is a processing fee, I will email you
the code and documentation as a zip file attachment.
The code for this script can now be freely
If you use this script please do consider a donation.
To download a complete package of files for the New WU API script
DON'T FORGET, YOU ALSO GET...
This cool, API powered weather sticker gadget that uses no Flash or
USE AT YOUR OWN RISK!
Questions / Comments?