逐小时天气预报
逐小时天气预报iOS SDK,提供全球城市未来24-168小时逐小时天气预报,包括:温度、天气状况、风力、风速、风向、相对湿度、大气压强、降水概率、露点温度、云量。
接口代码 | 接口 | 数据类 |
---|---|---|
weather24h | 24小时预报况 | WeatherHourlyResponse |
weather72h | 72小时预报况 | WeatherHourlyResponse |
weather168h | 168小时预报况 | WeatherHourlyResponse |
参数
WeatherParameter
-
location
(必选)需要查询地区的LocationID或以英文逗号分隔的经度,纬度坐标(十进制,最多支持小数点后两位),LocationID可通过GeoAPI获取。例如location=101010100
或location=116.41,39.92
-
lang
多语言设置,请阅读多语言文档,了解我们的多语言是如何工作、如何设置以及数据是否支持多语言。 -
unit
数据单位设置,可选值包括unit=m
(公制单位,默认)和unit=i
(英制单位)。更多选项和说明参考度量衡单位。
示例代码
Swift
Task{
do {
let parameter = WeatherParameter(location: "101010100")
/**
* 获取24小时预报数据
*/
let _ = try await QWeather.instance
.weather24h(parameter)
/**
* 获取72小时预报数据
*/
let _ = try await QWeather.instance
.weather72h(parameter)
/**
* 获取168小时预报数据
*/
let _ = try await QWeather.instance
.weather168h(parameter)
} catch QWeatherError.errorResponse(let error) {
print(error)
} catch {
print(error)
}
}
Objective-C
WeatherParameter * parameter = [WeatherParameter instanceWithLocation:@"101010100" lang:@(LangZH_HANS) unit:@(UnitMETRIC)];
void (^handler)(WeatherHourlyResponse *, NSError *) = ^(WeatherHourlyResponse *response,
NSError *error) {
if (response) {
NSLog(@"%@", response.description);
}
if (error) {
NSLog(@"%@", error.localizedDescription);
}
};
/**
* 获取24小时预报数据
*/
[QWeatherObjc weather24h:parameter completionHandler:handler];
/**
* 获取72小时预报数据
*/
[QWeatherObjc weather72h:parameter completionHandler:handler];
/**
* 获取168小时预报数据
*/
[QWeatherObjc weather168h:parameter completionHandler:handler];
返回数据
WeatherHourlyResponse
-
code
请参考状态码 -
updateTime
当前API的最近更新时间 -
fxLink
当前数据的响应式页面,便于嵌入网站或应用 -
hourly.fxTime
预报时间 -
hourly.temp
温度,默认单位:摄氏度 -
hourly.icon
天气状况的图标代码,另请参考天气图标项目 -
hourly.text
天气状况的文字描述,包括阴晴雨雪等天气状态的描述 -
hourly.wind360
风向360角度 -
hourly.windDir
风向 -
hourly.windScale
风力等级 -
hourly.windSpeed
风速,公里/小时 -
hourly.humidity
相对湿度,百分比数值 -
hourly.precip
当前小时累计降水量,默认单位:毫米 -
hourly.pop
逐小时预报降水概率,百分比数值,可能为空 -
hourly.pressure
大气压强,默认单位:百帕 -
hourly.cloud
云量,百分比数值。可能为空 -
hourly.dew
露点温度。可能为空 -
refer.sources
原始数据来源,或数据源说明,可能为空 -
refer.license
数据许可或版权声明,可能为空