December 3

Aeris API + HW3 = Better Weather for Your Site

The following article was contributed by Joe Torsitano from

Anyone who has used the HAMweather scripts on their website for more than a few months knows much of its power lies in its flexibility. The introduction of the Aeris Weather API means almost any existing HW3 installation can display the data which has always been included with higher speed and availability. It also allows other weather related information to be added. And it can be done with some easy changes to the templates provided with HW3 or that have already been customized.

HW2 and HW3 have been key components in (WFY) since 1999. While Aeris could have been a replacement for our HW system, I found it was very simple to modify existing templates so the API could provide all the improved benefits of Aeris while significantly reducing development time.

There are many benefits to Aeris data compared to other sources which have been traditionally used by HW3. Aeris utilizes the latest cloud-based services and content delivery networks which is very fast and reliable. It’s able to quickly respond to rapidly changing demands and loads when you really need weather data such as during significant weather events. The API enables the retrieval of a wide range of weather data and related information using JavaScript Object Notation, or JSON. If you’re interested in knowing more about JSON visit For t.his tutorial it’ll suffice to say it makes it really easy to read and write data.

In order to access the API an account is needed. Account types are based on how many times and what data is going to be retrieved. A free Developer account allows up to 750 requests per day to the types of information a standard HW3 installation uses plus more. You can sign up for a Developer account and transition can occur without the worry of charges piling up during the development time and a small non-commercial HW3 site can have the Aeris advantage at no cost. All that is necessary is giving credit to HAMweather on any page that uses the Aeris data in accordance with the credit policy at

Once you have your account, login at after which you’ll need to register your website at the Aeris API – Application/Website Registration link from your account. This will issue you a unique identifier for your account and key for each application, which is used to access the API.

Now that you have a login, ID and secret you can begin having your HW3 installation make Aeris requests. The key here is HW3’s ability to include regular php code. To include something like:

you would put this into an HW3 template:

If you need multiple lines to insert your php code you use double underlines after each line, like:

There must not be any blank lines otherwise the inserted code will not work.

So are you ready for Aeris API to appear in your HW3 installation? I’m going to start with a simple replacement for the current conditions. Now I’m sure most have customized their installations to better match their site’s look and feel (and their own personal preferences) so the examples given are based on the templates that come with HW3. But it should give you a good starting place.
First step backup your templates! This is especially important if you’re using a live site. But even if you have the bonus of developing on an internal, non-public system it’s always good to have where you started from to come back to. So if you haven’t backed up your templates, do it now! You will be glad you did.

Sets of data from the API are called endpoints. In this case we’ll be using the observations endpoint. Within the endpoints are the individual pieces of data like temperature, humidity, etc., which are called query elements.
To start with we need to show when the observations were made. This is in the templates/zandh.html template. In the template find the item:

Replace it with this, filling in your CLIENT_ID and CLIENT_SECRET where indicated:

Now upload the modified zandh.html to your server. Next you’ll be modifying the templates/include/current.html file. You’ll be replacing a lot more code here. In the default templates you’ll be replacing lines 14 through 53 (starting right under the first statement and going until the line right above the next to the last statement). Replace all that with the following, filling in your CLIENT_ID and CLIENT_SECRET where indicated:

Once you upload the modified current.html to your server, give it a test. Get a forecast for your town. The current conditions you see will be coming from the Aeris API!

In this example we just dropped Aeris API replacements into the default templates. This created two requests to the API, one for the time and one for the actual conditions. Since access to the API is metered you will probably want to modify your templates to gather all the information from one request to maximize the number of reports you can get.

In my next installment I’ll give you the sun and the moon, Aeris API style.

Share this post:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.