空气质量
<p>[TOC]</p>
<h3>1 接口调用说明</h3>
<p>空气质量,包含全国城市空气质量查询、全国城市空气质量排行榜、PM数据-按城市查询、PM数据-按IP查询。</p>
<h4>1.1 请求方式</h4>
<p>如接口没有单独说明,所有接口均为:<strong>POST</strong></p>
<h4>1.2 请求格式</h4>
<p>如接口没有单独说明,所有接口均为:<strong>application/x-www-form-urlencoded</strong></p>
<h4>1.3 请求参数</h4>
<p>请求参数包括公共参数和业务参数(业务参数见具体接口说明)
调用接口时,需要把<strong>公共参数</strong>和<strong>业务参数</strong>一并放在<strong>请求参数</strong>中提交</p>
<h5>1.3.1 公共请求参数</h5>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th><div style="width:420px;">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>appId</td>
<td>String</td>
<td>是</td>
<td>服务商分配的唯一标识</td>
</tr>
<tr>
<td>timestamp</td>
<td>Long</td>
<td>是</td>
<td>当前时间戳(毫秒)</td>
</tr>
<tr>
<td>sign</td>
<td>String</td>
<td>是</td>
<td>签名,详见<a href="#签名算法">签名算法说明</a></td>
</tr>
</tbody>
</table>
<p><a name="签名算法"></a></p>
<h5>1.3.2 签名算法说明</h5>
<pre><code>sign = sha256(appId + appSecret + timestamp)</code></pre>
<p>用服务商分配的 <strong>appId</strong>、服务商分配的 <strong>appSecret</strong>,当前时间戳(毫秒) <strong>timestamp</strong>,按上述顺序拼接成字符串,再进行 <strong>sha256</strong> 哈希得到。如下:</p>
<pre><code class="language-java">String appId = &quot;xyzxy2121zxyz&quot;;
String timestamp = &quot;1555378976238&quot;;
String appSecret = &quot;efcefcef1121cefcefc1212121&quot;;
String str = appId + appSecret + timestamp;
String sign = sha256(str);</code></pre>
<h4>1.4 返回说明</h4>
<h5>1.4.1 公共返回字段说明</h5>
<p>所有接口均返回以下公共字段:</p>
<table>
<thead>
<tr>
<th>字段名</th>
<th><div style="width:420px">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>code</td>
<td>返回码,详见:code返回码说明</td>
</tr>
<tr>
<td>msg</td>
<td>code对应的描述</td>
</tr>
<tr>
<td>charge</td>
<td>计费标志 true为计费,false为不计费</td>
</tr>
<tr>
<td>taskNo</td>
<td>本次请求号</td>
</tr>
<tr>
<td>data</td>
<td>返回具体结果,object类型,详见data返回字段描述</td>
</tr>
</tbody>
</table>
<p><a name="code返回码说明"></a></p>
<h5>1.4.2 code返回码说明</h5>
<table>
<thead>
<tr>
<th>code</th>
<th><div style="width:420px;">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>200</td>
<td>成功</td>
</tr>
<tr>
<td>201</td>
<td>查无数据</td>
</tr>
<tr>
<td>400</td>
<td>参数错误</td>
</tr>
<tr>
<td>404</td>
<td>接口地址不正确</td>
</tr>
<tr>
<td>500</td>
<td>系统维护,请稍候再试</td>
</tr>
<tr>
<td>601</td>
<td>接口未开通</td>
</tr>
<tr>
<td>602</td>
<td>账号停用</td>
</tr>
<tr>
<td>604</td>
<td>接口停用</td>
</tr>
<tr>
<td>606</td>
<td>调用超限,请稍候再试</td>
</tr>
<tr>
<td>607</td>
<td>ip不在白名单</td>
</tr>
<tr>
<td>609</td>
<td>请求过于频繁,请稍候再试</td>
</tr>
<tr>
<td>610</td>
<td>请求超时</td>
</tr>
<tr>
<td>999</td>
<td>其他,以实际返回为准</td>
</tr>
</tbody>
</table>
<hr />
<h3>2 空气质量-全国城市空气质量查询</h3>
<h4>2.1 接口描述</h4>
<ul>
<li>根据城市查询对应的空气质量。由于国家只发布了370个大城市空气质量,因此查询小地区返回上一级主要城市的PM25情况。每半小时更新全国最多367个城市空气质量。</li>
</ul>
<h4>2.2 请求地址</h4>
<p><code>https://api.jumdata.com/air-quality/query</code></p>
<h4>2.3 业务参数</h4>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th><div style="width:420px;">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>area</td>
<td>String</td>
<td>是</td>
<td>城市名称</td>
</tr>
</tbody>
</table>
<h4>2.4 成功返回样例</h4>
<pre><code class="language-json">{
&quot;code&quot;: 200,//返回码,详见返回码说明
&quot;msg&quot;: &quot;成功&quot;,//返回码对应描述
&quot;taskNo&quot;: &quot;325946705208507560688788&quot;,//本次请求号
&quot;charge&quot;: true,//计费标志
&quot;data&quot;: {
&quot;area&quot;: &quot;杭州&quot;,//地区名
&quot;o3&quot;: &quot;22&quot;,//臭氧1小时平均,μg/m³
&quot;area_code&quot;: &quot;hangzhou&quot;,
&quot;num&quot;: &quot;153&quot;,//排行
&quot;pm10&quot;: &quot;63&quot;,//颗粒物(粒径小于等于10μm)1小时平均,μg/m³
&quot;co&quot;: &quot;0.9&quot;,//一氧化碳1小时平均,mg/m³
&quot;quality&quot;: &quot;良好&quot;,//空气质量指数类别,有“优质、良好、轻度污染、中度污染、重度污染、严重污染”6类
&quot;no2&quot;: &quot;61&quot;,//二氧化氮1小时平均,μg/m³
&quot;ct&quot;: &quot;2024-11-02 23:10:00.012&quot;,//发布时间
&quot;so2&quot;: &quot;6&quot;,//二氧化硫一小时平均,μg/m³
&quot;pm2_5&quot;: &quot;34&quot;,//颗粒物(粒径小于等于2.5μm)1小时平均,μg/m³
&quot;aqi&quot;: &quot;57&quot;,//空气质量指数(AQI),即air quality index,是定量描述空气质量状况的无纲量指数
&quot;primary_pollutant&quot;: &quot;颗粒物(PM10)&quot;,//首要污染物
&quot;o3_8h&quot;: &quot;79&quot;//臭氧8小时滑动平均,μg/m³
}
}</code></pre>
<h4>2.5 失败返回样例</h4>
<pre><code class="language-json">{
&quot;msg&quot;: &quot;地区不能为空&quot;,
&quot;code&quot;: 400,
&quot;charge&quot;: false
}</code></pre>
<hr />
<h3>3 空气质量-全国城市空气质量排行榜</h3>
<h4>3.1 接口描述</h4>
<ul>
<li>查询全国367个城市的空气质量排行榜。每半小时更新全国最多367个城市空气质量排行榜。</li>
</ul>
<h4>3.2 请求地址</h4>
<p><code>https://api.jumdata.com/air-quality/ranking</code></p>
<h4>3.3 业务参数</h4>
<h4>3.4 成功返回样例</h4>
<pre><code class="language-json">{
&quot;code&quot;: 200,//返回码,详见返回码说明
&quot;msg&quot;: &quot;成功&quot;,//返回码对应描述
&quot;taskNo&quot;: &quot;823469219158756173215449&quot;,//本次请求号
&quot;charge&quot;: true,//计费标志
&quot;data&quot;: {
&quot;list&quot;: [
{
&quot;area&quot;: &quot;昌都&quot;,//地区名
&quot;o3&quot;: &quot;30&quot;,//臭氧1小时平均,μg/m³
&quot;area_code&quot;: &quot;changdou&quot;,
&quot;num&quot;: &quot;1&quot;,//排行
&quot;pm10&quot;: &quot;15&quot;,//颗粒物(粒径小于等于10μm)1小时平均,μg/m³
&quot;co&quot;: &quot;0.6&quot;,//一氧化碳1小时平均,mg/m³
&quot;quality&quot;: &quot;优质&quot;,//空气质量指数类别,有“优质、良好、轻度污染、中度污染、重度污染、严重污染”6类
&quot;no2&quot;: &quot;12&quot;,//二氧化氮1小时平均,μg/m³
&quot;ct&quot;: &quot;2024-11-03 09:40:00.011&quot;,//发布时间
&quot;so2&quot;: &quot;6&quot;,//二氧化硫一小时平均,μg/m³
&quot;pm2_5&quot;: &quot;9&quot;,//颗粒物(粒径小于等于2.5μm)1小时平均,μg/m³
&quot;aqi&quot;: &quot;15&quot;,//空气质量指数(AQI),即air quality index,是定量描述空气质量状况的无纲量指数
&quot;primary_pollutant&quot;: &quot;&quot;,//首要污染物
&quot;o3_8h&quot;: &quot;30&quot;//臭氧8小时滑动平均,μg/m³
},
......
]
}
}</code></pre>
<hr />
<h3>4 空气质量-PM数据-按城市查询</h3>
<h4>4.1 接口描述</h4>
<ul>
<li>查询单个城市及其下属的监测点的PM数据,包括AQI,空气质量,指数类别,首要污染物,PM 2.5,细颗粒物,PM 10,可吸入颗粒物, 一氧化碳, 二氧化氮, 臭氧1小时平均, 臭氧8小时平均, 二氧化硫等信息。每8小时更新367个城市下各个监测点相关详细PM数据。</li>
</ul>
<h4>4.2 请求地址</h4>
<p><code>https://api.jumdata.com/air-quality/pm/by-city</code></p>
<h4>4.3 业务参数</h4>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th><div style="width:420px;">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>city</td>
<td>String</td>
<td>是</td>
<td>城市</td>
</tr>
</tbody>
</table>
<h4>4.4 成功返回样例</h4>
<pre><code class="language-json">{
&quot;code&quot;: 200,//返回码,详见返回码说明
&quot;msg&quot;: &quot;成功&quot;,//返回码对应描述
&quot;taskNo&quot;: &quot;518352325189267867664895&quot;,//本次请求号
&quot;charge&quot;: true,//计费标志
&quot;data&quot;: {
&quot;pm&quot;: { //PM结构数据
&quot;area&quot;: &quot;杭州&quot;,//城市名称
&quot;o3&quot;: &quot;24&quot;,//臭氧1小时平均,μg/m³
&quot;area_code&quot;: &quot;hangzhou&quot;,
&quot;num&quot;: &quot;93&quot;,//排行
&quot;pm10&quot;: &quot;46&quot;,//颗粒物(粒径小于等于10μm)1小时平均,μg/m³
&quot;co&quot;: &quot;0.7&quot;,//一氧化碳1小时平均,mg/m³
&quot;quality&quot;: &quot;优质&quot;,//空气质量指数类别,有“优质、良好、轻度污染、中度污染、重度污染、严重污染”6类
&quot;no2&quot;: &quot;38&quot;,//二氧化氮1小时平均,μg/m³
&quot;ct&quot;: &quot;2024-11-03 09:40:00.011&quot;,//发布时间
&quot;so2&quot;: &quot;6&quot;,//二氧化硫一小时平均,μg/m³
&quot;pm2_5&quot;: &quot;31&quot;,//颗粒物(粒径小于等于2.5μm)1小时平均,μg/m³
&quot;aqi&quot;: &quot;42&quot;,//空气质量指数(AQI),即air quality index,是定量描述空气质量状况的无纲量指数
&quot;primary_pollutant&quot;: &quot;&quot;,//首要污染物
&quot;o3_8h&quot;: &quot;11&quot; //臭氧8小时滑动平均,μg/m³
},
&quot;siteList&quot;: [ //下属的监测站的PM数据。此列表数据只在【单个城市PM】接入点中存在。
{
&quot;no2&quot;: &quot;7&quot;, //二氧化氮1小时平均,μg/m³
&quot;site_name&quot;: &quot;市府大楼&quot;, //监测点名称
&quot;ct&quot;: &quot;2022-07-06 11:39:00.707&quot;,//发布时间
&quot;o3&quot;: &quot;59&quot;,//臭氧1小时平均,μg/m³
&quot;so2&quot;: &quot;9&quot;, //二氧化硫一小时平均,μg/m³
&quot;pm2_5&quot;: &quot;7&quot;,//颗粒物(粒径小于等于2.5μm)1小时平均,μg/m³
&quot;aqi&quot;: &quot;19&quot;,//空气质量指数(AQI),即air quality index,是定量描述空气质量状况的无纲量指数
&quot;pm10&quot;: &quot;17&quot;, //颗粒物(粒径小于等于10μm)1小时平均,μg/m³
&quot;primary_pollutant&quot;: &quot;-&quot;,//首要污染物
&quot;co&quot;: &quot;0.6&quot;,//一氧化碳1小时平均,mg/m³
&quot;quality&quot;: &quot;优质&quot;, //空气质量指数类别,有“优、良、轻度污染、中度污染、重度污染、严重污染”6类
&quot;o3_8h&quot;: &quot;59&quot; //臭氧8小时滑动平均,μg/m³
},
......
]
}
}</code></pre>
<h4>4.5 失败返回样例</h4>
<pre><code class="language-json">{
&quot;msg&quot;: &quot;城市不能为空&quot;,
&quot;code&quot;: 400,
&quot;charge&quot;: false
}</code></pre>
<hr />
<h3>5 空气质量-PM数据-按IP查询</h3>
<h4>5.1 接口描述</h4>
<ul>
<li>根据ip查询单个城市及其下属的监测点的PM数据,包括AQI,空气质量,指数类别,首要污染物,PM 2.5,细颗粒物,PM 10,可吸入颗粒物, 一氧化碳, 二氧化氮, 臭氧1小时平均, 臭氧8小时平均, 二氧化硫等信息。每8小时更新367个城市下各个监测点相关详细PM数据。</li>
</ul>
<h4>5.2 请求地址</h4>
<p><code>https://api.jumdata.com/air-quality/pm/by-ip</code></p>
<h4>5.3 业务参数</h4>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th><div style="width:420px;">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>ip</td>
<td>String</td>
<td>是</td>
<td>ip地址</td>
</tr>
</tbody>
</table>
<h4>5.4 成功返回样例</h4>
<pre><code class="language-json">{
&quot;code&quot;: 200,//返回码,详见返回码说明
&quot;msg&quot;: &quot;成功&quot;,//返回码对应描述
&quot;taskNo&quot;: &quot;569922565184110844672479&quot;,//本次请求号
&quot;charge&quot;: true,//计费标志
&quot;data&quot;: {
&quot;pm&quot;: { //PM结构数据
&quot;area&quot;: &quot;杭州&quot;,//城市名称
&quot;o3&quot;: &quot;24&quot;,//臭氧1小时平均,μg/m³
&quot;area_code&quot;: &quot;hangzhou&quot;,
&quot;num&quot;: &quot;93&quot;,//排行
&quot;pm10&quot;: &quot;46&quot;,//颗粒物(粒径小于等于10μm)1小时平均,μg/m³
&quot;co&quot;: &quot;0.7&quot;,//一氧化碳1小时平均,mg/m³
&quot;quality&quot;: &quot;优质&quot;,//空气质量指数类别,有“优质、良好、轻度污染、中度污染、重度污染、严重污染”6类
&quot;no2&quot;: &quot;38&quot;,//二氧化氮1小时平均,μg/m³
&quot;ct&quot;: &quot;2024-11-03 09:40:00.011&quot;,//发布时间
&quot;so2&quot;: &quot;6&quot;,//二氧化硫一小时平均,μg/m³
&quot;pm2_5&quot;: &quot;31&quot;,//颗粒物(粒径小于等于2.5μm)1小时平均,μg/m³
&quot;aqi&quot;: &quot;42&quot;,//空气质量指数(AQI),即air quality index,是定量描述空气质量状况的无纲量指数
&quot;primary_pollutant&quot;: &quot;&quot;,//首要污染物
&quot;o3_8h&quot;: &quot;11&quot; //臭氧8小时滑动平均,μg/m³
},
&quot;siteList&quot;: [ //下属的监测站的PM数据。此列表数据只在【单个城市PM】接入点中存在。
{
&quot;no2&quot;: &quot;7&quot;, //二氧化氮1小时平均,μg/m³
&quot;site_name&quot;: &quot;市府大楼&quot;, //监测点名称
&quot;ct&quot;: &quot;2022-07-06 11:39:00.707&quot;,//发布时间
&quot;o3&quot;: &quot;59&quot;,//臭氧1小时平均,μg/m³
&quot;so2&quot;: &quot;9&quot;, //二氧化硫一小时平均,μg/m³
&quot;pm2_5&quot;: &quot;7&quot;,//颗粒物(粒径小于等于2.5μm)1小时平均,μg/m³
&quot;aqi&quot;: &quot;19&quot;,//空气质量指数(AQI),即air quality index,是定量描述空气质量状况的无纲量指数
&quot;pm10&quot;: &quot;17&quot;, //颗粒物(粒径小于等于10μm)1小时平均,μg/m³
&quot;primary_pollutant&quot;: &quot;-&quot;,//首要污染物
&quot;co&quot;: &quot;0.6&quot;,//一氧化碳1小时平均,mg/m³
&quot;quality&quot;: &quot;优质&quot;, //空气质量指数类别,有“优、良、轻度污染、中度污染、重度污染、严重污染”6类
&quot;o3_8h&quot;: &quot;59&quot; //臭氧8小时滑动平均,μg/m³
},
......
]
}
}</code></pre>
<h4>5.5 失败返回样例</h4>
<pre><code class="language-json">{
&quot;msg&quot;: &quot;ip地址不能为空&quot;,
&quot;code&quot;: 400,
&quot;charge&quot;: false
}</code></pre>