Weather Alert

Platform: API iOS Android

Get officially issued real-time severe weather alert data around the world.

Hint: For the implementation of weather alert, see Resource - Alert Info in advance.

Interface code Interface Class
weatherAlertCurrent Weather Alert WeatherAlertCurrentResponse

Parameters

WeatherAlertCurrentParameter

Name Type Required Example
longitude Double true 116.41
latitude Double true 39.92
localTime Bool true true
lang Lang false ZH_HANS

Sample code

Swift

Task {
    do {
        let parameter = WeatherAlertCurrentParameter(longitude: 113.26, 
                                                      latitude: 38.73, 
                                                     localTime: false, 
                                                          lang: .ZH_HANS)
        let response = try await Q.weatherAlertCurrent(parameter)
        print(response)
    } catch QWeatherError.errorResponse(let error) {
        print(error)
    } catch {
        print(error)
    }
}

Objective-C

WeatherAlertCurrentParameter *parameter = [WeatherAlertCurrentParameter instanceWithLongitude: 113.26 
                                                                                     latitude: 38.73 
                                                                                    localTime: NO 
                                                                                         lang: @(LangZH_HANS)];
[QWeatherObjc weatherAlertCurrent:parameter completionHandler:^(WeatherAlertCurrentResponse * _Nullable response, NSError * _Nullable error) {
    if (response) {
        NSLog(@"%@", response.description);
    }
    if (error) {
        NSLog(@"%@", error.localizedDescription);
    }
}];

Response

WeatherAlertCurrentResponse

  • metadata.tag Unique tag for this data
  • metadata.zeroResult true indicates the request is successful but no data is available, e.g. no alert data for the queried location.
  • metadata.attributions Attributions for data sources or declarations, developers must display this information with data
  • alerts.id The ID of this alert message
  • alerts.senderName The name of the agency or authority issuing this alert, may be null
  • alerts.issuedTime The time when the original alert message was generated. The actual release or receipt time may be slightly delayed.
  • alerts.messageType.code The code of the alert message nature
  • alerts.messageType.supersedes Alert IDs that are superseded by this message, only relevant when messageType.code is update or cancel.
  • alerts.eventType.name Name of the alert event type
  • alerts.eventType.code Code of the alert event type
  • alerts.urgency The urgency of the alert message, may be null
  • alerts.severity The severity of the alert message
  • alerts.certainty The certainty of the alert message, may be null
  • alerts.icon Icon code for this alert
  • alerts.color.code Color code for this alert
  • alerts.color.red Red component in RGBA for this alert, range 0–255
  • alerts.color.green Green component in RGBA for this alert, range 0–255
  • alerts.color.blue Blue component in RGBA for this alert, range 0–255
  • alerts.color.alpha Alpha (opacity) in RGBA for this alert, range 0-1
  • alerts.effectiveTime The effective time of the alert message, may be null
  • alerts.onsetTime The expected time of the beginning of this alert event, may be null
  • alerts.expiredTime The expiry time of the alert message
  • alerts.headline Headline or brief of the alert message
  • alerts.description Description of the alert message
  • alerts.criteria The criteria or condition for triggering this alert. This is for reference only and may out of date with official standard. May be null
  • alerts.instruction The recommended action for this alert, may be null
  • alerts.responseTypes Type code of recommended action for this alert, may be null