火车票查询
其他 官方文档
支持查询高铁、动车等列车的实时票务信息,输入出发地、目的地及日期即可获取车次、发车/到达时间、行程时长、座位类型、票价及余票数量
基本说明:
接口地址:https://api.lolimi.cn/API/hc/api
返回格式:json
请求方式:get/post
请求示例:https://api.lolimi.cn/API/hc/api?departure=北京&arrival=上海&type=json
请求参数说明:
名称 类型 必填 说明
type string 必填 json/text默认text;departure
返回参数说明:
名称 类型 说明
TrainNumber string 列车车次
start string 出发地
end string 终点
DepartTime string 出发时间
ArriveTime string 到达时间
SeatList arr 座位信息
JSON返回示例:
{
	"code": 200,
	"count": 1,
	"go": "合肥",
	"to": "上海",
	"form": "",
	"time": "2026-01-24 21:11:12",
	"date": "2026-01-24",
	"data": [{
		"TrainNumber": "K8361",
		"start": "合肥",
		"end": "上海",
		"DepartTime": "22:35",
		"ArriveTime": "08:09",
		"TimeDifference": "14:26",
		"SeatList": [{
				"SeatName": "硬座",
				"SeatPrice": 78,
				"Seatresidue": 99
			},
			{
				"SeatName": "硬卧",
				"SeatPrice": 148,
				"Seatresidue": 99
			},
			{
				"SeatName": "软卧",
				"SeatPrice": 223,
				"Seatresidue": 4
			},
			{
				"SeatName": "无座",
				"SeatPrice": 78,
				"Seatresidue": 99
			}
		]
	}],
	"timestamp": 1769262315,
	"author": "桑帛云API:https://api.lolimi.cn",
	"exec_time": "191ms"
}
服务级错误码参照
错误码 说明
- -
完整教学代码示例
<?php
/**
 * Created by PhpStorm.
 * User: FZS
 * Time: 2026/1/20 07:11
 */
class freeApi
{
    private $apiUrl;

    public function __construct()
    {
        $this->apiUrl = 'https://api.lolimi.cn/API/hc/api?departure=北京&arrival=上海&type=json';
    }

    /**
     * 获取结果
     * @return array
     */
    public function getResult()
    {
        return file_get_contents($this->apiUrl);
    }
}
package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
)

const (
	APIURL   = "https://api.lolimi.cn/API/hc/api?departure=北京&arrival=上海&type=json"
)

func main() {
	queryUrl := fmt.Sprintf("%s",APIURL)
	resp, err := http.Get(queryUrl)
	if err != nil {
		log.Println(err)
		return
	}

	defer resp.Body.Close()

	body, err := ioutil.ReadAll(resp.Body)

	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(string(body))
}