天气查询-历史天气
<h3>接口描述</h3>
<ul>
<li>全国3000多个省市的历史天气查询,包括最高最低温度、风级、湿度、气压等指数,最低最高温度、日出日落时间、空气质量指数、首要污染物等信息。</li>
</ul>
<h3>请求地址</h3>
<p><code>https://api.jumdata.com/weather/query/history</code></p>
<h3>请求方式</h3>
<ul>
<li>GET/POST</li>
</ul>
<h3>请求格式</h3>
<ul>
<li>x-www-form-urlencoded</li>
</ul>
<h3>请求参数</h3>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th><div style="width:400px">说明</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>签名,详见签名算法说明</td>
</tr>
<tr>
<td>date</td>
<td>String</td>
<td>否</td>
<td>日期,默认为昨天,格式为:yyyy-MM-dd</td>
</tr>
<tr>
<td>city</td>
<td>String</td>
<td>是</td>
<td>城市名称或者城市区划代码,支持区县,参见:[城市区划代码](<a href="https://file.jumdata.com/support/weather/weather-city.xlsx">https://file.jumdata.com/support/weather/weather-city.xlsx</a> "城市区划代码")</td>
</tr>
</tbody>
</table>
<h3>签名算法说明</h3>
<p><code>sign = sha256(appId + appSecret + timestamp)</code></p>
<p>用服务商分配的 appId、服务商分配的 appSecret,当前时间毫秒数 timestamp,按上述顺序拼接成字符串,再进行 sha256 哈希得到。如下:</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>
<h3>成功返回样例</h3>
<pre><code class="language-json">{
&quot;code&quot;: 200,//返回码,详见返回码说明
&quot;msg&quot;: &quot;成功&quot;,//返回码对应描述
&quot;taskNo&quot;: &quot;680024790172821701729765&quot;,//本次请求号
&quot;charge&quot;: true,//计费标志
&quot;data&quot;: {
&quot;date&quot;: &quot;2024-08-23&quot;,//日期
&quot;templow&quot;: &quot;26&quot;,//最低气温
&quot;img&quot;: &quot;https://xxx.png&quot;,//图片地址
&quot;imgNo&quot;: &quot;02&quot;,//天气图标编号
&quot;sunrise&quot;: &quot;05:30&quot;,//日出时间
&quot;windpower&quot;: &quot;2级&quot;,//风级
&quot;cityname&quot;: &quot;杭州&quot;,//城市
&quot;cityid&quot;: 382,//城市ID
&quot;pressure&quot;: &quot;1004&quot;,//气压
&quot;primarypollutant&quot;: &quot;—&quot;,//首要污染物
&quot;temphigh&quot;: &quot;36&quot;,//最高气温
&quot;winddirect&quot;: &quot;南风&quot;,//风向
&quot;sunset&quot;: &quot;18:33&quot;,//日落时间
&quot;weather&quot;: &quot;晴&quot;,//天气
&quot;aqi&quot;: &quot;35&quot;,//AQI指数
&quot;humidity&quot;: &quot;80&quot;,//湿度
&quot;windspeed&quot;: &quot;2.1&quot;//风速
}
}</code></pre>
<h3>失败返回样例</h3>
<pre><code class="language-json">{
&quot;msg&quot;: &quot;城市不能为空&quot;,
&quot;code&quot;: 400
}</code></pre>
<h3>返回字段说明</h3>
<table>
<thead>
<tr>
<th>字段名</th>
<th><div style="width:400px">说明</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>是否计费</td>
</tr>
<tr>
<td>taskNo</td>
<td>本次请求号</td>
</tr>
<tr>
<td>data</td>
<td>返回具体结果,详见成功返回样例</td>
</tr>
</tbody>
</table>
<h4>code返回码说明</h4>
<table>
<thead>
<tr>
<th>code</th>
<th><div style="width:400px">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>200</td>
<td>成功(计费)</td>
</tr>
<tr>
<td>201</td>
<td>查无数据</td>
</tr>
<tr>
<td>202</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>603</td>
<td>余额不足请充值</td>
</tr>
<tr>
<td>604</td>
<td>接口停用</td>
</tr>
<tr>
<td>607</td>
<td>ip不在白名单</td>
</tr>
<tr>
<td>609</td>
<td>请求过于频繁,请稍候再试</td>
</tr>
<tr>
<td>999</td>
<td>其他,以实际返回为准</td>
</tr>
</tbody>
</table>