Weather Alert
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.tagUnique tag for this data -
metadata.zeroResulttrueindicates the request is successful but no data is available, e.g. no alert data for the queried location. -
metadata.attributionsAttributions for data sources or declarations, developers must display this information with data -
alerts.idThe ID of this alert message -
alerts.senderNameThe name of the agency or authority issuing this alert, may be null -
alerts.issuedTimeThe time when the original alert message was generated. The actual release or receipt time may be slightly delayed. -
alerts.messageType.codeThe code of the alert message nature -
alerts.messageType.supersedesAlert IDs that are superseded by this message, only relevant whenmessageType.codeis update or cancel. -
alerts.eventType.nameName of the alert event type -
alerts.eventType.codeCode of the alert event type -
alerts.urgencyThe urgency of the alert message, may be null -
alerts.severityThe severity of the alert message -
alerts.certaintyThe certainty of the alert message, may be null -
alerts.iconIcon code for this alert -
alerts.color.codeColor code for this alert -
alerts.color.redRed component in RGBA for this alert, range 0–255 -
alerts.color.greenGreen component in RGBA for this alert, range 0–255 -
alerts.color.blueBlue component in RGBA for this alert, range 0–255 -
alerts.color.alphaAlpha (opacity) in RGBA for this alert, range 0-1 -
alerts.effectiveTimeThe effective time of the alert message, may be null -
alerts.onsetTimeThe expected time of the beginning of this alert event, may be null -
alerts.expiredTimeThe expiry time of the alert message -
alerts.headlineHeadline or brief of the alert message -
alerts.descriptionDescription of the alert message -
alerts.criteriaThe criteria or condition for triggering this alert. This is for reference only and may out of date with official standard. May be null -
alerts.instructionThe recommended action for this alert, may be null -
alerts.responseTypesType code of recommended action for this alert, may be null