天气预报和实况

城市级天气预报API,包括全球15万个城市或地区的1-15天天气预报、实况天气、逐小时天气预报以及日出日落、月升月落等数据。

请求URL

实况天气 HTTP GET

  • 商业版 https://api.heweather.net/v7/weather/now?{请求参数}
  • 开发版 https://devapi.heweather.net/v7/weather/now?{请求参数}

3天预报 HTTP GET

  • 商业版 https://api.heweather.net/v7/weather/3d?{请求参数}
  • 开发版 https://devapi.heweather.net/v7/weather/3d?{请求参数}

7天预报 HTTP GET

  • 商业版 https://api.heweather.net/v7/weather/7d?{请求参数}
  • 开发版 https://devapi.heweather.net/v7/weather/7d?{请求参数}

10天预报 HTTP GET

  • 商业版 https://api.heweather.net/v7/weather/10d?{请求参数}

15天预报 HTTP GET

  • 商业版 https://api.heweather.net/v7/weather/15d?{请求参数}

逐小时预报(未来24小时) HTTP GET

  • 商业版 https://api.heweather.net/v7/weather/24h?{请求参数}
  • 开发版 https://devapi.heweather.net/v7/weather/24h?{请求参数}

逐小时预报(未来72小时) HTTP GET

  • 商业版 https://api.heweather.net/v7/weather/72h?{请求参数}

逐小时预报(未来168小时) HTTP GET

  • 商业版 https://api.heweather.net/v7/weather/168h?{请求参数}

请求参数

请求参数包括必选和可选参数,如不填写可选参数将使用其默认值,参数之间使用&进行分隔。

location 必选

需要查询地区的LocationID或以逗号分隔的经度/纬度坐标(十进制),LocationID可通过城市搜索服务获取。例如: location=101010100location=116.41,39.92

key 必选

用户认证密钥,请参考如何获取你的KEY。支持数字签名方式认证。例如:key=12334567890ABC

gzip 可选

对接口进行压缩,可大幅节省网络消耗、减少接口获取延迟。默认开启gzip

  • y 使用gzip方式压缩,默认
  • n 不使用压缩

lang 可选

多语言设置,支持31种语言,默认中文。具体的语言参数值请参考多语言参数值

unit 可选

度量衡单位参数选择,例如温度选摄氏度或华氏度、公里或英里。默认公制单位

  • m 公制单位,默认
  • i 英制单位

返回数据

参数 描述 示例值
code API状态码,具体含义请参考状态码 200
updateTime 当前API的最近更新时间 2013-12-30T01:45+08:00
fxLink 该城市的天气预报和实况自适应网页,可嵌入网站或应用 http://hfx.link/ae45
now.obsTime 实况观测时间 2013-12-30T01:45+08:00
now.temp 实况温度,默认单位:摄氏度 21
now.feelsLike 实况体感温度,默认单位:摄氏度 23
now.icon 当前天气状况和图标的代码,图标可通过天气状况和图标下载 100
now.text 实况天气状况的文字描述,包括阴晴雨雪等天气状态的描述
now.wind360 实况风向360角度 305
now.windDir 实况风向 西北
now.windScale 实况风力等级 3
now.windSpeed 实况风速,公里/小时 15
now.humidity 实况相对湿度,百分比数值 40
now.precip 实况降水量,默认单位:毫米 1.2
now.pressure 实况大气压强,默认单位:百帕 1020
now.vis 实况能见度,默认单位:公里 10
now.cloud 实况云量,百分比数值 23
now.dew 实况露点温度 12
daily.fxDate 预报日期 2013-05-31
daily.sunrise 日出时间 07:34
daily.sunset 日落时间 17:21
daily.moonrise 月升时间 16:09
daily.moonset 月落时间 04:21
daily.moonPhase 月相名称 满月
daily.tempMax 预报当天最高温度 4
daily.tempMin 预报当天最低温度 -5
daily.iconDay 预报白天天气状况的图标代码,图标可通过天气状况和图标下载 100
daily.textDay 预报白天天气状况文字描述,包括阴晴雨雪等天气状态的描述
daily.iconNight 预报夜间天气状况的图标代码,图标可通过天气状况和图标下载 100
daily.textNight 预报晚间天气状况文字描述,包括阴晴雨雪等天气状态的描述
daily.wind360Day 预报白天风向360角度 305
daily.windDirDay 预报白天风向 西北
daily.windScaleDay 预报白天风力等级 3-4
daily.windSpeedDay 预报白天风速,公里/小时 15
daily.wind360Night 预报夜间风向360角度 305
daily.WindDirNight 预报夜间当天风向 西北
daily.windScaleNight 预报夜间风力等级 3-4
daily.windSpeedNight 预报夜间风速,公里/小时 15
daily.humidity 预报当天相对湿度,百分比数值 40
daily.precip 预报当天降水量,默认单位:毫米 1.2
daily.pressure 预报当天大气压强,默认单位:百帕 1020
daily.vis 预报当天能见度,默认单位:公里 10
daily.cloud 预报当天云量,百分比数值 23
daily.uvIndex 预报当天紫外线强度指数 3
hourly.fxTime 逐小时预报时间 2013-12-30T13:00+08:00
hourly.temp 逐小时预报温度 2
hourly.icon 逐小时预报天气状况图标代码,图标可通过天气状况和图标下载 101
hourly.text 逐小时预报天气状况文字描述,包括阴晴雨雪等天气状态的描述 多云
hourly.wind360 逐小时预报风向360角度 305
hourly.windDir 逐小时预报风向 西北
hourly.windScale 逐小时预报风力等级 3
hourly.windSpeed 逐小时预报风速,公里/小时 15
hourly.humidity 逐小时预报相对湿度,百分比数值 40
hourly.precip 逐小时预报降水量,默认单位:毫米 1.2
hourly.pop 逐小时预报降水概率,百分比数值,可能为空 5
hourly.pressure 逐小时预报大气压强,默认单位:百帕 1020
hourly.cloud 逐小时预报云量,百分比数值 23
hourly.dew 逐小时预报露点温度 12
refer.sources 原始数据来源,可能为空  
refer.license 数据许可证  

请求和返回示例

实况天气

// 北京实况天气 
// 商业版 https://api.heweather.net/v7/weather/now?location=101010100&key=xxx
// 开发版 https://devapi.heweather.net/v7/weather/now?location=101010100&key=xxx
// 请将示例请求URL中的KEY更换成你自己的KEY

{
  "code": "200",
  "updateTime": "2020-06-30T22:00+08:00",
  "fxLink": "http://hfx.link/2ax1",
  "now": {
    "obsTime": "2020-06-30T21:40+08:00",
    "temp": "24",
    "feelsLike": "26",
    "icon": "101",
    "text": "多云",
    "wind360": "123",
    "windDir": "东南风",
    "windScale": "1",
    "windSpeed": "3",
    "humidity": "72",
    "precip": "0.0",
    "pressure": "1003",
    "vis": "16",
    "cloud": "10",
    "dew": "21"
  },
  "refer": {
    "sources": [
      "Weather China"
    ],
    "license": [
      "commercial license"
    ]
  }
}

3天预报

// 北京3天预报 
// 商业版 https://api.heweather.net/v7/weather/3d?location=101010100&key=xxx
// 开发版 https://devapi.heweather.net/v7/weather/3d?location=101010100&key=xxx
// 请将示例请求URL中的KEY更换成你自己的KEY

{
  "code": "200",
  "updateTime": "2020-06-14T16:57+08:00",
  "fxLink": "https://www.heweather.com/weather/beijing-101010100.html",
  "daily": [
    {
      "fxDate": "2020-06-14",
      "sunrise": "04:45",
      "sunset": "19:44",
      "moonrise": "01:05",
      "moonset": "12:53",
      "tempMax": "35",
      "tempMin": "22",
      "iconDay": "100",
      "textDay": "晴",
      "iconNight": "150",
      "textNight": "晴",
      "wind360Day": "358",
      "windDirDay": "北风",
      "windScaleDay": "1-2",
      "windSpeedDay": "8",
      "wind360Night": "234",
      "windDirNight": "西南风",
      "windScaleNight": "1-2",
      "windSpeedNight": "6",
      "humidity": "22",
      "precip": "0.0",
      "pressure": "1001",
      "vis": "25",
      "uvIndex": "11"
    },
    {
      "fxDate": "2020-06-15",
      "sunrise": "04:45",
      "sunset": "19:45",
      "moonrise": "01:29",
      "moonset": "13:51",
      "tempMax": "36",
      "tempMin": "22",
      "iconDay": "100",
      "textDay": "晴",
      "iconNight": "150",
      "textNight": "晴",
      "wind360Day": "6",
      "windDirDay": "北风",
      "windScaleDay": "1-2",
      "windSpeedDay": "2",
      "wind360Night": "220",
      "windDirNight": "西南风",
      "windScaleNight": "1-2",
      "windSpeedNight": "5",
      "humidity": "30",
      "precip": "0.0",
      "pressure": "999",
      "vis": "25",
      "uvIndex": "11"
    },
    {
      "fxDate": "2020-06-16",
      "sunrise": "04:45",
      "sunset": "19:45",
      "moonrise": "01:52",
      "moonset": "14:49",
      "tempMax": "35",
      "tempMin": "24",
      "iconDay": "100",
      "textDay": "晴",
      "iconNight": "150",
      "textNight": "晴",
      "wind360Day": "235",
      "windDirDay": "西南风",
      "windScaleDay": "3-4",
      "windSpeedDay": "18",
      "wind360Night": "206",
      "windDirNight": "西南风",
      "windScaleNight": "1-2",
      "windSpeedNight": "5",
      "humidity": "30",
      "precip": "0.0",
      "pressure": "994",
      "vis": "25",
      "uvIndex": "11"
    }
  ],
  "refer": {
    "sources": [
      "Weather China"
    ],
    "license": [
      "commercial license"
    ]
  }
}

逐小时预报(未来24小时)

// 北京未来24小时逐小时天气 
// 商业版 https://api.heweather.net/v7/weather/24d?location=101010100&key=xxx
// 开发版 https://devapi.heweather.net/v7/weather/24d?location=101010100&key=xxx
// 请将示例请求URL中的KEY更换成你自己的KEY

{
  "code": "200",
  "updateTime": "2020-06-14T17:09+08:00",
  "fxLink": "https://www.heweather.com/weather/beijing-101010100.html",
  "hourly": [
    {
      "fxDate": "2020-06-14T18:00+08:00",
      "temp": "34",
      "icon": "150",
      "text": "晴",
      "wind360": "101",
      "windDir": "东南风",
      "windScale": "3-4",
      "windSpeed": "14",
      "humidity": "19",
      "pop": "0",
      "precip": "0.0",
      "pressure": "1001",
      "cloud": "6",
      "dew": "3",
      "snow": "0.0",
      "ice": "0.0"
    },
    {
      "fxDate": "2020-06-14T19:00+08:00",
      "temp": "33",
      "icon": "150",
      "text": "晴",
      "wind360": "153",
      "windDir": "东南风",
      "windScale": "1-2",
      "windSpeed": "1",
      "humidity": "22",
      "pop": "0",
      "precip": "0.0",
      "pressure": "1001",
      "cloud": "3",
      "dew": "4",
      "snow": "0.0",
      "ice": "0.0"
    },
    {
      "fxDate": "2020-06-14T20:00+08:00",
      "temp": "30",
      "icon": "150",
      "text": "晴",
      "wind360": "355",
      "windDir": "北风",
      "windScale": "1-2",
      "windSpeed": "6",
      "humidity": "24",
      "pop": "0",
      "precip": "0.0",
      "pressure": "1001",
      "cloud": "0",
      "dew": "5",
      "snow": "0.0",
      "ice": "0.0"
    },
    {
      "fxDate": "2020-06-14T21:00+08:00",
      "temp": "29",
      "icon": "150",
      "text": "晴",
      "wind360": "173",
      "windDir": "南风",
      "windScale": "3-4",
      "windSpeed": "21",
      "humidity": "28",
      "pop": "0",
      "precip": "0.0",
      "pressure": "1002",
      "cloud": "0",
      "dew": "5",
      "snow": "0.0",
      "ice": "0.0"
    },
    {
      "fxDate": "2020-06-14T22:00+08:00",
      "temp": "27",
      "icon": "150",
      "text": "晴",
      "wind360": "214",
      "windDir": "西南风",
      "windScale": "1-2",
      "windSpeed": "10",
      "humidity": "32",
      "pop": "0",
      "precip": "0.0",
      "pressure": "1002",
      "cloud": "0",
      "dew": "5",
      "snow": "0.0",
      "ice": "0.0"
    },
    {
      "fxDate": "2020-06-14T23:00+08:00",
      "temp": "26",
      "icon": "150",
      "text": "晴",
      "wind360": "245",
      "windDir": "西南风",
      "windScale": "1-2",
      "windSpeed": "9",
      "humidity": "37",
      "pop": "0",
      "precip": "0.0",
      "pressure": "1002",
      "cloud": "0",
      "dew": "4",
      "snow": "0.0",
      "ice": "0.0"
    },
    {
      "fxDate": "2020-06-15T00:00+08:00",
      "temp": "25",
      "icon": "150",
      "text": "晴",
      "wind360": "274",
      "windDir": "西风",
      "windScale": "1-2",
      "windSpeed": "1",
      "humidity": "37",
      "pop": "0",
      "precip": "0.0",
      "pressure": "1002",
      "cloud": "5",
      "dew": "5",
      "snow": "0.0",
      "ice": "0.0"
    },
    {
      "fxDate": "2020-06-15T01:00+08:00",
      "temp": "24",
      "icon": "150",
      "text": "晴",
      "wind360": "279",
      "windDir": "西风",
      "windScale": "1-2",
      "windSpeed": "3",
      "humidity": "38",
      "pop": "0",
      "precip": "0.0",
      "pressure": "1002",
      "cloud": "9",
      "dew": "5",
      "snow": "0.0",
      "ice": "0.0"
    },
    {
      "fxDate": "2020-06-15T02:00+08:00",
      "temp": "23",
      "icon": "150",
      "text": "晴",
      "wind360": "242",
      "windDir": "西南风",
      "windScale": "1-2",
      "windSpeed": "9",
      "humidity": "39",
      "pop": "0",
      "precip": "0.0",
      "pressure": "1002",
      "cloud": "14",
      "dew": "5",
      "snow": "0.0",
      "ice": "0.0"
    },
    {
      "fxDate": "2020-06-15T03:00+08:00",
      "temp": "22",
      "icon": "150",
      "text": "晴",
      "wind360": "266",
      "windDir": "西风",
      "windScale": "1-2",
      "windSpeed": "10",
      "humidity": "41",
      "pop": "0",
      "precip": "0.0",
      "pressure": "1001",
      "cloud": "9",
      "dew": "6",
      "snow": "0.0",
      "ice": "0.0"
    },
    {
      "fxDate": "2020-06-15T04:00+08:00",
      "temp": "22",
      "icon": "150",
      "text": "晴",
      "wind360": "276",
      "windDir": "西风",
      "windScale": "1-2",
      "windSpeed": "9",
      "humidity": "43",
      "pop": "0",
      "precip": "0.0",
      "pressure": "1000",
      "cloud": "5",
      "dew": "6",
      "snow": "0.0",
      "ice": "0.0"
    },
    {
      "fxDate": "2020-06-15T05:00+08:00",
      "temp": "22",
      "icon": "150",
      "text": "晴",
      "wind360": "207",
      "windDir": "西南风",
      "windScale": "1-2",
      "windSpeed": "6",
      "humidity": "46",
      "pop": "0",
      "precip": "0.0",
      "pressure": "999",
      "cloud": "0",
      "dew": "5",
      "snow": "0.0",
      "ice": "0.0"
    },
    {
      "fxDate": "2020-06-15T06:00+08:00",
      "temp": "25",
      "icon": "150",
      "text": "晴",
      "wind360": "266",
      "windDir": "西风",
      "windScale": "1-2",
      "windSpeed": "3",
      "humidity": "42",
      "pop": "0",
      "precip": "0.0",
      "pressure": "998",
      "cloud": "13",
      "dew": "7",
      "snow": "0.0",
      "ice": "0.0"
    },
    {
      "fxDate": "2020-06-15T07:00+08:00",
      "temp": "26",
      "icon": "150",
      "text": "晴",
      "wind360": "154",
      "windDir": "东南风",
      "windScale": "1-2",
      "windSpeed": "6",
      "humidity": "38",
      "pop": "0",
      "precip": "0.0",
      "pressure": "998",
      "cloud": "25",
      "dew": "7",
      "snow": "0.0",
      "ice": "0.0"
    },
    {
      "fxDate": "2020-06-15T08:00+08:00",
      "temp": "27",
      "icon": "150",
      "text": "晴",
      "wind360": "238",
      "windDir": "西南风",
      "windScale": "1-2",
      "windSpeed": "1",
      "humidity": "34",
      "pop": "0",
      "precip": "0.0",
      "pressure": "997",
      "cloud": "38",
      "dew": "6",
      "snow": "0.0",
      "ice": "0.0"
    },
    {
      "fxDate": "2020-06-15T09:00+08:00",
      "temp": "29",
      "icon": "150",
      "text": "晴",
      "wind360": "136",
      "windDir": "东南风",
      "windScale": "1-2",
      "windSpeed": "8",
      "humidity": "31",
      "pop": "0",
      "precip": "0.0",
      "pressure": "997",
      "cloud": "55",
      "dew": "5",
      "snow": "0.0",
      "ice": "0.0"
    },
    {
      "fxDate": "2020-06-15T10:00+08:00",
      "temp": "31",
      "icon": "150",
      "text": "晴",
      "wind360": "118",
      "windDir": "东南风",
      "windScale": "1-2",
      "windSpeed": "5",
      "humidity": "29",
      "pop": "0",
      "precip": "0.0",
      "pressure": "997",
      "cloud": "72",
      "dew": "3",
      "snow": "0.0",
      "ice": "0.0"
    },
    {
      "fxDate": "2020-06-15T11:00+08:00",
      "temp": "33",
      "icon": "150",
      "text": "晴",
      "wind360": "7",
      "windDir": "北风",
      "windScale": "1-2",
      "windSpeed": "10",
      "humidity": "26",
      "pop": "0",
      "precip": "0.0",
      "pressure": "997",
      "cloud": "90",
      "dew": "2",
      "snow": "0.0",
      "ice": "0.0"
    },
    {
      "fxDate": "2020-06-15T12:00+08:00",
      "temp": "34",
      "icon": "150",
      "text": "晴",
      "wind360": "279",
      "windDir": "西风",
      "windScale": "1-2",
      "windSpeed": "1",
      "humidity": "24",
      "pop": "0",
      "precip": "0.0",
      "pressure": "997",
      "cloud": "91",
      "dew": "0",
      "snow": "0.0",
      "ice": "0.0"
    },
    {
      "fxDate": "2020-06-15T13:00+08:00",
      "temp": "35",
      "icon": "150",
      "text": "晴",
      "wind360": "249",
      "windDir": "西南风",
      "windScale": "1-2",
      "windSpeed": "5",
      "humidity": "23",
      "pop": "0",
      "precip": "0.0",
      "pressure": "998",
      "cloud": "93",
      "dew": "0",
      "snow": "0.0",
      "ice": "0.0"
    },
    {
      "fxDate": "2020-06-15T14:00+08:00",
      "temp": "35",
      "icon": "150",
      "text": "晴",
      "wind360": "0",
      "windDir": "北风",
      "windScale": "1-2",
      "windSpeed": "1",
      "humidity": "21",
      "pop": "0",
      "precip": "0.0",
      "pressure": "998",
      "cloud": "95",
      "dew": "0",
      "snow": "0.0",
      "ice": "0.0"
    },
    {
      "fxDate": "2020-06-15T15:00+08:00",
      "temp": "35",
      "icon": "150",
      "text": "晴",
      "wind360": "128",
      "windDir": "东南风",
      "windScale": "1-2",
      "windSpeed": "7",
      "humidity": "20",
      "pop": "0",
      "precip": "0.0",
      "pressure": "998",
      "cloud": "93",
      "dew": "0",
      "snow": "0.0",
      "ice": "0.0"
    },
    {
      "fxDate": "2020-06-15T16:00+08:00",
      "temp": "35",
      "icon": "150",
      "text": "晴",
      "wind360": "165",
      "windDir": "东南风",
      "windScale": "1-2",
      "windSpeed": "11",
      "humidity": "20",
      "pop": "0",
      "precip": "0.0",
      "pressure": "999",
      "cloud": "91",
      "dew": "0",
      "snow": "0.0",
      "ice": "0.0"
    },
    {
      "fxDate": "2020-06-15T17:00+08:00",
      "temp": "36",
      "icon": "150",
      "text": "晴",
      "wind360": "8",
      "windDir": "北风",
      "windScale": "1-2",
      "windSpeed": "6",
      "humidity": "20",
      "pop": "0",
      "precip": "0.0",
      "pressure": "999",
      "cloud": "89",
      "dew": "0",
      "snow": "0.0",
      "ice": "0.0"
    }
  ],
  "refer": {
    "sources": [
      "Weather China"
    ],
    "license": [
      "commercial license"
    ]
  }
}