空气质量小时预报
空气质量小时预报API提供未来24小时空气质量的数据,包括AQI、污染物浓度、分指数以及健康建议。
我们推荐阅读空气质量信息文档,以便了解AQI的类型、污染物、支持的国家等信息。
| 接口代码 | 接口 | 数据类 | 
|---|---|---|
| airHourly | 空气质量小时预报 | AirV1HourlyResponse | 
参数
AirV1Parameter
请求参数包括必选和可选参数,如不填写可选参数将使用其默认值。
- 
            
latitude(必选)所需位置的纬度。十进制,最多支持小数点后两位。例如39.92 - 
            
longitude(必选)所需位置的经度。十进制,最多支持小数点后两位。例如116.41 
- 
            
lang多语言设置,请阅读多语言文档,了解我们的多语言是如何工作、如何设置以及数据是否支持多语言。 
示例代码
Swift
Task {
    do {
        let parameter = AirV1Parameter(longitude: 116.41, latitude: 39.92)
        let response = try await QWeather.instance
            .airHourly(parameter)
        print(response)
    } catch QWeatherError.errorResponse(let error) {
        print(error)
    } catch {
        print(error)
    }
}
Objective-C
AirV1Parameter *parameter = [AirV1Parameter instanceWithLongitude:116.41 latitude:39.92 lang:@(LangZH_HANS)];
[QWeatherObjc airHourly:parameter completionHandler:^(AirV1HourlyResponse * _Nullable response, NSError * _Nullable error) {
    if (response) {
        NSLog(@"%@", response.description);
    }
    if (error) {
        NSLog(@"%@", error.localizedDescription);
    }
}];
返回数据
AirV1HourlyResponse
- 
        
metadata.tag数据标签 - 
        
hours.forecastTime预报时间,ISO8601格式 - 
        
hours.indexes.code空气质量指数Code - 
        
hours.indexes.name空气质量指数的名字 - 
        
hours.indexes.aqi空气质量指数的值 - 
        
hours.indexes.aqiDisplay空气质量指数的值的文本显示 - 
        
hours.indexes.level空气质量指数等级,可能为空 - 
        
hours.indexes.category空气质量指数类别,可能为空 - 
        
hours.indexes.color.red空气质量指数的颜色,RGBA中的red - 
        
hours.indexes.color.green空气质量指数的颜色,RGBA中的green - 
        
hours.indexes.color.blue空气质量指数的颜色,RGBA中的blue - 
        
hours.indexes.color.alpha空气质量指数的颜色,RGBA中的alpah - 
        
hours.indexes.primaryPollutant.code首要污染物的Code,可能为空 - 
        
hours.indexes.primaryPollutant.name首要污染物的名字,可能为空 - 
        
hours.indexes.primaryPollutant.fullName首要污染物的全称,可能为空 - 
        
hours.indexes.health.effect空气质量对健康的影响,可能为空 - 
        
hours.indexes.health.advice.generalPopulation对一般人群的健康指导意见,可能为空 - 
        
hours.indexes.health.advice.sensitivePopulation对敏感人群的健康指导意见,可能为空 - 
        
hours.pollutants.code污染物的Code - 
        
hours.pollutants.name污染物的名字 - 
        
hours.pollutants.fullName污染物的全称 - 
        
hours.pollutants.concentration.value污染物的浓度值 - 
        
hours.pollutants.concentration.unit污染物的浓度值的单位 - 
        
hours.pollutants.subIndexes.code污染物的分指数的Code,可能为空 - 
        
hours.pollutants.subIndexes.aqi污染物的分指数的数值,可能为空 - 
        
hours.pollutants.subIndexes.aqiDisplay污染物的分指数数值的显示名称