12306 Train Query for Openclaw

A high-performance CLI utility for querying real-time China Railway 12306 train schedules and ticket availability.

zhangsaizz
v1.0.0
Mar 21, 2026
0
835
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install 12306-query

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install 12306-query using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is 12306 Train Query?

The 12306-query skill is a specialized technical interface designed to bridge the gap between AI agents and the official China Railway database. As a key part of the Openclaw Skills ecosystem, it allows developers and automated agents to fetch live data on high-speed rail (Gaotie), bullet trains, and traditional rail services across mainland China without requiring complex API keys.

This tool is particularly valuable for building travel assistants or automated booking monitors. By leveraging Openclaw Skills, users can transform raw station data and seat availability into structured Markdown or HTML reports, enabling seamless integration into chat interfaces or data processing pipelines.

12306 Train Query Use Cases

  • Checking real-time ticket availability for high-speed rail (G/D series) between Chinese cities.
  • Monitoring specific arrival or departure windows for business travel planning.
  • Automating the lookup of station names and codes for travel logistics.
  • Generating formatted Markdown tables of train schedules for AI-driven travel recommendations.

How 12306 Train Query Works

  1. The user or agent initiates a query command specifying the origin, destination, and optional filters like date or train type.
  2. The skill interfaces directly with the official 12306 API to retrieve the most recent schedule and seat inventory.
  3. Station names are resolved and cached locally for 7 days to ensure high performance and reduce network overhead.
  4. The raw data is processed based on the requested format—generating either a visual HTML file, a structured Markdown table, or a raw JSON object.
  5. The output is delivered to the stdout or saved to a designated file path for further use by Openclaw Skills workflows.

12306 Train Query Setup

To integrate this into your Openclaw Skills environment, ensure you have Node.js installed and run the following commands:

# Navigate to the skill directory
cd {baseDir}

# Query tickets from Beijing to Shanghai in Markdown format
node scripts/query.mjs 北京 上海 -f md

# Perform a station lookup
node scripts/stations.mjs 上海

12306 Train Query Data Schema & Taxonomy

The skill manages data through a mix of temporary caches and structured outputs:

Data Type Location Retention
Station Cache {baseDir}/data/stations.json 7 Days
HTML Reports {baseDir}/data/<from>-<to>-<date>.html User Defined
Raw Data JSON Output (stdout) Per Request

Seat Type Mapping:

  • swz: Business/Premium
  • zy: First Class
  • ze: Second Class
  • rw/dw: Soft/Bullet Sleeper

12306 Train Query Advanced Features

  • Multi-parameter filtering: Combine train types (e.g., GD), departure windows, and maximum travel duration.
  • Availability Mode: Use the --available flag to filter out trains that are already sold out or not yet bookable.
  • Flexible Formatting: Toggle between HTML for visual review and JSON/Markdown for programmatic Openclaw Skills integration.
  • Time-based Arrive/Depart filters: Restrict results to specific time blocks using HH:MM ranges.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Requires
Bins node
Github Stars: 0
forks: 0

Featured*