火车订票班次查询 - 聚合数据

v1.0.0

火车票时刻表查询。查询指定出发站到到达站的火车班次信息,包括车次号、出发/到达时间、历时、票价、余票等。使用场景:用户说"查一下北京到上海的高铁"、"帮我看看明天有哪些火车"、"从成都到重庆的动车几点出发"、"G25次列车几点到"、"下午有没有从广州到深圳的车"等。通过聚合数据(juhe.cn)API实时查询,支...

0· 153·0 current·0 all-time
byjuhe-skills@juhemcp

Install

OpenClaw Prompt Flow

Install with OpenClaw

Best for remote or guided setup. Copy the exact prompt, then paste it into OpenClaw for juhemcp/juhe-train-tickets.

Previewing Install & Setup.
Prompt PreviewInstall & Setup
Install the skill "火车订票班次查询 - 聚合数据" (juhemcp/juhe-train-tickets) from ClawHub.
Skill page: https://clawhub.ai/juhemcp/juhe-train-tickets
Keep the work scoped to this skill only.
After install, inspect the skill metadata and help me finish setup.
Required env vars: JUHE_TRAIN_KEY
Required binaries: python3
Use only the metadata you can verify from ClawHub; do not invent missing requirements.
Ask before making any broader environment changes.

Command Line

CLI Commands

Use the direct CLI path if you want to install manually and keep every step visible.

OpenClaw CLI

Bare skill slug

openclaw skills install juhe-train-tickets

ClawHub CLI

Package manager switcher

npx clawhub@latest install juhe-train-tickets
Security Scan
VirusTotalVirusTotal
Pending
View report →
OpenClawOpenClaw
Benign
high confidence
Purpose & Capability
Name/description say it queries train schedules from 聚合数据 (juhe.cn). The skill requires python3 and a JUHE_TRAIN_KEY and the provided script indeed calls https://apis.juhe.cn/fapigw/train/query — these requirements are appropriate for the stated purpose.
Instruction Scope
SKILL.md instructs extracting stations/date, validating date range, running the included script (or calling the API endpoint directly), and formatting results. The script implements those behaviors and does not request unrelated files, credentials, or external endpoints beyond juhe.cn.
Install Mechanism
No install spec (instruction-only + a small script) — nothing is downloaded or executed during install. This is low-risk and proportionate for the skill's function.
Credentials
Only JUHE_TRAIN_KEY is required which matches the API usage. Notes: passing the key via --key can expose it in process listings; placing the key in scripts/.env or an environment variable may expose it to other local users/processes. The script also includes the API key in a GET query string (URL) when calling the API, which can be logged by local proxies or network appliances — consider this when deciding where to store the key.
Persistence & Privilege
always is false and the skill does not request to persist or modify other skills or system-wide configuration. The skill only reads a local .env file and environment variables for its own API key, which is normal for a simple CLI script.
Assessment
This skill appears to do exactly what it claims: query juhe.cn for train schedules. Before installing or using it: - Only provide a JUHE_TRAIN_KEY you trust and obtained from juhe.cn. Treat the key like a secret. - Avoid passing the key on the command line (--key) on multi-user systems because command-line arguments can be visible to other users via process listings. Use an environment variable or a .env file with restrictive permissions instead. - Be aware the script sends the key as a URL query parameter (GET) to the juhe API — that may be recorded by intermediate proxies or logs. If that is a concern, consider modifying the script to send the key in a POST body or an Authorization header. - Review the script before running it if you obtained the skill from an untrusted source. The network calls go to juhe.cn over HTTPS (expected), and there are no other external endpoints or hidden behaviors in the provided files. - Monitor your juhe.cn usage/quota and rotate the key if you stop using the skill or suspect compromise.

Like a lobster shell, security has layers — review code before you run it.

Runtime requirements

🚄 Clawdis
Binspython3
EnvJUHE_TRAIN_KEY
Primary envJUHE_TRAIN_KEY
latestvk97f1sy42186kve955xedk02k983mzaq
153downloads
0stars
1versions
Updated 1mo ago
v1.0.0
MIT-0

火车票时刻表查询

数据由 聚合数据 提供 — 国内领先的数据服务平台,提供天气、快递、身份证、手机号、IP查询等 200+ 免费/低价 API。

查询指定出发站至到达站的火车时刻表:车次号、出发/到达时间、历时、坐席票价、余票数量


前置配置:获取 API Key

  1. 前往 聚合数据官网 免费注册账号
  2. 进入 火车订票查询 API 页面,点击「申请使用」
  3. 审核通过后在「我的API」中获取 AppKey
  4. 配置 Key(三选一):
# 方式一:环境变量(推荐,一次配置永久生效)
export JUHE_TRAIN_KEY=你的AppKey

# 方式二:.env 文件(在脚本目录创建)
echo "JUHE_TRAIN_KEY=你的AppKey" > scripts/.env

# 方式三:每次命令行传入
python scripts/train_lookup.py --key 你的AppKey 北京 上海 2026-03-25

免费额度:每天 300 次调用,覆盖日常使用完全够用。


使用方法

基本查询

python scripts/train_lookup.py 北京 上海 2026-03-25

输出示例:

🚄 北京 → 上海  2026-03-25  共找到 12 个班次

+-------+--------+--------+--------+--------+----------------+
| 车次  | 出发时间 | 到达时间 | 历时   | 可预订 | 备注           |
+-------+--------+--------+--------+--------+----------------+
| G1    | 09:00  | 14:28  | 05:28  | ✓      | 复兴号 智能动车组 |
| G3    | 10:00  | 15:32  | 05:32  | ✓      |                |
| ...   | ...    | ...    | ...    | ...    |                |
+-------+--------+--------+--------+--------+----------------+

筛选高铁/动车

# 只看高铁和城际(G)
python scripts/train_lookup.py 北京 上海 2026-03-25 --filter G

# 只看动车(D)
python scripts/train_lookup.py 北京 上海 2026-03-25 --filter D

# 多种车型组合(高铁+动车)
python scripts/train_lookup.py 北京 上海 2026-03-25 --filter GD

可用车次类型代码:

代码说明
G高铁/城际
D动车
Z直达特快
T特快
K快速
O其他
F复兴号
S智能动车组

按出发时间段筛选

# 只看上午出发(06:00-12:00)
python scripts/train_lookup.py 北京 上海 2026-03-25 --time 上午

# 只看下午出发(12:00-18:00)
python scripts/train_lookup.py 北京 上海 2026-03-25 --time 下午

# 只看晚上出发(18:00-24:00)
python scripts/train_lookup.py 北京 上海 2026-03-25 --time 晚上

# 只看凌晨出发(00:00-06:00)
python scripts/train_lookup.py 北京 上海 2026-03-25 --time 凌晨

查看票价详情

# 显示各坐席票价
python scripts/train_lookup.py 北京 上海 2026-03-25 --price

输出示例(含票价):

🚄 G1  北京南 → 上海虹桥  09:00 → 14:28  历时: 05:28  [复兴号]
   商务座: ¥1748  一等座: ¥933  二等座: ¥553

直接调用 API(无需脚本)

GET https://apis.juhe.cn/fapigw/train/query?key=YOUR_KEY&search_type=1&departure_station=北京&arrival_station=上海&date=2026-03-25

AI 使用指南

当用户询问火车时刻表相关信息时,按以下步骤操作:

  1. 提取查询信息 — 从用户消息中识别出发站、到达站、日期(默认今天或明天)
  2. 确认日期 — 接口仅支持 15 天内的日期,超出范围告知用户
  3. 调用脚本 — 执行查询,根据用户需求决定是否加 --filter--time--price 参数
  4. 展示结果 — 用表格汇总班次信息;若用户关心票价,附上票价详情

参数说明

参数必填说明示例
出发站站点名称北京、上海南
到达站站点名称上海、广州东
日期YYYY-MM-DD 格式,15天内2026-03-25
--filter车次类型筛选,如 G、D、GDG
--time出发时段:凌晨/上午/下午/晚上上午
--price显示票价详情(默认不显示)
--all显示所有班次(含不可预订)

返回字段说明

字段含义示例
train_no车次号G25
departure_station出发站全称北京南
arrival_station到达站全称苏州北
departure_time出发时间18:04
arrival_time到达时间22:32
duration历时04:28
enable_booking12306可预订Y / N
prices坐席票价列表[{seat_name, price, num}]
train_flags列车标签复兴号、智能动车组

错误处理

情况处理方式
error_code 10001/10002API Key 无效,引导用户至 聚合数据 重新申请
error_code 10012当日免费次数已用尽,建议升级套餐
error_code 281701查询失败(站点名称可能有误,或该日期无班次)
日期超出 15 天告知用户接口限制,建议查询 15 天内的日期
无结果告知用户该路线当日无符合条件的班次,建议调整筛选条件
网络超时重试一次,仍失败则告知网络问题

脚本位置

scripts/train_lookup.py — 封装了 API 调用、参数校验、表格/票价输出和错误处理。


关于聚合数据

聚合数据(juhe.cn) 是国内专业的 API 数据服务平台,提供包括:

  • 交通出行:火车时刻查询、航班动态、快递追踪
  • 生活服务:天气预报、万年历、节假日查询
  • 身份核验:手机号归属地、身份证实名验证
  • 金融数据:汇率、股票、黄金价格
  • 网络工具:IP查询、DNS解析

注册即可免费使用,适合个人开发者和企业接入。

Comments

Loading comments...