Air Quality Hourly Forecast
The air quality hourly forecast API provides air quality forecast data for each hour of the next 24 hours, including AQI, pollutants concentration, sub-indexes, health effects and advice.
We recommend to read Air Quality Info to learn about the AQIs, pollutants, supported regions and more.
| Interface code | Interface | Class |
|---|---|---|
| airHourly | Air quality hourly forecast | AirV1HourlyResponse |
Parameters
AirV1Parameter
-
latitude(required)The latitude of the desired location. Decimal format, up to 2 decimal places. For example39.92 -
longitude(required)The longitude of the desired location. Decimal format, up to 2 decimal places. For example116.41
-
langMulti-language setting, please see Language to find out how our multi-language works and how to set up.
Sample code
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);
}
}];
Response
AirV1HourlyResponse
-
metadata.tagUnique tag for this data -
hours.forecastTimeForecast time, ISO8601 format -
hours.indexes.codeCode of air quality index -
hours.indexes.nameName of air quality index -
hours.indexes.aqiValue of air quality index -
hours.indexes.aqiDisplayDisplay name of the AQI value -
hours.indexes.levelLevel of air quality index -
hours.indexes.categoryCategory of air quality index -
hours.indexes.color.redRed in RGBA color for AQI -
hours.indexes.color.greenGreen in RGBA color for AQI -
hours.indexes.color.blueBlue in RGBA color for AQI -
hours.indexes.color.alphaAlpha in RGBA color for AQI -
hours.indexes.primaryPollutant.codeThe primary pollutant code, maybe NULL. -
hours.indexes.primaryPollutant.nameName of primary pollutant, maybe NULL. -
hours.indexes.primaryPollutant.fullNameFull name of primary pollutant, maybe NULL. -
hours.indexes.health.effectHealth effects of air quality, maybe NULL. -
hours.indexes.health.advice.generalPopulationHealth advice for general population, maybe NULL. -
hours.indexes.health.advice.sensitivePopulationHealth advice for sensitive population, maybe NULL. -
hours.pollutants.codeThe pollutant code. -
hours.pollutants.nameName of pollutant. -
hours.pollutants.fullNameFull name of pollutant. -
hours.pollutants.concentration.valueConcentration values of pollutants. -
hours.pollutants.concentration.unitUnits for concentration values of pollutants. -
hours.pollutants.subIndexes.codeCode of air quality sub-index, maybe NULL. -
hours.pollutants.subIndexes.aqiSub-index value for pollutant, maybe NULL. -
hours.pollutants.subIndexes.aqiDisplaySub-index for display, maybe NULL.