空气质量

全国3240市县区及1500个监测站点的空气质量AQI接口,支持空气质量AQI数据,空气质量实况数据、空气质量未来7天预报。通过灵活的接口请求参数,你可以一次获取以上数据,也可以分别获取其中你需要的数据。

请求URL

空气质量实况 HTTP GET

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

空气质量5天预报 HTTP GET

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

请求参数

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

location 必选

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

key 必选

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

gzip 可选

对API接口进行压缩,可以极大的减少API接口访问延迟,减少缓存空间,提高接口连接成功率。默认开启gzip

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

lang 可选

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

返回数据

参数 描述 示例值
code API状态码,具体含义请参考状态码 200
updateTime 当前API的最近更新时间 2013-12-30T01:45+08:00
fxLink 该城市的空气质量自适应网页,可嵌入网站或应用 http://hfx.link/ae45
now.pubTime 实时空气质量数据发布时间 2013-12-30T01:45+08:00
now.aqi 实时空气质量指数 74
now.level 实时空气质量指数等级 2
now.category 实时空气质量指数级别
now.primary 实时空气质量的主要污染物,空气质量为优时,返回值为NA pm2.5
now.pm10 实时 pm10 78
now.pm2p5 实时 pm2.5 66
now.no2 实时 二氧化氮 40
now.so2 实时 二氧化硫 30
now.co 实时 一氧化碳 33
now.o3 实时 臭氧 20
station.pubTime 监测站实时空气质量数据发布时间,仅在国控站点的城市中返回。 2013-12-30T01:45+08:00
station.name 监测站名称,仅在国控站点的城市中返回 万寿西宫
station.id 监测站ID,仅在国控站点的城市中返回 CNA110000
station.aqi 监测站实时空气质量指数,仅在国控站点的城市中返回 74
station.level 监测站实时空气质量指数等级,仅在国控站点的城市中返回 2
station.category 监测站实时空气质量指数级别,仅在国控站点的城市中返回
station.primary 监测站实时主要污染物,仅在国控站点的城市中返回。空气质量为优时,返回值为NA pm25
station.pm10 监测站实时 pm10,仅在国控站点的城市中返回 78
station.pm2p5 监测站实时 pm2.5,仅在国控站点的城市中返回 66
station.no2 监测站实时 二氧化氮,仅在国控站点的城市中返回 40
station.so2 监测站实时 二氧化硫,仅在国控站点的城市中返回 30
station.co 监测站实时 一氧化碳,仅在国控站点的城市中返回 33
station.o3 监测站实时 臭氧,仅在国控站点的城市中返回 20
daily.fxDate 空气质量逐天预报日期 2018-05-31
daily.aqi 空气质量逐天预报指数 74
daily.level 逐天预报的空气质量指数等级 2
daily.category 逐天预空气质量指数级别
daily.primary 空气质量逐天预报的主要污染物,空气质量为优时,返回值为NA pm2.5
refer.sources 原始数据来源,可能为空  
refer.license 数据许可证  

空气质量指数等级

数值 等级 级别 级别颜色
0-50 一级 绿色
51-100 二级 黄色
101-150 三级 轻度污染 橙色
151-200 四级 中度污染 红色
201-300 五级 重度污染 紫色
>300 六级 严重污染 褐红色

请求和返回示例

空气质量实况

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

{
  "code": "200",
  "updateTime": "2020-06-21T11:44+08:00",
  "fxLink": "https://www.heweather.com/air/beijing-101010100.html",
  "now": {
    "pubTime": "2020-06-21T11:00+08:00",
    "aqi": "82",
    "category": "良",
    "primary": "O3",
    "pm10": "82",
    "pm2p5": "39",
    "no2": "16",
    "so2": "5",
    "co": "0.7",
    "o3": "185"
  },
  "station": [
    {
      "pubTime": "2020-06-21T11:00+08:00",
      "stationName": "万寿西宫",
      "stationId": "CNA1001",
      "aqi": "64",
      "level": "2",
      "category": "良",
      "primary": "PM10",
      "pm10": "77",
      "pm2p5": "36",
      "no2": "17",
      "so2": "3",
      "co": "0.5",
      "o3": "166"
    },
    {
      "pubTime": "2020-06-21T11:00+08:00",
      "stationName": "定陵",
      "stationId": "CNA1002",
      "aqi": "103",
      "level": "3",
      "category": "轻度污染",
      "primary": "O3",
      "pm10": "95",
      "pm2p5": "35",
      "no2": "15",
      "so2": "3",
      "co": "0.7",
      "o3": "206"
    },
    {
      "pubTime": "2020-06-21T11:00+08:00",
      "stationName": "东四",
      "stationId": "CNA1003",
      "aqi": "102",
      "level": "3",
      "category": "轻度污染",
      "primary": "O3",
      "pm10": "67",
      "pm2p5": "36",
      "no2": "12",
      "so2": "5",
      "co": "0.6",
      "o3": "203"
    },
    {
      "pubTime": "2020-06-21T11:00+08:00",
      "stationName": "天坛",
      "stationId": "CNA1004",
      "aqi": "69",
      "level": "2",
      "category": "良",
      "primary": "O3",
      "pm10": "76",
      "pm2p5": "38",
      "no2": "12",
      "so2": "5",
      "co": "0.7",
      "o3": "175"
    },
    {
      "pubTime": "2020-06-21T11:00+08:00",
      "stationName": "农展馆",
      "stationId": "CNA1005",
      "aqi": "73",
      "level": "2",
      "category": "良",
      "primary": "O3",
      "pm10": "77",
      "pm2p5": "35",
      "no2": "13",
      "so2": "4",
      "co": "0.6",
      "o3": "178"
    },
    {
      "pubTime": "2020-06-21T11:00+08:00",
      "stationName": "官园",
      "stationId": "CNA1006",
      "aqi": "83",
      "level": "2",
      "category": "良",
      "primary": "O3",
      "pm10": "77",
      "pm2p5": "39",
      "no2": "15",
      "so2": "5",
      "co": "0.5",
      "o3": "186"
    },
    {
      "pubTime": "2020-06-21T11:00+08:00",
      "stationName": "海淀区万柳",
      "stationId": "CNA1007",
      "aqi": "97",
      "level": "2",
      "category": "良",
      "primary": "O3",
      "pm10": "74",
      "pm2p5": "36",
      "no2": "17",
      "so2": "6",
      "co": "0.7",
      "o3": "197"
    },
    {
      "pubTime": "2020-06-21T11:00+08:00",
      "stationName": "顺义新城",
      "stationId": "CNA1008",
      "aqi": "101",
      "level": "3",
      "category": "轻度污染",
      "primary": "O3",
      "pm10": "67",
      "pm2p5": "32",
      "no2": "18",
      "so2": "5",
      "co": "0.5",
      "o3": "202"
    },
    {
      "pubTime": "2020-06-21T11:00+08:00",
      "stationName": "怀柔镇",
      "stationId": "CNA1009",
      "aqi": "99",
      "level": "2",
      "category": "良",
      "primary": "O3",
      "pm10": "102",
      "pm2p5": "53",
      "no2": "26",
      "so2": "4",
      "co": "0.7",
      "o3": "199"
    },
    {
      "pubTime": "2020-06-21T11:00+08:00",
      "stationName": "昌平镇",
      "stationId": "CNA1010",
      "aqi": "78",
      "level": "2",
      "category": "良",
      "primary": "NA",
      "pm10": "106",
      "pm2p5": "57",
      "no2": "17",
      "so2": "3",
      "co": "0.7",
      "o3": "163"
    },
    {
      "pubTime": "2020-06-21T11:00+08:00",
      "stationName": "奥体中心",
      "stationId": "CNA1011",
      "aqi": "67",
      "level": "2",
      "category": "良",
      "primary": "PM10",
      "pm10": "84",
      "pm2p5": "30",
      "no2": "15",
      "so2": "3",
      "co": "0.5",
      "o3": "164"
    },
    {
      "pubTime": "2020-06-21T11:00+08:00",
      "stationName": "古城",
      "stationId": "CNA1012",
      "aqi": "67",
      "level": "2",
      "category": "良",
      "primary": "O3",
      "pm10": "72",
      "pm2p5": "33",
      "no2": "13",
      "so2": "5",
      "co": "0.6",
      "o3": "173"
    }
  ],
  "refer": {
    "sources": [
      "cnemc"
    ],
    "license": [
      "commercial license"
    ]
  }
}

空气质量5天预报

// 北京空气质量5天预报 
// 商业版:https://api.heweather.net/v7/air/5d?location=101010100&key=xxx
// 请将示例请求URL中的KEY更换成你自己的KEY

{
  "code": "200",
  "updateTime": "2020-06-19T09:28+08:00",
  "fxLink": "https://www.heweather.com/air/beijing-101010100.html",
  "daily": [
    {
      "fxDate": "2020-06-19",
      "aqi": "15",
      "category": "优",
      "primary": "NA"
    },
    {
      "fxDate": "2020-06-20",
      "aqi": "20",
      "category": "优",
      "primary": "NA"
    },
    {
      "fxDate": "2020-06-21",
      "aqi": "39",
      "category": "优",
      "primary": "NA"
    },
    {
      "fxDate": "2020-06-22",
      "aqi": "24",
      "category": "优",
      "primary": "NA"
    },
    {
      "fxDate": "2020-06-23",
      "aqi": "25",
      "category": "优",
      "primary": "NA"
    }
  ],
  "refer": {
    "sources": [
      "cnemc"
    ],
    "license": [
      "commercial license"
    ]
  }
}