格点实时天气

平台: API iOS Android

基于全球任意坐标的高精度实时天气,精确到3-5公里范围,包括:温度、湿度、大气压、天气状况、风力、风向等。

接口代码 接口 数据类
gridNow 格点实时天气 GridNowResponse

参数

GridWeatherParameter

参数名 参数类型 必选 示例值
longitude Double 116.41
latitude Double 39.92
lang Lang ZH_HANS
unit Unit METRIC

代码示例

Swift

Task{
    do {
        let parameter = GridWeatherParameter(longitude: 116.41, latitude: 39.92)
        let response = try await QWeather.instance
            .gridNow(parameter)
        print(response)
    } catch QWeatherError.errorResponse(let error) {
        print(error)
    } catch {
        print(error)
    }
}

Objective-C

GridWeatherParameter *parameter = [GridWeatherParameter instanceWithLongitude:116.41 latitude:39.92 lang:@(LangZH_HANS) unit:@(UnitMETRIC)];
[QWeatherObjc gridNow:parameter completionHandler:^(GridNowResponse * _Nullable response, NSError * _Nullable error) {
    if (response) {
        NSLog(@"%@", response.description);
    }
    if (error) {
        NSLog(@"%@", error.localizedDescription);
    }
}];

返回数据

GridNowResponse

  • code 请参考状态码
  • updateTime 当前API的最近更新时间
  • fxLink 当前数据的响应式页面,便于嵌入网站或应用
  • now.obsTime 数据观测时间
  • now.temp 温度,默认单位:摄氏度
  • now.icon 天气状况的图标代码,另请参考天气图标项目
  • now.text 天气状况的文字描述,包括阴晴雨雪等天气状态的描述
  • now.wind360 风向360角度
  • now.windDir 风向
  • now.windScale 风力等级
  • now.windSpeed 风速,公里/小时
  • now.humidity 相对湿度,百分比数值
  • now.precip 过去1小时降水量,默认单位:毫米
  • now.pressure 大气压强,默认单位:百帕
  • now.cloud 云量,百分比数值。可能为空
  • now.dew 露点温度。可能为空
  • refer.sources 原始数据来源,或数据源说明,可能为空
  • refer.license 数据许可或版权声明,可能为空