360 Secure SkillHub
360 安全技能中心

KMB and LWB Bus Arrivals

通过 python3 脚本调用九巴开放数据接口,按路线编号与站点名称(支持中英文及部分匹配)查询实时到站时间,自动尝试双向并输出含 HKT 时间的纯文本结果;无缓存,需网络访问与 certifi 依赖,声明 2 次重试和 3 秒超时。

stevenho1394
stevenho1394
热度 61.45
最近更新 2026-09-13 22:33:42
分类:生活依赖:代码执行 / 第三方 API应用场景:旅行

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add kmb-bus-arrival
Metadata
name
kmb-bus-arrival
description
Retrieve real-time KMB bus arrival information. getArrival returns plain text.
version
1.2.2
author
Steven Ho
repository
https://github.com/StevenHo1394/kmb-bus-arrival
tools
[{"name":"getArrival","description":"Get the next bus arrival times for a specific route and stop name. Returns plain text.","command":"python3 kmb_bus.py getArrival {route} {stop_name}","inputSchema":{"type":"object","required":["route","stop_name"],"properties":{"route":{"type":"string","pattern":"^[A-Za-z0-9]{1,16}$","maxLength":16},"stop_name":{"type":"string","pattern":"^[\\w\\s\\u4e00-\\u9fff\\(\\)()\\-]{1,50}$","maxLength":50}}},"output":{"format":"text"}}]

KMB Bus Arrival

Retrieve real-time KMB bus arrival information using the official KMB Open Data API (data.etabus.gov.hk).

Installation

# Place kmb_bus.py and SKILL.md in your skills directory
# Requires: Python 3.8+, internet access to data.etabus.gov.hk
# Dependencies: certifi (pip install certifi)

Usage

Hermes CLI / OpenClaw

# Get arrivals for route E31 at Panda Hotel
python3 kmb_bus.py getArrival E31 "Panda Hotel"

# Get arrivals for route 265M at Chung On Street
python3 kmb_bus.py getArrival 265M "Chung On Street"

Parameters

Parameter Type Description
route string KMB route number (e.g., E31, 265M, 269M)
stop_name string Stop name in English or Chinese (partial match supported)

Output Format

*E31 (to TSUEN WAN (DISCOVERY PARK))*

Stop: *PANDA HOTEL (TW281)*

Next arrivals:
- 20:46 HKT
- 21:11 HKT

(Current Time: 20:30 HKT)

Features

  • Auto-direction: Tries both inbound and outbound; reports whichever has the stop. If both directions serve the stop, both are shown.
  • Alternate stop ID fallback: If the given stop name matches multiple stops on the route, uses up to 2 matches.
  • Fresh API calls: No caching — all requests hit the live KMB API.
  • Plain text output: Human-readable with Traditional Chinese stop names.
  • Human-readable errors: Clear error messages for invalid routes/stops.

Implementation Details

  • Script: kmb_bus.py — single command getArrival <route> <stop_name>
  • API: https://data.etabus.gov.hk/v1/transport/kmb/
    • /route-stop/{route}/{bound}/1 — stop sequence with UUID IDs
    • /stop/{stop_id} — stop name lookup
    • /eta/{stop_uuid}/{route}/1 — real-time ETA (Format B, UUID-based)
  • Timezone: All times in HKT (UTC+8)
  • Retries: 2 retries with exponential backoff, 3s total timeout per call

Version History

v1.2.2 (2026-09-13)

  • Security fixes per ClawHub audit
  • API call budget raised to 100, timeouts increased to 3s
  • Fixed datetime.utcnow() deprecation
  • Added README.md, flattened directory structure

v1.2.1 (2026-08-22)

  • Full removal of caching — all API calls are fresh
  • Plain-text errors for getArrival
  • Auto-direction and alternate stop ID fallback retained
  • Single command: getArrival <route> <stop_name>
  • Removed legacy commands: getRouteDirection, getRouteInfo, getBusStopID, getNextArrivals

Related Skills

  • hk-gmb-arrival — Green minibus (GMB) real-time arrival (different operator)
  • hong-kong-info — General HK info services including franchised bus real-time occupancy

References

  • references/clawhub-security-audit-2026-09-13.md — ClawHub A.I.G security audit findings and remediation (T09 command injection, E1 external transmission, SDI-4 capability mismatch)