Saturday, January 9, 2010

Java Weather API

Knowing what is happening with the weather is always a piece of useful information worth having. After Googling around I wasn't able to find an actually Java API for the weather and I could see many others were just looking for a simple Java API to plug into their system. So I started the development with a friend, Luke Morgan, and we are at the stages where the API has reached a mature level and is something we will release shortly, most likely as part of a Google Code project. The API is extremely easy to use (as it should be!) and here is an example of how it would be utilised:
Weather weather;
try
{
Weather weather = WeatherStation.getWeather("wirral");
}
catch(WeatherStationException wse)
{}

weather.getConditions(); //Returns a string, such as "Fog", "Partly Cloudy"
weather.getTemperature(); //returned in degree celsius


So as you can see, incorporating this API into any application is trivial. The API also supports the forecast for weather. So, for example, it could be successfully utilised as:

Forecast forecast;
try
{
forecast = WeatherStation.getForecast("wirral");
}
catch(WeatherStationException wse
{}

for(Weather weather: forecast.getForecast()) //returns a list of Weather (4 days)
{
System.out.println(weather.getDate() + " is forecast for " + weather.getConditions());
}
}


This is something I have personally utilised as part of Jarvis - the virtual assistant. By utilising this API in my system I receive weather updates automatically each morning, giving me the current condition and forecast data then receiving another update at night giving me tomorrows forecast. The updates are mostly delivered using my T-Mobile API. It is further utilised by the fact that Jarvis has access to my Google Calendar, so for each event Jarvis also delivers the weather conditions.

In the meantime if you would like access to this code please feel free to contact me.

5 comments:

preet said...

Hi
java weather Api will play important role for future software development.I am a computer engineering student , i am working on college project, in that i want forecasted wind data. Can u help me on this.

regards
preet

Unknown said...

I would love a copy of the API please!

Unknown said...

Where is the API source code or jar? :)

churi said...

I would to get a copy of jar lib for java weather api

Yossi said...

I would like to have the API to use in a demo I am making.