微算力 · API 导航与自营网关
API 接入 EN
未登录登录
🇬🇧

伦敦官方实时交通全掌握

TfL London Transit · v1.0.0
专业技能 安全 S+ 级 作者 brianleach 公开目录收录
1k 下载 0 安装 2.8k 收藏 14 浏览

简介

TfL官方API接入,提供伦敦地铁实时到站、公交预测、线路状态、服务中断和行程规划,免费密钥支持500次/分钟。

原始描述

London TfL transit — real-time Tube arrivals, bus predictions, line status, service disruptions, journey planning, and route info for the London Underground,...

通过你的 Agent 添加

安装目录:tfl/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。

点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。

或者手动安装

Claude Code~/.claude/skills/tfl-london-transit/
Codex CLI~/.codex/skills/tfl-london-transit/
DeepSeek Harness~/.agents/skills/tfl-london-transit/

包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可; 目录名不用换,也不要把包直接解压到 skills 根目录。 技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。

中文使用说明 来自收录源

核心用法

TfL London Transit 是一款基于伦敦交通局官方统一REST API的实时公共交通查询工具,覆盖Tube地铁、DLR轻轨、Overground地上铁、Elizabeth线、公交、电车等全模式。用户可通过自然语言查询任意站点到站时间、线路运行状态、服务中断及规划跨区行程。

主要功能模块:

  • 线路状态:查询全部或指定Tube线路实时运行状态(Good Service/Suspended/Severe Delays等)
  • 到站预测:支持地铁站(NaPTAN ID检索)和公交站点(490开头ID)的实时到站倒计时
  • 智能搜索:模糊匹配站点名称,自动解析经纬度定位周边站点
  • 行程规划:起点到终点的多模式路径规划,含票价预估
  • 服务中断:主动推送指定线路的维护、故障、停运信息

技术实现上,该工具通过Node.js脚本封装TfL API,返回数据经清洗后以伦敦本地习惯格式化(24小时制、线路色标emoji、分钟级倒计时)。

显著优点

  1. 官方数据源:直接对接api.tfl.gov.uk,数据权威性无可替代,延迟通常在秒级
  2. 全模式覆盖:单一API统管11条Tube线路、6条Overground支线、DLR、Elizabeth线、公交、电车、缆车、河运
  3. 零成本接入:API密钥免费申请,无密钥亦可基础使用,适合轻度用户
  4. 隐私友好:不采集用户位置、不写入本地缓存、无遥测上报,仅传输站点ID和可选密钥
  5. 开发者友好:统一JSON格式,无需处理protobuf或SIRI等多格式转换

潜在缺点与局限性

  • 地域限制:仅限大伦敦地区(Greater London),对英国其他城市或国际出行无支持
  • 离线不可用:完全依赖实时API,无本地GTFS缓存,网络中断即失效
  • 免费配额限制:无密钥时速率限制较严,高峰期可能触发429限流
  • 英文界面:API返回及脚本输出均为英文,非英语用户需二次处理
  • NaPTAN ID依赖:精确查询需记忆或查找TfL站点编码,新手有学习成本

适合人群

  • 伦敦居民及通勤者:日常查Tube/公交到站、规避延误线路
  • 国际旅客:行程规划、实时确认Elizabeth线/机场快线状态
  • 开发者/研究者:需要伦敦公共交通实时数据做分析或应用开发
  • 智能助手场景:为AI助手提供伦敦出行能力的后端工具

常规风险

风险类型 说明 缓解措施
API密钥泄露 密钥以query参数明文传输 使用环境变量注入,避免硬编码
速率限制 无密钥时易触发429错误 免费申请密钥,获得500req/min额度
数据时效性 极端情况下API延迟或故障 关键出行建议交叉验证TfL官网或现场显示屏
网络依赖 地铁内信号覆盖不均 提前查询到站时间,预留缓冲
输入注入 站点名称URL编码处理 已实现编码转义,无shell命令拼接风险

整体而言,这是一款数据来源权威、隐私设计简洁、功能聚焦伦敦的实用工具,适合需要可靠实时公交信息的用户集成使用。

技能正文


name: tfl description: London TfL transit — real-time Tube arrivals, bus predictions, line status, service disruptions, journey planning, and route info for the London Underground, DLR, Overground, Elizabeth line, and buses. Use when the user asks about London public transport, Tube times, bus arrivals, or TfL service status. homepage: "https://github.com/brianleach/tfl-skill" license: MIT metadata: openclaw: emoji: "\U0001F1EC\U0001F1E7" tags: [transit, london, tfl, transportation, tube, underground, bus, train, schedule] primaryEnv: TFL_API_KEY requires: bins: ["node"] files: ["scripts/tfl.mjs"]

TfL London Transit

Real-time London TfL transit data — Tube arrivals, bus predictions, line status, disruptions, journey planning, and route information. Uses TfL's single unified REST API for all modes. API key optional (free, recommended for higher rate limits).

When to Use

  • User asks about the Tube, London Underground, TfL, or London public transport
  • User mentions specific Tube lines (Bakerloo, Central, Circle, District, Hammersmith & City, Jubilee, Metropolitan, Northern, Piccadilly, Victoria, Waterloo & City)
  • User asks "is the Northern line running" or "when's the next Tube"
  • User mentions London stations (King's Cross, Oxford Circus, Waterloo, Victoria, Paddington, etc.)
  • User asks about London buses, DLR, Overground, Elizabeth line, or trams
  • User asks about TfL service status, delays, disruptions, or planned closures
  • User asks about Oyster, contactless, or TfL fares
  • User asks about journey planning in London

Data Sources

TfL has a single unified REST API (api.tfl.gov.uk) that returns JSON for ALL modes — Tube, bus, DLR, Overground, Elizabeth line, trams, river bus, cable car. No protobuf, no SIRI, no multiple feed formats. Just one clean REST API with consistent JSON responses.

API key: Register for a free app_key at https://api-portal.tfl.gov.uk/ — append ?app_key={KEY} to requests. The API works without a key for basic usage but is rate-limited; with a key you get 500 requests per minute.

Key Endpoints

Endpoint Description
/Line/Mode/tube/Status All Tube line statuses
/Line/{lineId}/Status Specific line status
/StopPoint/{naptanId}/Arrivals Arrivals at a stop
/Line/{lineId}/Arrivals/{stopPointId} Arrivals filtered by line
/StopPoint/Search/{query} Search stops by name
/StopPoint?lat=&lon=&radius= Stops near location
/Line/{lineId}/StopPoints Stops on a line
/Line/{lineId}/Route/Sequence/{dir} Route stop sequence
/Line/{lineId}/Disruption Disruptions on a line
/Journey/JourneyResults/{from}/to/{to} Journey planning
/Line/Mode/bus All bus routes

All endpoints return JSON. Append ?app_key={KEY} for authenticated requests.

Implementation

Quick Start: Use the helper scripts

The scripts in this skill's scripts/ directory handle fetching, parsing, and presenting TfL data.

Script: scripts/tfl.mjs

Main entry point. Supports these commands:

# Tube line status
node scripts/tfl.mjs status
node scripts/tfl.mjs status --all
node scripts/tfl.mjs status --line victoria

# Arrivals at a station
node scripts/tfl.mjs arrivals --station "Oxford Circus"
node scripts/tfl.mjs arrivals --stop 940GZZLUOXC
node scripts/tfl.mjs arrivals --stop-search "kings cross"
node scripts/tfl.mjs arrivals --stop-search "kings cross" --line piccadilly

# Bus arrivals
node scripts/tfl.mjs bus-arrivals --stop 490005183E
node scripts/tfl.mjs bus-arrivals --stop-search "oxford circus"
node scripts/tfl.mjs bus-arrivals --stop-search "oxford circus" --route 24

# Disruptions
node scripts/tfl.mjs disruptions
node scripts/tfl.mjs disruptions --line northern

# Routes and stops
node scripts/tfl.mjs routes
node scripts/tfl.mjs routes --all
node scripts/tfl.mjs bus-routes
node scripts/tfl.mjs stops --search "waterloo"
node scripts/tfl.mjs stops --near 51.5074,-0.1278 --radius 500
node scripts/tfl.mjs stops --line victoria
node scripts/tfl.mjs route-info --line bakerloo
node scripts/tfl.mjs route-info --route 24

# Journey planning
node scripts/tfl.mjs journey --from "waterloo" --to "kings cross"
node scripts/tfl.mjs journey --from "51.5031,-0.1132" --to "51.5308,-0.1238"

Setup: API Key (Optional, Recommended)

Basic functionality works without a key (rate-limited). For 500 requests/minute:

  1. Register at https://api-portal.tfl.gov.uk/
  2. Set environment variable: TFL_API_KEY

Tube Lines Reference

Line ID Line Name Emoji Terminals
bakerloo Bakerloo brown Harrow & Wealdstone <-> Elephant & Castle
central Central red Epping / Ealing Broadway <-> West Ruislip
circle Circle yellow Hammersmith (loop via Liverpool Street)
district District green Richmond / Ealing Broadway <-> Upminster
hammersmith-city Hammersmith & City pink Hammersmith <-> Barking
jubilee Jubilee silver Stanmore <-> Stratford
metropolitan Metropolitan magenta Chesham / Amersham / Uxbridge <-> Aldgate
northern Northern black Edgware / High Barnet <-> Morden / Battersea
piccadilly Piccadilly dark blue Heathrow T5 / Uxbridge <-> Cockfosters
victoria Victoria light blue Walthamstow Central <-> Brixton
waterloo-city Waterloo & City teal Waterloo <-> Bank

Other TfL Rail Modes

Line ID Name Type
dlr DLR Docklands Light Railway
liberty Liberty Overground (Romford — Upminster)
lioness Lioness Overground (Watford — Euston)
mildmay Mildmay Overground (Stratford — Richmond/Clapham)
suffragette Suffragette Overground (Gospel Oak — Barking)
weaver Weaver Overground (Liverpool St — Enfield/Cheshunt/Chingford)
windrush Windrush Overground (Highbury — Crystal Palace/Clapham/W Croydon)
elizabeth Elizabeth line Crossrail
tram London Trams Croydon Tramlink

TfL Fares Reference (from March 2025)

Fare Type Price
Tube Zone 1 (Oyster/contactless, peak) £2.80
Tube Zone 1 (Oyster/contactless, off-peak) £2.70
Tube Zones 1-2 (peak) £2.80
Tube Zones 1-2 (off-peak) £2.70
Tube Zones 1-3 (peak) £3.50
Tube Zones 1-3 (off-peak) £2.80
Bus & Tram (any journey) £1.75
Hopper fare (unlimited bus/tram within 1 hour) £1.75 total
Daily cap Zones 1-2 £8.90
Weekly cap Zones 1-2 £44.70
Cash single (ticket machine) £6.70 (Zone 1)

Peak: Mon-Fri 6:30-9:30am and 4:00-7:00pm (except public holidays).

Tips for Users

  • NaPTAN IDs are the station identifiers — Tube stations use 940GZZLU{code} format
  • Use --station or --stop-search for name-based lookups; use --stop for exact NaPTAN IDs
  • Times are shown in 24-hour format (London convention)
  • The arrivals command uses timeToStation (seconds) from the TfL API for ETA
  • Bus stops have their own NaPTAN IDs in 490{code} format
  • Journey planning returns fare estimates when available

Error Handling

  • If TFL_API_KEY is not set, requests still work but are rate-limited — a note is printed
  • 429 rate limit responses print a helpful message with the key signup URL
  • Invalid station/stop searches show "No matching station found" with suggestions
  • Network errors and API error responses produce friendly messages
  • Station closed or no service shows an appropriate message

Response Formatting

When presenting transit info to the user:

  • Lead with the most actionable info (next arrival time, line status)
  • Show line name with color emoji (e.g., "🔴 Central: Good Service")
  • Show times in 24-hour format (London convention)
  • For arrivals: show line + destination + minutes (from timeToStation / 60)
  • Show platform name when available
  • For journey planning: show step-by-step with mode, line, duration, and fare
  • Always mention disruptions for queried lines

External Endpoints

Endpoint Data Sent Data Received
api.tfl.gov.uk/Line/*/Status API key (query param, optional) Line status (JSON)
api.tfl.gov.uk/StopPoint/*/Arrivals API key (query param, optional) Arrivals (JSON)
api.tfl.gov.uk/StopPoint/Search/* API key (query param, optional) Stop search results (JSON)
api.tfl.gov.uk/StopPoint?lat=&lon= API key (query param, optional) Nearby stops (JSON)
api.tfl.gov.uk/Line/*/StopPoints API key (query param, optional) Stops on line (JSON)
api.tfl.gov.uk/Line/*/Route/Sequence/* API key (query param, optional) Route sequence (JSON)
api.tfl.gov.uk/Line/*/Disruption API key (query param, optional) Disruptions (JSON)
api.tfl.gov.uk/Journey/JourneyResults/* API key (query param, optional) Journey results (JSON)
api.tfl.gov.uk/Line/Mode/bus API key (query param, optional) Bus routes (JSON)

API key is passed as a query parameter to TfL's official API. No other user data is transmitted.

Security & Privacy

  • API key optional — TfL Unified API works without a key (rate-limited); with a free key you get 500 req/min
  • No user data transmitted — requests contain only the optional API key and route/stop identifiers, no personal information
  • No local storage — this skill does not write any files to disk (no GTFS cache needed — TfL is all live API)
  • No telemetry — this skill does not phone home or collect usage data
  • Input handling — stop names and route IDs from user input are URL-encoded in API queries, never interpolated into shell commands

Trust Statement

This skill reads publicly available transit data from TfL's official Unified API. The optional API key is used only for TfL API rate-limit authentication. The skill does not access, store, or transmit any personal information beyond the API key configured by the user.

正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。

标签

transitlondontfltransportationtubeundergroundbustrainschedulereal-timepublic-transport

同类 Skill