历史天气和空气质量

最近历史数据,可以通过API接口获取最近10天的天气、空气质量历史数据。其中空气质量仅支持中国范围内的城市。

如需要更长时间的城市历史数据或格点历史数据,请在这里提交购买申请。

请求URL

天气历史数据 HTTP GET

  • 商业版 https://datasetapi.qweather.com/v7/historical/weather?{请求参数}

空气质量历史数据 HTTP GET

  • 商业版 https://datasetapi.qweather.com/v7/historical/air?{请求参数}

请求参数

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

location 必选

需要查询地区的LocationID,LocationID可通过城市搜索服务获取。例如: location=101010100

key 必选

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

date 必选

选择获取历史的日期限度,最多可选择最近10天的数据,例如今天是7月5日,最多可获取6月25日至7月4日的历史数据。日期格式为yyyyMMdd,例如 date=20200531

gzip 可选

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

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

lang 可选

多语言,默认中文。具体的语言参数值请参考多语言参数

unit 可选

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

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

返回数据

参数 描述 示例值
code API状态码,具体含义请参考状态码 200
fxLink 该城市的历史天气和空气质量自适应网页,可嵌入网站或应用。有可能为空。 http://hfx.link/ae45
weatherDaily.date 历史当天天气日期 2018-05-31
weatherDaily.sunrise 当天日出时间 07:36
weatherDaily.sunset 当天日落时间 16:58
weatherDaily.moonrise 当天月升时间 04:47
weatherDaily.moonset 当天月落时间 14:59
weatherDaily.moonPhase 当天月相名称 上弦月
weatherDaily.tempMax 当天最高温度 4
weatherDaily.tempMin 当天最低温度 -5
weatherDaily.humidity 当天相对湿度 37
weatherDaily.precip 当天降水量 0
weatherDaily.pressure 当天大气压强 1018
weatherHourly.time 历史当天天气时间 2013-12-30T01:45+08:00
weatherHourly.temp 当天每小时温度 2
weatherHourly.icon 当天每小时天气状况图标的代码,图标可通过天气状况和图标下载 101
weatherHourly.text 当天每小时天气状况代码 多云
weatherHourly.precip 当天每小时累计降水量 1.2
weatherHourly.wind360 当天每小时风向360角度 305
weatherHourly.windDir 当天每小时风向 西北
weatherHourly.windScale 当天每小时风力 4
weatherHourly.windSpeed 当天每小时风速,公里/小时 15
weatherHourly.humidity 当天每小时相对湿度 30
weatherHourly.pressure 当天每小时大气压强 1030
airHourly.pubTime 历史当天空气质量数据发布时间,格式yyyy-MM-dd HH:mm 2013-12-30T01:45+08:00
airHourly.aqi 当天每小时空气质量指数 74
airHourly.level 当天每小时空气质量指数等级 2
airHourly.category 当天每小时空气质量指数级别
airHourly.primary 当天每小时主要污染物 pm2.5
airHourly.pm10 当天每小时pm10 78
airHourly.pm2p5 当天每小时pm2.5 66
airHourly.no2 当天每小时二氧化氮 40
airHourly.so2 当天每小时二氧化硫 30
airHourly.co 当天每小时一氧化碳 33
airHourly.o3 当天每小时臭氧 20
refer.sources 原始数据来源,可能为空  
refer.license 数据许可证  

请求和返回示例

天气历史数据

// 北京天气历史数据 
// 商业版 https://api.qweather.com/v7/historical/weather?location=101010100&date=20200725&key=xxx
// 请将示例请求URL中的KEY更换成你自己的KEY,date更换成最近10天的日期

{
  "code": "200",
  "fxLink": "http://hfx.link/2ax6",
  "weatherDaily": {
    "date": "2020-07-25",
    "sunrise": "05:08",
    "sunset": "19:33",
    "moonrise": "09:54",
    "moonset": "22:40",
    "moonPhase": "峨眉月",
    "tempMax": "33",
    "tempMin": "23",
    "humidity": "52",
    "precip": "0.0",
    "pressure": "1000"
  },
  "weatherHourly": [
    {
      "time": "2020-07-25 00:00",
      "temp": "28",
      "icon": "100",
      "text": "晴",
      "precip": "0.0",
      "wind360": "246",
      "windDir": "西南风",
      "windScale": "2",
      "windSpeed": "8",
      "humidity": "49",
      "pressure": "1001"
    },
    {
      "time": "2020-07-25 01:00",
      "temp": "27",
      "icon": "101",
      "text": "多云",
      "precip": "0.0",
      "wind360": "350",
      "windDir": "北风",
      "windScale": "1",
      "windSpeed": "4",
      "humidity": "57",
      "pressure": "1001"
    },
    {
      "time": "2020-07-25 02:00",
      "temp": "25",
      "icon": "100",
      "text": "晴",
      "precip": "0.0",
      "wind360": "175",
      "windDir": "南风",
      "windScale": "2",
      "windSpeed": "7",
      "humidity": "63",
      "pressure": "1001"
    },
    {
      "time": "2020-07-25 03:00",
      "temp": "25",
      "icon": "104",
      "text": "阴",
      "precip": "0.0",
      "wind360": "359",
      "windDir": "北风",
      "windScale": "1",
      "windSpeed": "5",
      "humidity": "68",
      "pressure": "1001"
    },
    {
      "time": "2020-07-25 04:00",
      "temp": "23",
      "icon": "100",
      "text": "晴",
      "precip": "0.0",
      "wind360": "126",
      "windDir": "东南风",
      "windScale": "1",
      "windSpeed": "3",
      "humidity": "73",
      "pressure": "1000"
    },
    {
      "time": "2020-07-25 05:00",
      "temp": "23",
      "icon": "100",
      "text": "晴",
      "precip": "0.0",
      "wind360": "166",
      "windDir": "东南风",
      "windScale": "1",
      "windSpeed": "4",
      "humidity": "76",
      "pressure": "1001"
    },
    {
      "time": "2020-07-25 06:00",
      "temp": "23",
      "icon": "100",
      "text": "晴",
      "precip": "0.0",
      "wind360": "69",
      "windDir": "东北风",
      "windScale": "1",
      "windSpeed": "2",
      "humidity": "75",
      "pressure": "1001"
    },
    {
      "time": "2020-07-25 07:00",
      "temp": "26",
      "icon": "104",
      "text": "阴",
      "precip": "0.0",
      "wind360": "358",
      "windDir": "北风",
      "windScale": "1",
      "windSpeed": "4",
      "humidity": "71",
      "pressure": "1001"
    },
    {
      "time": "2020-07-25 08:00",
      "temp": "28",
      "icon": "104",
      "text": "阴",
      "precip": "0.0",
      "wind360": "189",
      "windDir": "南风",
      "windScale": "1",
      "windSpeed": "3",
      "humidity": "57",
      "pressure": "1001"
    },
    {
      "time": "2020-07-25 09:00",
      "temp": "30",
      "icon": "104",
      "text": "阴",
      "precip": "0.0",
      "wind360": "350",
      "windDir": "北风",
      "windScale": "1",
      "windSpeed": "3",
      "humidity": "48",
      "pressure": "1001"
    },
    {
      "time": "2020-07-25 10:00",
      "temp": "32",
      "icon": "104",
      "text": "阴",
      "precip": "0.0",
      "wind360": "180",
      "windDir": "南风",
      "windScale": "1",
      "windSpeed": "2",
      "humidity": "48",
      "pressure": "1001"
    },
    {
      "time": "2020-07-25 11:00",
      "temp": "33",
      "icon": "101",
      "text": "多云",
      "precip": "0.0",
      "wind360": "177",
      "windDir": "南风",
      "windScale": "2",
      "windSpeed": "6",
      "humidity": "40",
      "pressure": "1001"
    },
    {
      "time": "2020-07-25 12:00",
      "temp": "32",
      "icon": "101",
      "text": "多云",
      "precip": "0.0",
      "wind360": "222",
      "windDir": "西南风",
      "windScale": "2",
      "windSpeed": "10",
      "humidity": "39",
      "pressure": "1001"
    },
    {
      "time": "2020-07-25 13:00",
      "temp": "32",
      "icon": "101",
      "text": "多云",
      "precip": "0.0",
      "wind360": "187",
      "windDir": "南风",
      "windScale": "2",
      "windSpeed": "10",
      "humidity": "40",
      "pressure": "1000"
    },
    {
      "time": "2020-07-25 14:00",
      "temp": "33",
      "icon": "101",
      "text": "多云",
      "precip": "0.0",
      "wind360": "266",
      "windDir": "西风",
      "windScale": "2",
      "windSpeed": "9",
      "humidity": "36",
      "pressure": "1000"
    },
    {
      "time": "2020-07-25 15:00",
      "temp": "32",
      "icon": "101",
      "text": "多云",
      "precip": "0.0",
      "wind360": "183",
      "windDir": "南风",
      "windScale": "1",
      "windSpeed": "2",
      "humidity": "39",
      "pressure": "1000"
    },
    {
      "time": "2020-07-25 16:00",
      "temp": "32",
      "icon": "101",
      "text": "多云",
      "precip": "0.0",
      "wind360": "189",
      "windDir": "南风",
      "windScale": "1",
      "windSpeed": "4",
      "humidity": "39",
      "pressure": "999"
    },
    {
      "time": "2020-07-25 17:00",
      "temp": "32",
      "icon": "101",
      "text": "多云",
      "precip": "0.0",
      "wind360": "173",
      "windDir": "南风",
      "windScale": "1",
      "windSpeed": "5",
      "humidity": "42",
      "pressure": "999"
    },
    {
      "time": "2020-07-25 18:00",
      "temp": "32",
      "icon": "101",
      "text": "多云",
      "precip": "0.0",
      "wind360": "173",
      "windDir": "南风",
      "windScale": "2",
      "windSpeed": "9",
      "humidity": "39",
      "pressure": "999"
    },
    {
      "time": "2020-07-25 19:00",
      "temp": "31",
      "icon": "101",
      "text": "多云",
      "precip": "0.0",
      "wind360": "185",
      "windDir": "南风",
      "windScale": "1",
      "windSpeed": "4",
      "humidity": "46",
      "pressure": "999"
    },
    {
      "time": "2020-07-25 20:00",
      "temp": "30",
      "icon": "104",
      "text": "阴",
      "precip": "0.0",
      "wind360": "185",
      "windDir": "南风",
      "windScale": "2",
      "windSpeed": "8",
      "humidity": "44",
      "pressure": "999"
    },
    {
      "time": "2020-07-25 21:00",
      "temp": "29",
      "icon": "104",
      "text": "阴",
      "precip": "0.0",
      "wind360": "208",
      "windDir": "西南风",
      "windScale": "2",
      "windSpeed": "7",
      "humidity": "52",
      "pressure": "1000"
    },
    {
      "time": "2020-07-25 22:00",
      "temp": "29",
      "icon": "104",
      "text": "阴",
      "precip": "0.0",
      "wind360": "188",
      "windDir": "南风",
      "windScale": "2",
      "windSpeed": "7",
      "humidity": "57",
      "pressure": "1000"
    },
    {
      "time": "2020-07-25 23:00",
      "temp": "28",
      "icon": "104",
      "text": "阴",
      "precip": "0.0",
      "wind360": "180",
      "windDir": "南风",
      "windScale": "1",
      "windSpeed": "5",
      "humidity": "61",
      "pressure": "1000"
    }
  ],
  "refer": {
    "sources": [
      "qweather.com"
    ],
    "license": [
      "commercial license"
    ]
  }
}

空气质量历史数据

// 北京空气质量历史数据 
// 商业版 https://api.qweather.com/v7/historical/air?location=101010100&date=20200725&key=xxx
// 请将示例请求URL中的KEY更换成你自己的KEY,date更换成最近10天的日期

{
  "code": "200",
  "fxLink": "http://hfx.link/2ax6",
  "airHourly": [
    {
      "pubTime": "2020-07-25 00:00",
      "aqi": "52",
      "level": "2",
      "category": "良",
      "primary": "PM10",
      "pm10": "54",
      "pm2p5": "22",
      "no2": "31",
      "so2": "2",
      "co": "0.5",
      "o3": "85"
    },
    {
      "pubTime": "2020-07-25 01:00",
      "aqi": "52",
      "level": "2",
      "category": "良",
      "primary": "PM10",
      "pm10": "54",
      "pm2p5": "22",
      "no2": "45",
      "so2": "2",
      "co": "0.5",
      "o3": "59"
    },
    {
      "pubTime": "2020-07-25 02:00",
      "aqi": "52",
      "level": "2",
      "category": "良",
      "primary": "PM10",
      "pm10": "53",
      "pm2p5": "22",
      "no2": "48",
      "so2": "3",
      "co": "0.5",
      "o3": "53"
    },
    {
      "pubTime": "2020-07-25 03:00",
      "aqi": "49",
      "level": "1",
      "category": "优",
      "primary": "-",
      "pm10": "49",
      "pm2p5": "23",
      "no2": "48",
      "so2": "3",
      "co": "0.5",
      "o3": "48"
    },
    {
      "pubTime": "2020-07-25 04:00",
      "aqi": "51",
      "level": "2",
      "category": "良",
      "primary": "PM10",
      "pm10": "51",
      "pm2p5": "23",
      "no2": "56",
      "so2": "3",
      "co": "0.5",
      "o3": "38"
    },
    {
      "pubTime": "2020-07-25 05:00",
      "aqi": "52",
      "level": "2",
      "category": "良",
      "primary": "PM10",
      "pm10": "53",
      "pm2p5": "24",
      "no2": "57",
      "so2": "3",
      "co": "0.5",
      "o3": "32"
    },
    {
      "pubTime": "2020-07-25 06:00",
      "aqi": "51",
      "level": "2",
      "category": "良",
      "primary": "PM10",
      "pm10": "52",
      "pm2p5": "22",
      "no2": "52",
      "so2": "3",
      "co": "0.5",
      "o3": "35"
    },
    {
      "pubTime": "2020-07-25 07:00",
      "aqi": "55",
      "level": "2",
      "category": "良",
      "primary": "PM10",
      "pm10": "59",
      "pm2p5": "25",
      "no2": "47",
      "so2": "2",
      "co": "0.6",
      "o3": "41"
    },
    {
      "pubTime": "2020-07-25 08:00",
      "aqi": "60",
      "level": "2",
      "category": "良",
      "primary": "PM10",
      "pm10": "69",
      "pm2p5": "27",
      "no2": "41",
      "so2": "3",
      "co": "0.6",
      "o3": "59"
    },
    {
      "pubTime": "2020-07-25 09:00",
      "aqi": "61",
      "level": "2",
      "category": "良",
      "primary": "PM10",
      "pm10": "72",
      "pm2p5": "30",
      "no2": "36",
      "so2": "4",
      "co": "0.7",
      "o3": "88"
    },
    {
      "pubTime": "2020-07-25 10:00",
      "aqi": "62",
      "level": "2",
      "category": "良",
      "primary": "PM10",
      "pm10": "74",
      "pm2p5": "29",
      "no2": "32",
      "so2": "4",
      "co": "0.8",
      "o3": "125"
    },
    {
      "pubTime": "2020-07-25 11:00",
      "aqi": "58",
      "level": "2",
      "category": "良",
      "primary": "PM10",
      "pm10": "66",
      "pm2p5": "30",
      "no2": "25",
      "so2": "4",
      "co": "0.8",
      "o3": "164"
    },
    {
      "pubTime": "2020-07-25 12:00",
      "aqi": "68",
      "level": "2",
      "category": "良",
      "primary": "O3",
      "pm10": "61",
      "pm2p5": "29",
      "no2": "23",
      "so2": "3",
      "co": "0.7",
      "o3": "174"
    },
    {
      "pubTime": "2020-07-25 13:00",
      "aqi": "83",
      "level": "2",
      "category": "良",
      "primary": "O3",
      "pm10": "52",
      "pm2p5": "27",
      "no2": "22",
      "so2": "3",
      "co": "0.7",
      "o3": "186"
    },
    {
      "pubTime": "2020-07-25 14:00",
      "aqi": "97",
      "level": "2",
      "category": "良",
      "primary": "O3",
      "pm10": "41",
      "pm2p5": "25",
      "no2": "18",
      "so2": "3",
      "co": "0.6",
      "o3": "197"
    },
    {
      "pubTime": "2020-07-25 15:00",
      "aqi": "98",
      "level": "2",
      "category": "良",
      "primary": "O3",
      "pm10": "51",
      "pm2p5": "24",
      "no2": "19",
      "so2": "2",
      "co": "0.5",
      "o3": "198"
    },
    {
      "pubTime": "2020-07-25 16:00",
      "aqi": "83",
      "level": "2",
      "category": "良",
      "primary": "O3",
      "pm10": "54",
      "pm2p5": "24",
      "no2": "20",
      "so2": "2",
      "co": "0.5",
      "o3": "186"
    },
    {
      "pubTime": "2020-07-25 17:00",
      "aqi": "74",
      "level": "2",
      "category": "良",
      "primary": "O3",
      "pm10": "59",
      "pm2p5": "24",
      "no2": "21",
      "so2": "2",
      "co": "0.6",
      "o3": "179"
    },
    {
      "pubTime": "2020-07-25 18:00",
      "aqi": "73",
      "level": "2",
      "category": "良",
      "primary": "O3",
      "pm10": "62",
      "pm2p5": "24",
      "no2": "22",
      "so2": "2",
      "co": "0.6",
      "o3": "178"
    },
    {
      "pubTime": "2020-07-25 19:00",
      "aqi": "58",
      "level": "2",
      "category": "良",
      "primary": "PM10",
      "pm10": "66",
      "pm2p5": "25",
      "no2": "24",
      "so2": "3",
      "co": "0.6",
      "o3": "166"
    },
    {
      "pubTime": "2020-07-25 20:00",
      "aqi": "58",
      "level": "2",
      "category": "良",
      "primary": "PM10",
      "pm10": "66",
      "pm2p5": "27",
      "no2": "28",
      "so2": "3",
      "co": "0.6",
      "o3": "147"
    },
    {
      "pubTime": "2020-07-25 21:00",
      "aqi": "66",
      "level": "2",
      "category": "良",
      "primary": "PM10",
      "pm10": "82",
      "pm2p5": "31",
      "no2": "29",
      "so2": "3",
      "co": "0.7",
      "o3": "127"
    },
    {
      "pubTime": "2020-07-25 22:00",
      "aqi": "67",
      "level": "2",
      "category": "良",
      "primary": "PM10",
      "pm10": "83",
      "pm2p5": "32",
      "no2": "26",
      "so2": "4",
      "co": "0.8",
      "o3": "125"
    },
    {
      "pubTime": "2020-07-25 23:00",
      "aqi": "70",
      "level": "2",
      "category": "良",
      "primary": "PM10",
      "pm10": "89",
      "pm2p5": "37",
      "no2": "28",
      "so2": "4",
      "co": "0.9",
      "o3": "120"
    }
  ],
  "refer": {
    "sources": [
      "qweather.com"
    ],
    "license": [
      "commercial license"
    ]
  }
}