METAR and TAF Webservice

ozedf

I am regularly exploring the Web Service space in the aviation domain looking for new datasets and feeds. I just stumbled upon CheckWX.com collecting weather messages from various sources and redistribute them. Thanks to Henry who is operating the page (it is not run by a company) we have access to big pool of weather messages via an API. The WS use is free, as long you wont hit the service with more than 2000 calls a day.

METAR (Meteorological Terminal Aviation Routine Weather Report) is a weather forecast in a standard message format, usually used by pilots for the pre-flight briefing. The standard defined by ICAO. The data is collected by weather observation stations.
TAF (Terminal aerodrome forecast), similar to METAR focus on aerodromes and provides a forecast for the next ~24 hours, usually every 6 hours.

You find more information in the ICAO reference “Manual of Aeronautical Meteorological Practice” or in the Airforce “Aircrew Quick Reference to the METAR and TAF Codes”.

Lets build a 5min Android app, similar to the BA Webservice client in a previous post. Thanks to the OkHttp library we get data nicely JSON formatted with a few lines of code. We just need to pass the airportcode (ICAO) to get back the current METAR info (plus some extra info about the airport).

private void callWXweatherService(String airportCode) {

	OkHttpClient httpClient = new OkHttpClient();
	String callURL = "https://api.checkwx.com/metar/" + airportCode + "/decoded";

	Request request = new Request.Builder().url(callURL)
			.addHeader("Content-Type", "application/json")
			.addHeader("X-API-KEY", "{your own API key}")
			.build();

	httpClient.newCall(request).enqueue(new Callback() {
		@Override
		public void onFailure(Call call, IOException e) {
			System.out.println("WS Call failed (1):" + e.getMessage());
		}

		@Override
		public void onResponse(Call call, Response response) {
			ResponseBody responseBody = response.body();
			if (!response.isSuccessful()) {
				final String errRep = "WS Call failed (2):" + response.toString();
			} else {
				try {
					System.out.println("Response " + response.toString());
					String str = new String(responseBody.bytes());
					final JSONObject svcresponse = new JSONObject(str);
					int spacesToIndentEachLevel = 2;
					final String prettyPrintString = svcresponse.toString(spacesToIndentEachLevel);

				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}
	});
}

The API documentation: api.checkwx.com

screenshotcheckwx

If I have time I will create a better readable gui and integrate with Google Maps.

Disclaimer: This discussion, datamodel and sourcecode or application is for study purpose solely. It does not reflect or replicate any existing commercial product. It is also not fit for or meant for production.

Please note, weather data from CheckWX is not a substitute for an official weather briefing.