火车查询
<p>[TOC]</p>
<h3>简介</h3>
<ul>
<li>查询火车票时刻、余票、过站停留等信息。</li>
</ul>
<h3>接口调用说明</h3>
<h4>请求方式</h4>
<p>如接口没有单独说明,所有接口均为:<strong>POST</strong></p>
<h4>请求格式</h4>
<p>如接口没有单独说明,所有接口均为:<strong>application/form-data</strong></p>
<h4>请求参数</h4>
<p>请求参数均包括公共参数和业务参数(业务参数见具体接口说明)
如接口没有单独说明,所有接口调用时,均需要把<strong>公共参数</strong>和<strong>业务参数</strong>一并放在<strong>请求参数</strong>中提交</p>
<p><a name="公共请求参数"></a></p>
<h5>公共请求参数</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>签名,详见签名算法说明</td>
</tr>
</tbody>
</table>
<h5>签名算法说明</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>返回说明</h4>
<h5>返回字段说明</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>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>603</td>
<td>余额不足请充值</td>
</tr>
<tr>
<td>604</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>火车票查询</h3>
<ul>
<li>根据出发站和到达站,查询火车票信息。</li>
</ul>
<h3>请求地址</h3>
<p><code>https://api.jumdata.com/train-query/ticket</code></p>
<h3>业务参数</h3>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th><div style="width:400px">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>start</td>
<td>String</td>
<td>是</td>
<td>出发站,如:杭州东</td>
</tr>
<tr>
<td>end</td>
<td>String</td>
<td>是</td>
<td>到达站,如:上海南</td>
</tr>
<tr>
<td>ishigh</td>
<td>String</td>
<td>否</td>
<td>是否高铁,0:不是,1:是</td>
</tr>
<tr>
<td>date</td>
<td>String</td>
<td>否</td>
<td>日期,格式yyyy-MM-dd。默认为当天</td>
</tr>
</tbody>
</table>
<p>公共请求参数请参阅:<a href="#公共请求参数">公共请求参数</a></p>
<h3>成功返回样例</h3>
<pre><code class="language-json">{
&quot;code&quot;: 200,//返回码,详见返回码说明
&quot;msg&quot;: &quot;成功&quot;,//返回码对应描述
&quot;charge&quot;: true,//计费标志
&quot;taskNo&quot;: &quot;040056972246718444474454&quot;,//本次请求号
&quot;data&quot;: {
&quot;date&quot;: &quot;2025-07-25&quot;,//日期
&quot;start&quot;: &quot;杭州东&quot;,//出发站
&quot;end&quot;: &quot;上海南&quot;,//查询到达站
&quot;list&quot;: [
{
&quot;terminalstation_code&quot;: &quot;IMH&quot;,//到达站code,可用于查询过站停留信息
&quot;is_start&quot;: &quot;过&quot;,//是否始发[始/过]
&quot;costtime&quot;: &quot;01时51分&quot;,//用时
&quot;terminalstation&quot;: &quot;上海松江&quot;,//到达站
&quot;departstation_code&quot;: &quot;XHH&quot;,//出发站code,可用于查询过站停留信息
&quot;is_end&quot;: &quot;过&quot;,//是否终点[过/终]
&quot;trainno&quot;: &quot;K528&quot;,//车次
&quot;type&quot;: &quot;快速&quot;,//类型
&quot;departuretime&quot;: &quot;01:55&quot;,//出发时间
&quot;sequenceno&quot;: 1,//顺序
&quot;departstation&quot;: &quot;杭州南&quot;,//出发站
&quot;trainno_uuid&quot;: &quot;650000K52805&quot;,//车次uuid
&quot;station&quot;: &quot;广州白云&quot;,//始发站
&quot;arrivaltime&quot;: &quot;03:46&quot;,//到达时间
&quot;endstation&quot;: &quot;南京&quot;,//终点站
&quot;yz&quot;: {//硬座
&quot;price&quot;: &quot;24.0&quot;,//票价(--:无席位)
&quot;num&quot;: &quot;有&quot; //余票(有:充足,无:无票,--:无席位)
},
&quot;wz&quot;: {//无座
&quot;price&quot;: &quot;24.0&quot;,
&quot;num&quot;: &quot;有&quot;
},
&quot;rw&quot;: {//软卧
&quot;size&quot;: {
&quot;xp_price&quot;: 114.5,
&quot;sp_price&quot;: 108.5
},
&quot;price&quot;: &quot;108.0&quot;,
&quot;num&quot;: &quot;1&quot;
},
&quot;ze&quot;: {//二等座
&quot;price&quot;: &quot;--&quot;,
&quot;num&quot;: &quot;--&quot;
},
&quot;swz&quot;: {//商务座
&quot;price&quot;: &quot;--&quot;,
&quot;num&quot;: &quot;--&quot;
},
&quot;yw&quot;: {//硬卧
&quot;size&quot;: {
&quot;xp_price&quot;: 78.5,
&quot;zp_price&quot;: 75.5,
&quot;sp_price&quot;: 70.5
},
&quot;price&quot;: &quot;70.0&quot;,
&quot;num&quot;: &quot;8&quot;
},
&quot;zy&quot;: {//一等座
&quot;price&quot;: &quot;--&quot;,
&quot;num&quot;: &quot;--&quot;
}
}
]
}
}
</code></pre>
<h3>失败返回样例</h3>
<pre><code class="language-json">{
&quot;code&quot;: 400,//返回码,详见返回码说明
&quot;msg&quot;: &quot;出发站不能为空&quot;//返回码对应描述
}</code></pre>
<hr />
<h3>过站停留信息查询</h3>
<ul>
<li>查询车辆过站停留信息。</li>
</ul>
<h3>请求地址</h3>
<p><code>https://api.jumdata.com/train-query/station</code></p>
<h3>业务参数</h3>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th><div style="width:400px">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>trainnoUuid</td>
<td>String</td>
<td>是</td>
<td>车次uuid,火车票查询接口返回</td>
</tr>
<tr>
<td>departstationCode</td>
<td>String</td>
<td>是</td>
<td>出发站Code,火车票查询接口返回</td>
</tr>
<tr>
<td>terminalstationCode</td>
<td>String</td>
<td>是</td>
<td>到达站Code,火车票查询接口返回</td>
</tr>
<tr>
<td>date</td>
<td>String</td>
<td>是</td>
<td>乘车日期,格式yyyy-MM-dd</td>
</tr>
</tbody>
</table>
<p>公共请求参数请参阅:<a href="#公共请求参数">公共请求参数</a></p>
<h3>成功返回样例</h3>
<pre><code class="language-json">{
&quot;code&quot;: 200,//返回码,详见返回码说明
&quot;msg&quot;: &quot;成功&quot;,//返回码对应描述
&quot;charge&quot;: true,//计费标志
&quot;taskNo&quot;: &quot;040056972246718444474454&quot;,//本次请求号
&quot;data&quot;: {
&quot;train_class_name&quot;: &quot;快速&quot;,//火车类型
&quot;start_station_name&quot;: &quot;昆明&quot;,//始发站名称
&quot;service_type&quot;: &quot;有空调&quot;,//服务内容
&quot;station_train_code&quot;: &quot;K80&quot;,//车次代码
&quot;end_station_name&quot;: &quot;上海松江&quot;,//终点站名称
&quot;list&quot;: [
{
&quot;station_name&quot;: &quot;昆明&quot;,//到站站点名称
&quot;isChina&quot;: &quot;1&quot;,//是否国内站
&quot;start_time&quot;: &quot;18:45&quot;,//出发时间
&quot;isEnabled&quot;: false,//是否启用(到达站范围内)
&quot;station_no&quot;: &quot;01&quot;,//站序
&quot;stopover_time&quot;: &quot;----&quot;,//站内停留时间
&quot;arrive_time&quot;: &quot;----&quot; //到站时间
},
{
&quot;station_name&quot;: &quot;上海松江&quot;,
&quot;isChina&quot;: &quot;1&quot;,
&quot;start_time&quot;: &quot;04:50&quot;,
&quot;isEnabled&quot;: true,
&quot;station_no&quot;: &quot;27&quot;,
&quot;stopover_time&quot;: &quot;----&quot;,
&quot;arrive_time&quot;: &quot;04:50&quot;
}
]
}
}
</code></pre>
<h3>失败返回样例</h3>
<pre><code class="language-json">{
&quot;msg&quot;: &quot;车次uuid不能为空&quot;,
&quot;code&quot;: 400
}</code></pre>