途牛火车票API

途牛火车票查询

url: http://huoche.tuniu.com/station_1708_2500

请求方式:GET

请求参数:

  • r:固定取值 train/trainTicket/getTickets

  • primary[departureDate]:发车日期,yyyy-MM-dd 格式,例如:2017-02-06

  • primary[departureCityCode]:出发站码,请参考途牛站码 json

  • primary[departureCityName]:出发站名,请参考途牛站码 json

  • primary[arrivalCityCode]:到达站码,请参考途牛站码 json

  • primary[arrivalCityName]:到达站名,请参考途牛站码 json

  • start:起始值,默认 0

  • limit:数量,默认 0

ps:startlimit 是分页相关的值,如果都是默认取0的话则返回所有的信息

url 示例:http://huoche.tuniu.com/yii.php?r=train/trainTicket/getTickets&primary%5BdepartureDate%5D=2017-02-23&primary%5BdepartureCityCode%5D=200&primary%5BdepartureCityName%5D=%E5%8C%97%E4%BA%AC&primary%5BarrivalCityCode%5D=2500&primary%5BarrivalCityName%5D=%E4%B8%8A%E6%B5%B7&start=0&limit=0北京上海2017年02月13日前十辆火车信息,start0limit5

json 示例:

{
  "code": 200,
  "data": {
    "count": 5,
    "stores": null,
    "trainTypeDetails": [
      {
        "trainType": 0,
        "number": 36,
        "trainTypeName": "G-高铁"
      },
      {
        "trainType": 6,
        "number": 1,
        "trainTypeName": "其它"
      },
      {
        "trainType": 4,
        "number": 1,
        "trainTypeName": "T-特快"
      },
      {
        "trainType": 2,
        "number": 3,
        "trainTypeName": "D-动车"
      }
    ],
    "streamId": null,
    "remark": null,
    "isFinish": null,
    "lastTime": 0,
    "expire": false,
    "freshUrl": null,
    "reserveUrls": null,
    "crossURL": null,
    "list": [
      {
        "trainId": 16101,
        "trainNum": "G101",
        "trainType": 0,
        "trainTypeName": "高铁",
        "departStationName": "北京南站",
        "destStationName": "上海虹桥站",
        "departDepartTime": "06:44",
        "destArriveTime": "12:38",
        "duration": 354,
        "prices": [
          {
            "leftNumber": 99,
            "seatStatus": "有",
            "seat": 0,
            "price": 1748,
            "stuPrice": null,
            "promotionPrice": 1748,
            "resId": 354865547,
            "detail": [],
            "priceMemo": null,
            "seatName": "商务座"
          },
          {
            "leftNumber": 99,
            "seatStatus": "有",
            "seat": 2,
            "price": 933,
            "stuPrice": null,
            "promotionPrice": 933,
            "resId": 354865549,
            "detail": [],
            "priceMemo": null,
            "seatName": "一等座"
          },
          {
            "leftNumber": 99,
            "seatStatus": "有",
            "seat": 3,
            "price": 553,
            "stuPrice": null,
            "promotionPrice": 553,
            "resId": 354865551,
            "detail": [],
            "priceMemo": null,
            "seatName": "二等座"
          }
        ],
        "durationDay": 1,
        "departStationType": 0,
        "destStationType": 1,
        "saleStatus": 0,
        "departStationId": 1175341,
        "destStationId": 1175076,
        "startSaleTime": "",
        "canChooseSeat": 0,
        "memo": "",
        "departureCityCode": 200,
        "arrivalCityCode": 2500,
        "departureCityName": "北京",
        "arrivalCityName": "上海",
        "upOrDown": 0,
        "trainStartDate": null,
        "durationStr": "5小时54分钟",
        "departStationTypeName": "ticketbtn",
        "destStationTypeName": "ticketbtn",
        "sellOut": 0
      },
      {
        "trainId": 165,
        "trainNum": "G5",
        "trainType": 0,
        "trainTypeName": "高铁",
        "departStationName": "北京南站",
        "destStationName": "上海虹桥站",
        "departDepartTime": "07:00",
        "destArriveTime": "11:55",
        "duration": 295,
        "prices": [
          {
            "leftNumber": 10,
            "seatStatus": "",
            "seat": 0,
            "price": 1748,
            "stuPrice": null,
            "promotionPrice": 1748,
            "resId": 1507056962,
            "detail": [],
            "priceMemo": null,
            "seatName": "商务座"
          },
          {
            "leftNumber": 99,
            "seatStatus": "有",
            "seat": 2,
            "price": 933,
            "stuPrice": null,
            "promotionPrice": 933,
            "resId": 1507056963,
            "detail": [],
            "priceMemo": null,
            "seatName": "一等座"
          },
          {
            "leftNumber": 99,
            "seatStatus": "有",
            "seat": 3,
            "price": 553,
            "stuPrice": null,
            "promotionPrice": 553,
            "resId": 1507056964,
            "detail": [],
            "priceMemo": null,
            "seatName": "二等座"
          }
        ],
        "durationDay": 1,
        "departStationType": 0,
        "destStationType": 1,
        "saleStatus": 0,
        "departStationId": 1175341,
        "destStationId": 1175076,
        "startSaleTime": "",
        "canChooseSeat": 0,
        "memo": "",
        "departureCityCode": 200,
        "arrivalCityCode": 2500,
        "departureCityName": "北京",
        "arrivalCityName": "上海",
        "upOrDown": 0,
        "trainStartDate": null,
        "durationStr": "4小时55分钟",
        "departStationTypeName": "ticketbtn",
        "destStationTypeName": "ticketbtn",
        "sellOut": 0
      },
      {
        "trainId": 16105,
        "trainNum": "G105",
        "trainType": 0,
        "trainTypeName": "高铁",
        "departStationName": "北京南站",
        "destStationName": "上海虹桥站",
        "departDepartTime": "07:35",
        "destArriveTime": "13:15",
        "duration": 340,
        "prices": [
          {
            "leftNumber": 14,
            "seatStatus": "",
            "seat": 0,
            "price": 1748,
            "stuPrice": null,
            "promotionPrice": 1748,
            "resId": 354865684,
            "detail": [],
            "priceMemo": null,
            "seatName": "商务座"
          },
          {
            "leftNumber": 99,
            "seatStatus": "有",
            "seat": 2,
            "price": 933,
            "stuPrice": null,
            "promotionPrice": 933,
            "resId": 354865687,
            "detail": [],
            "priceMemo": null,
            "seatName": "一等座"
          },
          {
            "leftNumber": 99,
            "seatStatus": "有",
            "seat": 3,
            "price": 553,
            "stuPrice": null,
            "promotionPrice": 553,
            "resId": 354865690,
            "detail": [],
            "priceMemo": null,
            "seatName": "二等座"
          }
        ],
        "durationDay": 1,
        "departStationType": 0,
        "destStationType": 1,
        "saleStatus": 0,
        "departStationId": 1175341,
        "destStationId": 1175076,
        "startSaleTime": "",
        "canChooseSeat": 0,
        "memo": "",
        "departureCityCode": 200,
        "arrivalCityCode": 2500,
        "departureCityName": "北京",
        "arrivalCityName": "上海",
        "upOrDown": 0,
        "trainStartDate": null,
        "durationStr": "5小时40分钟",
        "departStationTypeName": "ticketbtn",
        "destStationTypeName": "ticketbtn",
        "sellOut": 0
      },
      {
        "trainId": 1611,
        "trainNum": "G11",
        "trainType": 0,
        "trainTypeName": "高铁",
        "departStationName": "北京南站",
        "destStationName": "上海虹桥站",
        "departDepartTime": "08:00",
        "destArriveTime": "13:10",
        "duration": 310,
        "prices": [
          {
            "leftNumber": 99,
            "seatStatus": "有",
            "seat": 0,
            "price": 1748,
            "stuPrice": null,
            "promotionPrice": 1748,
            "resId": 354865337,
            "detail": [],
            "priceMemo": null,
            "seatName": "商务座"
          },
          {
            "leftNumber": 99,
            "seatStatus": "有",
            "seat": 2,
            "price": 933,
            "stuPrice": null,
            "promotionPrice": 933,
            "resId": 354865338,
            "detail": [],
            "priceMemo": null,
            "seatName": "一等座"
          },
          {
            "leftNumber": 99,
            "seatStatus": "有",
            "seat": 3,
            "price": 553,
            "stuPrice": null,
            "promotionPrice": 553,
            "resId": 354865339,
            "detail": [],
            "priceMemo": null,
            "seatName": "二等座"
          }
        ],
        "durationDay": 1,
        "departStationType": 0,
        "destStationType": 1,
        "saleStatus": 0,
        "departStationId": 1175341,
        "destStationId": 1175076,
        "startSaleTime": "",
        "canChooseSeat": 0,
        "memo": "",
        "departureCityCode": 200,
        "arrivalCityCode": 2500,
        "departureCityName": "北京",
        "arrivalCityName": "上海",
        "upOrDown": 0,
        "trainStartDate": null,
        "durationStr": "5小时10分钟",
        "departStationTypeName": "ticketbtn",
        "destStationTypeName": "ticketbtn",
        "sellOut": 0
      },
      {
        "trainId": 16107,
        "trainNum": "G107",
        "trainType": 0,
        "trainTypeName": "高铁",
        "departStationName": "北京南站",
        "destStationName": "上海虹桥站",
        "departDepartTime": "08:05",
        "destArriveTime": "13:38",
        "duration": 333,
        "prices": [
          {
            "leftNumber": 13,
            "seatStatus": "",
            "seat": 0,
            "price": 1748,
            "stuPrice": null,
            "promotionPrice": 1748,
            "resId": 354865873,
            "detail": [],
            "priceMemo": null,
            "seatName": "商务座"
          },
          {
            "leftNumber": 99,
            "seatStatus": "有",
            "seat": 2,
            "price": 933,
            "stuPrice": null,
            "promotionPrice": 933,
            "resId": 354865874,
            "detail": [],
            "priceMemo": null,
            "seatName": "一等座"
          },
          {
            "leftNumber": 99,
            "seatStatus": "有",
            "seat": 3,
            "price": 553,
            "stuPrice": null,
            "promotionPrice": 553,
            "resId": 354865875,
            "detail": [],
            "priceMemo": null,
            "seatName": "二等座"
          }
        ],
        "durationDay": 1,
        "departStationType": 0,
        "destStationType": 1,
        "saleStatus": 0,
        "departStationId": 1175341,
        "destStationId": 1175076,
        "startSaleTime": "",
        "canChooseSeat": 0,
        "memo": "",
        "departureCityCode": 200,
        "arrivalCityCode": 2500,
        "departureCityName": "北京",
        "arrivalCityName": "上海",
        "upOrDown": 0,
        "trainStartDate": null,
        "durationStr": "5小时33分钟",
        "departStationTypeName": "ticketbtn",
        "destStationTypeName": "ticketbtn",
        "sellOut": 0
      }
    ],
    "allTrainType": {
      "list": [
        {
          "trainType": 0,
          "trainTypeName": "G-高铁",
          "trainTypeCode": "G",
          "link": "http://huoche.tuniu.com/station_200_2500/G"
        }
      ],
      "departureCityName": "北京",
      "arrivalCityName": "上海"
    },
    "filter": {
      "filter": [
        {
          "id": "trainTypes",
          "name": "车型",
          "pros": [
            {
              "id": 0,
              "name": "G-高铁"
            },
            {
              "id": 2,
              "name": "D-动车"
            },
            {
              "id": 4,
              "name": "T-特快"
            },
            {
              "id": 6,
              "name": "其它"
            }
          ]
        },
        {
          "id": "seats",
          "name": "座席",
          "pros": [
            {
              "id": 0,
              "name": "商务座"
            },
            {
              "id": 2,
              "name": "一等座"
            },
            {
              "id": 3,
              "name": "二等座"
            },
            {
              "id": 4,
              "name": "高级软卧"
            },
            {
              "id": 5,
              "name": "软卧"
            },
            {
              "id": 6,
              "name": "硬卧"
            },
            {
              "id": 8,
              "name": "硬座"
            }
          ]
        },
        {
          "id": "departureStations",
          "name": "出发车站",
          "pros": [
            {
              "name": "北京南站",
              "id": 1175341
            },
            {
              "name": "北京站",
              "id": 1175342
            }
          ]
        },
        {
          "id": "arrivalStations",
          "name": "到达车站",
          "pros": [
            {
              "name": "上海站",
              "id": 1175075
            },
            {
              "name": "上海虹桥站",
              "id": 1175076
            }
          ]
        },
        {
          "id": "departureTimes",
          "name": "出发时段",
          "pros": [
            {
              "id": "6-12",
              "name": "6-12点"
            },
            {
              "id": "12-18",
              "name": "12-18点"
            },
            {
              "id": "18-24",
              "name": "18-24点"
            }
          ]
        },
        {
          "id": "arrivalTimes",
          "name": "到达时段",
          "pros": [
            {
              "id": "6-12",
              "name": "6-12点"
            },
            {
              "id": "12-18",
              "name": "12-18点"
            },
            {
              "id": "18-24",
              "name": "18-24点"
            }
          ]
        },
        {
          "id": "departStationTypes",
          "name": "是否始发",
          "pros": [
            {
              "id": 0,
              "name": "始发"
            }
          ]
        }
      ],
      "sort": [
        {
          "type": 2,
          "id": 1,
          "name": "出发时间"
        },
        {
          "type": 2,
          "id": 3,
          "name": "运行时间"
        },
        {
          "type": 2,
          "id": 2,
          "name": "到达时间"
        },
        {
          "type": 2,
          "id": 4,
          "name": "价格"
        }
      ]
    }
  }
}

解析:

  • trainTypeDetails:车辆类型信息
  • trainType:车辆类型码
  • number:该类车辆数量
  • trainTypeName:车辆类型码对应信息
  • trainId:车辆 id
  • trainNum:车辆车次号
  • departStationName:出发站
  • destStationName:到达站
  • departDepartTime:发车时间
  • destArriveTime:到达时间
  • duration:历时(以分钟为单位)
  • price:座位价格信息
  • leftNumber:剩余票量(99是表示票量充足)
  • seatStatus或为空,票量充足情况下为,反之为空
  • stuPrice:学生价,但是途牛网好像一直获取为 null
  • resId:座位对应 id
  • detail:座位具体细节
  • seat:座位类型码
  • price:价格
  • promotionPrice:折扣价
  • seatName:座位类型
  • durationDay:历时天数
  • departStationType:???
  • destStationType:???
  • saleStatus:???
  • departStationId:出发车站 id
  • destStationId:到达车站 id
  • startSaleTime:售票时间
  • canChooseSeat:是否可以选择座位,0表示不可以
  • departureCityCode:出发站城市码
  • arrivalCityCode:到达站城市码
  • departureCityName:出发站城市
  • arrivalCityName:到达站城市
  • trainStartDate:???
  • durationStr:耗时
  • sellOut:是否售罄,0表没有售罄
  • filter:过滤信息
  • id:过滤参数名
  • name:名称
  • pros:参数及参数取值
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 211,123评论 6 490
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,031评论 2 384
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 156,723评论 0 345
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,357评论 1 283
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,412评论 5 384
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,760评论 1 289
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,904评论 3 405
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,672评论 0 266
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,118评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,456评论 2 325
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,599评论 1 340
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,264评论 4 328
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,857评论 3 312
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,731评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,956评论 1 264
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,286评论 2 360
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,465评论 2 348

推荐阅读更多精彩内容