;
首页 接口文档 火车票

火车票

火车票模块在提供余票查询、经停站查询等API数据查询服务同时,亦向开发者提供了预订下单、支付出票、退票、改签等API预订服务。从而帮助开发者在自己的平台上完成从查询到预订到退改一条龙服务(PS:API预订服务是作为增值服务提供给开发者,非必选接入项,开发者有自己的出票渠道亦可使用自己的)。

http://接口域名/train/queryLeftTicket
json
get/post
http://接口域名/train/queryLeftTicket?appKey=您申请的APPKEY&fromStation=苏州&toStation=昆山&fromDate=2023-12-15

请求参数:

参数名称 类型 必填 说明
fromStation string 出发火车站名称
toStation string 到达火车站名称
fromDate date 出发日期

返回参数:

参数名称 类型 说明
trainLines trainLine[] 查询到的车次列表,空表示没有满足查询条件的的列车
trainCode string 车次,如 K257
trainNo string 车次12306官方内部编号,如:250000K25724 (【查询经停站V2】接口中需要用到)
fromStation string 出发火车站名称
toStation string 到达火车站名称
fromTime string 出发时间(格式:HH:mm)
toTime string 到达时间(格式:HH:mm)
fromDateTime string 出发日期时间(格式:yyyy-MM-dd HH:mm)
toDateTime string 到达日期时间(格式:yyyy-MM-dd HH:mm)
arrive_days string 列车从出发站到达目的站的运行天数(0:当日到达,1:次日到达,2:三日到达,3:四日到达,依此类推)
runTime string 历时时间,格式HH:mm,如10:40表示历时10小时40分钟
trainsType int 车次类型(高铁 = 1, 动车 = 2,直达 = 3,特快 = 4,快速 = 5,其他 = 6)
trainsTypeName string 车次类型名称(和trainsType对应)
beginStation string 始发站(可选)
beginTime string 始发时间(格式:HH:mm)
endStation string 终点站
endTime string 终点时间(格式:HH:mm)
isSupportChooseSleeper bool 是否支持 选铺服务(如剩余铺位无法满足您的需求,系统将自动为您分配),PS:不是所有卧铺12306都支持 选铺服务的。硬卧和二等卧 分上、中、下三个铺位;软卧、一等卧、动卧 、高级动卧 分上、下两个铺位
isSupportChooseSeat bool 是否支持选座,目前仅支持高铁、动车类型的车次选座,具体以12306返回为准
Seats SeatInfo[] 席别信息
seatType int 席别类型(商务座 = 1,特等座 = 2,一等座 = 3,二等座 = 4,高级软卧 = 5,软卧 = 6,动卧 = 7 ,硬卧 = 8,软座 = 9,硬座 = 10,一等卧 = 11,二等卧 = 12,高级动卧 = 13, 一等软座 = 14 , 二等软座 = 15, 特等软座 = 16, 包厢硬卧 = 17, 一人软包 = 18, 多功能座 = 19, 无座 =98,其他 = 99)
seatTypeName string 席别名称(和seatType对应)
ticketPrice float 票价
leftTicketNum int 票数
otherSeats SleeperSeatInfo[] 上中下卧铺价格,当seatType为卧铺类型时(如:硬卧、软卧、高级软卧等),才有值。
sleeperType int 铺别类型( 下铺 = 1 , 中铺 = 2 , 上铺 = 3 )
sleeperTypeName string 铺别名称
ticketPrice float 票价

JSON返回示例 :

{
  "data": {
    "trainLines": [
      {
        "trainCode": "K289",
        "trainNo": "760000K2920K",
        "fromStation": "苏州",
        "toStation": "昆山",
        "fromTime": "04:30",
        "toTime": "04:54",
        "fromDateTime": "2023-12-15 04:30",
        "toDateTime": "2023-12-15 04:54",
        "arrive_days": "0",
        "runTime": "00:24",
        "trainsType": 5,
        "trainsTypeName": "快速",
        "beginStation": "成都西",
        "beginTime": null,
        "endStation": "昆山",
        "endTime": null,
        "isSupportChooseSleeper": true,
        "note": "",
        "transferQueryExtraParams": null,
        "sequence": 0,
        "Seats": [
          {
            "seatType": 98,
            "seatTypeName": "无座",
            "ticketPrice": 9.0,
            "leftTicketNum": 0,
            "otherSeats": null
          },
          {
            "seatType": 10,
            "seatTypeName": "硬座",
            "ticketPrice": 9.0,
            "leftTicketNum": 183,
            "otherSeats": null
          },
          {
            "seatType": 8,
            "seatTypeName": "硬卧",
            "ticketPrice": 55.0,
            "leftTicketNum": 108,
            "otherSeats": [
              {
                "sleeperType": 3,
                "sleeperTypeName": "上铺",
                "ticketPrice": 55.0
              },
              {
                "sleeperType": 2,
                "sleeperTypeName": "中铺",
                "ticketPrice": 60.0
              },
              {
                "sleeperType": 1,
                "sleeperTypeName": "下铺",
                "ticketPrice": 63.0
              }
            ]
          },
          {
            "seatType": 6,
            "seatTypeName": "软卧",
            "ticketPrice": 81.5,
            "leftTicketNum": 4,
            "otherSeats": [
              {
                "sleeperType": 3,
                "sleeperTypeName": "上铺",
                "ticketPrice": 81.5
              },
              {
                "sleeperType": 1,
                "sleeperTypeName": "下铺",
                "ticketPrice": 87.5
              }
            ]
          }
        ]
      },
      {
        "trainCode": "G8293",
        "trainNo": "5f000G829601",
        "fromStation": "苏州",
        "toStation": "昆山南",
        "fromTime": "22:20",
        "toTime": "22:33",
        "fromDateTime": "2023-12-15 22:20",
        "toDateTime": "2023-12-15 22:33",
        "arrive_days": "0",
        "runTime": "00:13",
        "trainsType": 1,
        "trainsTypeName": "高铁",
        "beginStation": "盐城",
        "beginTime": null,
        "endStation": "上海",
        "endTime": null,
        "isSupportChooseSleeper": false,
        "note": "",
        "transferQueryExtraParams": null,
        "sequence": 0,
        "Seats": [
          {
            "seatType": 98,
            "seatTypeName": "无座",
            "ticketPrice": 14.0,
            "leftTicketNum": 0,
            "otherSeats": null
          },
          {
            "seatType": 4,
            "seatTypeName": "二等座",
            "ticketPrice": 14.0,
            "leftTicketNum": 186,
            "otherSeats": null
          },
          {
            "seatType": 3,
            "seatTypeName": "一等座",
            "ticketPrice": 23.0,
            "leftTicketNum": 0,
            "otherSeats": null
          },
          {
            "seatType": 1,
            "seatTypeName": "商务座",
            "ticketPrice": 49.0,
            "leftTicketNum": 0,
            "otherSeats": null
          }
        ]
      }
    ]
  },
  "success": true,
  "msg": "请求成功"
}