Weather is an important part of any flight operation. The Weather API is a straightforward way to check the weather before and during a flight. Weather forecasts are available up to seven days in advance by including the desired dates in the request.

The Weather API takes a single Point and returns the weather conditions at the requested time. As an example, let's check the current weather around Los Angeles:

curl "https://api.airmap.com/advisory/v1/weather?latitude=33.92&longitude=-118.45" \
     -H "X-API-Key: <API_KEY>"
     
 This generates the response:
 
 {
  "status": "success",
  "data": {
    "attribution": "Powered by Dark Sky",
    "attribution_uri": "https://darksky.net/poweredby/",
    "weather": [
      {
        "condition": "Mostly Cloudy",
        "icon": "partly-cloudy-day",
        "wind": {
          "heading": 172,
          "speed": 1.78
        },
        "humidity": 0.72,
        "visibility": 15.53,
        "precipitation": 0,
        "temperature": 22.04,
        "timezone": "America/Los_Angeles",
        "time": "2017-09-19T19:00:00.000Z",
        "dew_point": 16.67,
        "mslp": 1013.41
      }
    ]
  }
}
let start = Date()
let end = start.addingTimeInterval(60*60)

AirMap.getWeatherForecast(at: coordinate, from: start, to: end) { result in
    
    switch result {
    
    case .error(let error):
        print(error)

    case .value(let weather):
        for observation in weather.observations {
            print(observation.time)
            print(observation.temperature)
            print(observation.condition)
        }
    }
}
Coordinate coordinate = ...
Date startTime = new Date();
Date endTime = new Date(startTime.getTime() + (4 * 60 * 60 * 1000));

AirMap.getWeather(coordinate, startTime, endTime, new AirMapCallback<AirMapWeather>() {
    @Override
    protected void onSuccess(AirMapWeather weather) {
        AirMapLog.d(TAG, "Weather: " + weather.getUpdates());
    }

    @Override
    protected void onError(AirMapException e) {
        // Handle error
    }
});

Simple, right?

๐Ÿšง

Tip

Information from the Weather API response is not currently utilized by other APIs within AirMap's Contextual Airspace model. However, you may still choose to make use of the data in creative ways in your application, such as providing a default value for visibility when that particular Flight Feature is required as input from the pilot during Flight Planning.

Updated 4 years ago


What's Next

Learn how to create a Flight

Overview

Weather


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.