监测站数据(new)
监测站数据API提供各个国家或地区监测站的污染物浓度值。
警告:监测站的观测值仅供参考,可能由于故障、移除、维护或当地法律法规等各种原因导致数据延迟或缺失,我们无法确保该数据的可用性。
接口代码 | 接口 | 数据类型 |
---|---|---|
airStation | 监测站数据(new) | AirV1StationResponse |
参数
AirV1StationParameter
请求参数包括必选和可选参数,如不填写可选参数将使用其默认值。
-
LocationID
(必选)空气质量监测站的LocationID,LocationID可通过GeoAPI获取。例如P58911
-
lang
多语言设置,请阅读多语言文档,了解我们的多语言是如何工作、如何设置以及数据是否支持多语言。
代码示例
Swift
Task{
do {
let parameter = AirV1StationParameter(locationID: "P58911")
let response = try await QWeather.instance
.airStation(parameter)
print(response)
} catch QWeatherError.errorResponse(let error) {
print(error)
} catch {
print(error)
}
}
Objective-C
AirV1StationParameter * parameter = [AirV1StationParameter instanceWithLocationID:@"P58911" lang:@(LangZH_HANS)];
[QWeatherObjc airStation:parameter completionHandler:^(AirV1StationResponse * _Nullable response, NSError * _Nullable error) {
if (response) {
NSLog(@"%@", response.description);
}
if (error) {
NSLog(@"%@", error.localizedDescription);
}
}];
返回数据
AirV1StationResponse
-
metadata.tag
数据标签 -
metadata.sources
数据来源或提供商名字以及他们的声明,开发者必须将此内容与当前数据一起展示,可能为空 -
pollutants.code
污染物的Code -
pollutants.name
污染物的名字 -
pollutants.fullName
污染物的全称 -
pollutants.concentration.value
污染物的浓度值 -
pollutants.concentration.unit
污染物的浓度值的单位