功能介绍
提供全国火车票车次查询, 站到站查询接口。
比如您查询"济南"到"北京", 接口会返回所有济南到北京的列车, 慢车、动车、高铁都会有, 但是不会出现票价, 适合做出行规划。
API文档在线测试此接口
该接口同时支持HTTP和HTTPS, 并且允许跨域请求
请求方式及url:
请求方式:
GET
接口地址:(建议在服务端设置线路地址为动态可修改的)
http://apia.yikeapi.com/train/
请求示例
http://apia.yikeapi.com/train/?start_station=烟台&stop_station=青岛&appid=&appsecret=
请求参数说明:
参数名 | 必选 | 类型 | 说明 | 备注(示例) |
---|---|---|---|---|
appid | 是 | string | 用户appid | 注册开发账号 |
appsecret | 是 | string | 用户appsecret | |
start_station | 是 | string | 出发站 |
示例: 烟台
|
stop_station | 是 | string | 终点站 |
示例: 青岛
|
callback | 否 | string | jsonp参数 | 如: jQuery.Callbacks |
vue | 否 | string | 跨域参数 | 如果您使用的是react、vue、angular请填写值: 1 |
相关接口
响应JSON
{
"errcode":0,
"errmsg":"success",
"api":"yikeapi.com",
"usetime":0.10343503952026367,
"list":[
{
"train_id":"16019",//列车编号,根据此编号查询列车详情
"station_train_code":"C6520",//列车名称
"train_from_station":"烟台",//列车始发站
"train_to_station":"青岛",//列车终点站
"from_station":"烟台",//出发站
"to_station":"青岛",//到达站
"start_time_unix":1642544460,
"start_time":"06:21",//出发时间
"stop_time":"08:12",//到达时间
"day_diff":0//是否跨日, 0:否 1是
},
{
"train_id":"9861",
"station_train_code":"D2926",
"train_from_station":"荣成",
"train_to_station":"上海虹桥",
"from_station":"烟台南",
"to_station":"青岛西",
"start_time_unix":1642546560,
"start_time":"06:56",
"stop_time":"08:53",
"day_diff":0
},
{
"train_id":"8173",
"station_train_code":"D2138",
"train_from_station":"烟台",
"train_to_station":"上海虹桥",
"from_station":"烟台",
"to_station":"青岛西",
"start_time_unix":1642548840,
"start_time":"07:34",
"stop_time":"09:41",
"day_diff":0
},
{
"train_id":"21837",
"station_train_code":"C6552",
"train_from_station":"荣成",
"train_to_station":"青岛北",
"from_station":"烟台南",
"to_station":"青岛北",
"start_time_unix":1642549080,
"start_time":"07:38",
"stop_time":"08:40",
"day_diff":0
},
{
"train_id":"3346",
"station_train_code":"G5588",
"train_from_station":"威海",
"train_to_station":"曲阜东",
"from_station":"烟台南",
"to_station":"青岛北",
"start_time_unix":1642551960,
"start_time":"08:26",
"stop_time":"09:44",
"day_diff":0
},
{
"train_id":"4535",
"station_train_code":"G1850",
"train_from_station":"烟台",
"train_to_station":"长沙南",
"from_station":"烟台",
"to_station":"青岛西",
"start_time_unix":1642556640,
"start_time":"09:44",
"stop_time":"11:35",
"day_diff":0
},
{
"train_id":"4880",
"station_train_code":"G2684",
"train_from_station":"威海",
"train_to_station":"兰州西",
"from_station":"烟台南",
"to_station":"青岛西",
"start_time_unix":1642558560,
"start_time":"10:16",
"stop_time":"11:57",
"day_diff":0
},
{
"train_id":"20773",
"station_train_code":"C6546",
"train_from_station":"烟台",
"train_to_station":"青岛北",
"from_station":"烟台",
"to_station":"青岛北",
"start_time_unix":1642558560,
"start_time":"10:16",
"stop_time":"11:23",
"day_diff":0
},
{
"train_id":"8746",
"station_train_code":"D6050",
"train_from_station":"烟台",
"train_to_station":"青岛北",
"from_station":"烟台",
"to_station":"青岛北",
"start_time_unix":1642559520,
"start_time":"10:32",
"stop_time":"11:40",
"day_diff":0
},
{
"train_id":"21440",
"station_train_code":"C6508",
"train_from_station":"荣成",
"train_to_station":"青岛",
"from_station":"烟台南",
"to_station":"青岛",
"start_time_unix":1642571760,
"start_time":"13:56",
"stop_time":"15:40",
"day_diff":0
},
{
"train_id":"20506",
"station_train_code":"C6544",
"train_from_station":"威海",
"train_to_station":"青岛",
"from_station":"烟台南",
"to_station":"青岛",
"start_time_unix":1642573680,
"start_time":"14:28",
"stop_time":"15:50",
"day_diff":0
},
{
"train_id":"8744",
"station_train_code":"D6046",
"train_from_station":"烟台",
"train_to_station":"青岛",
"from_station":"烟台",
"to_station":"青岛",
"start_time_unix":1642573980,
"start_time":"14:33",
"stop_time":"16:29",
"day_diff":0
},
{
"train_id":"3344",
"station_train_code":"G5584",
"train_from_station":"威海",
"train_to_station":"曲阜东",
"from_station":"烟台南",
"to_station":"青岛西",
"start_time_unix":1642575600,
"start_time":"15:00",
"stop_time":"16:39",
"day_diff":0
},
{
"train_id":"9863",
"station_train_code":"D2930",
"train_from_station":"威海",
"train_to_station":"上海虹桥",
"from_station":"烟台南",
"to_station":"青岛西",
"start_time_unix":1642577340,
"start_time":"15:29",
"stop_time":"17:06",
"day_diff":0
},
{
"train_id":"3348",
"station_train_code":"G5592",
"train_from_station":"烟台",
"train_to_station":"菏泽东",
"from_station":"烟台",
"to_station":"青岛西",
"start_time_unix":1642577760,
"start_time":"15:36",
"stop_time":"17:18",
"day_diff":0
},
{
"train_id":"21438",
"station_train_code":"C6504",
"train_from_station":"荣成",
"train_to_station":"青岛",
"from_station":"烟台南",
"to_station":"青岛",
"start_time_unix":1642585080,
"start_time":"17:38",
"stop_time":"19:17",
"day_diff":0
},
{
"train_id":"23007",
"station_train_code":"C6582",
"train_from_station":"威海",
"train_to_station":"青岛北",
"from_station":"烟台南",
"to_station":"青岛北",
"start_time_unix":1642586160,
"start_time":"17:56",
"stop_time":"18:58",
"day_diff":0
},
{
"train_id":"23009",
"station_train_code":"C6588",
"train_from_station":"威海",
"train_to_station":"青岛",
"from_station":"烟台南",
"to_station":"青岛",
"start_time_unix":1642586940,
"start_time":"18:09",
"stop_time":"20:01",
"day_diff":0
},
{
"train_id":"8768",
"station_train_code":"D6092",
"train_from_station":"烟台",
"train_to_station":"青岛北",
"from_station":"烟台",
"to_station":"青岛北",
"start_time_unix":1642589280,
"start_time":"18:48",
"stop_time":"20:00",
"day_diff":0
},
{
"train_id":"22804",
"station_train_code":"C6578",
"train_from_station":"烟台",
"train_to_station":"青岛北",
"from_station":"烟台",
"to_station":"青岛北",
"start_time_unix":1642592040,
"start_time":"19:34",
"stop_time":"20:54",
"day_diff":0
},
{
"train_id":"23945",
"station_train_code":"C662",
"train_from_station":"龙口市",
"train_to_station":"青岛",
"from_station":"烟台",
"to_station":"青岛",
"start_time_unix":1642593240,
"start_time":"19:54",
"stop_time":"22:11",
"day_diff":0
}
]
}
示例代码
$ curl "http://apia.yikeapi.com/train/?start_station=烟台&stop_station=青岛&appid=&appsecret="
错误码参考
字段 | 错误码 | 说明 |
---|---|---|
errcode | 100 | 参考错误 |
errcode | 50002 | 接口测试次数已用完 |
errcode | 50001 | 套参包已用完 |
{ "errcode":100, "errmsg":"缺少注册参数appid或appsecret" }