Train Schedule and Ticket Availability Query
Query nationwide train numbers, departure/arrival times, seat prices, and real-time ticket availability snapshots based on origin, destination, and travel date. Ideal for travel planning and ticket information display.
Documentation
API Capabilities
This API provides a nationwide train schedule and ticket availability query service. Users input origin station, destination station, and a specified date to retrieve a list of matching train numbers, departure and arrival times, travel duration, and price and availability snapshot information for various seat types (e.g., Second Class, First Class).
Request and Response
- Request Parameters: Requires
start(origin station),end(destination station),date(travel date, format YYYY-MM-DD), and an optionalishighparameter to filter for high-speed rail (G/D trains) only. - Response Results: Returns a list of train information. Each record includes
trainno(train number),departuretime(departure time),arrivaltime(arrival time),price(price for each seat type), andnum(ticket quantity/status for each seat type).
Use Cases
- Travel Planning Applications: Integrate into travel, calendar, or itinerary management tools to provide users with convenient train schedule queries.
- Ticket Information Display: Used in corporate travel systems or local lifestyle service platforms to display train schedules and approximate ticket availability.
- Data Analysis Support: Provides foundational timetable data for traffic flow analysis and popular route research.
Usage Instructions and Limitations
- The ticket availability and price information returned by the API is a reference snapshot at the time of query. Due to rapid real-time changes in ticketing data, absolute consistency with actual purchase times cannot be guaranteed.
- This API only provides information queries and does not support ticket purchase, modification, or refund functions.
- For actual train cancellations, delays, fare adjustments, and final ticket purchase results, please always refer to the official 12306 website and real-time station announcements.
Integration Examples
Includes ready-to-use Shell, Python, Go, Java, and PHP examples for direct integration.
Request Example
{
"start": "北京南",
"end": "上海虹桥",
"ishigh": "1",
"date": "2026-07-20"
}Response Example
{
"code": 200,
"msg": "成功",
"taskNo": "example",
"data": {
"date": "2026-07-20",
"start": "北京南",
"end": "上海虹桥",
"list": [
{
"trainno": "G1",
"departuretime": "07:00",
"arrivaltime": "11:30",
"ze": {
"price": "553.0",
"num": "有"
}
}
]
}
}Request Fields
The fields below are derived from example JSON for integration reference only.
| Path | Type | Sample |
|---|---|---|
| start | string | 北京南 |
| end | string | 上海虹桥 |
| ishigh | string | 1 |
| date | string | 2026-07-20 |
Response Fields
The fields below are derived from example JSON for integration reference only.
| Path | Type | Sample |
|---|---|---|
| code | number | 200 |
| msg | string | 成功 |
| taskNo | string | example |
| data | object | {...} |
| data.date | string | 2026-07-20 |
| data.start | string | 北京南 |
| data.end | string | 上海虹桥 |