tfl-cli
Use tfl for London transport: tube status, journey planning, disruptions, live arrivals, bike availability, and stop search.
Setup
- - INLINECODE1
- Optional: set
TFL_APP_KEY for higher rate limits (basic usage works without any key)
Status
- - All lines: INLINECODE3
- Specific line: INLINECODE4
- Filter by mode: INLINECODE5
Disruptions
- - Current disruptions: INLINECODE6
- Specific line: INLINECODE7
Journey Planning
- - Station to station: INLINECODE8
- Postcode to postcode: INLINECODE9
- Arrive by time: INLINECODE10
- With preferences: INLINECODE11
- Via a waypoint: INLINECODE12
- Project one route field: INLINECODE13
- Project route legs: INLINECODE14
Arrivals
- - Next arrivals: INLINECODE15
- Specific line: INLINECODE16
- Filter direction: INLINECODE17
- Project one value: INLINECODE18
- Project in JSON: INLINECODE19
Bikes
- - Near postcode: INLINECODE20
- Custom radius: INLINECODE21
- Project one value: INLINECODE22
- Project one subtree: INLINECODE23
Search
- - Find stops/stations: INLINECODE24
- Limit results: INLINECODE25
Output
- - All commands default to text in TTY and JSON when piped
- Force JSON: INLINECODE26
- Force text: INLINECODE27
- Disable colour: INLINECODE28
- Success envelope: INLINECODE29
- Error envelope: INLINECODE30
Agent Notes
- -
--output <path> is available on route, arrivals, and INLINECODE34 - Paths use dot notation with zero-based array indexes, for example
journeys.0.durationMinutes or INLINECODE36 - In text mode, scalar projections print just the value
- In text mode, object or array projections print plain pretty JSON
- Projection errors are structured: malformed paths return
INVALID_INPUT, missing paths return INLINECODE38
Notes
- - No API key required for basic usage
- Accepts station names, postcodes (
SE1 9SG), coordinates (51.50,-0.12), and TfL stop IDs - Status and disruptions cover tube, overground, DLR, and Elizabeth line
- Exit codes: 0 success, 2 bad input or ambiguity, 3 upstream failure, 4 internal error
- When a station name is ambiguous, the error includes candidate suggestions
tfl-cli
使用 tfl 查询伦敦交通信息:地铁状态、行程规划、中断信息、实时到站、自行车可用性及站点搜索。
设置
- - npm install -g @shan8851/tfl-cli
- 可选:设置 TFLAPPKEY 以提高速率限制(基本使用无需任何密钥)
状态
- - 所有线路:tfl status
- 特定线路:tfl status jubilee
- 按交通模式筛选:tfl status --mode tube,dlr
中断信息
- - 当前中断:tfl disruptions
- 特定线路:tfl disruptions piccadilly
行程规划
- - 站到站:tfl route waterloo kings cross
- 邮编到邮编:tfl route SE1 9SG EC2R 8AH
- 指定到达时间:tfl route waterloo bank --arrive-by --time 09:00
- 带偏好设置:tfl route waterloo paddington --preference least-interchange
- 途经中间点:tfl route waterloo paddington --via bank
- 提取单一路线字段:tfl route SE1 9SG EC2R 8AH --output journeys.0.durationMinutes
- 提取路线分段:tfl route waterloo canary wharf --output journeys.0.legs
到站信息
- - 下一班到站:tfl arrivals waterloo
- 特定线路:tfl arrivals kings cross --line northern --limit 5
- 筛选方向:tfl arrivals waterloo --direction inbound
- 提取单个值:tfl arrivals waterloo --output arrivals.0.timeToStationSeconds
- 以JSON格式提取:tfl arrivals waterloo --json --output arrivals.0.lineName
自行车
- - 附近邮编:tfl bikes SE1 9SG
- 自定义半径:tfl bikes waterloo --radius 750 --limit 5
- 提取单个值:tfl bikes SE1 9SG --output bikePoints.0.bikes
- 提取单个子树:tfl bikes SE1 9SG --output bikePoints.0
搜索
- - 查找站点/车站:tfl search stops paddington
- 限制结果数量:tfl search stops paddington --limit 10
输出
- - 所有命令在TTY中默认输出文本,通过管道时输出JSON
- 强制JSON:tfl status --json
- 强制文本:tfl status --text
- 禁用颜色:tfl --no-color status
- 成功信封:{ ok, schemaVersion, command, requestedAt, data }
- 错误信封:{ ok, schemaVersion, command, requestedAt, error }
代理说明
- - --output <路径> 适用于 route、arrivals 和 bikes 命令
- 路径使用点号表示法,数组索引从0开始,例如 journeys.0.durationMinutes 或 arrivals.0.lineName
- 在文本模式下,标量投影仅输出值
- 在文本模式下,对象或数组投影输出美观的纯JSON
- 投影错误结构化:格式错误的路径返回 INVALIDINPUT,缺失的路径返回 NOTFOUND
注意事项
- - 基本使用无需API密钥
- 支持车站名称、邮编(SE1 9SG)、坐标(51.50,-0.12)和TfL站点ID
- 状态和中断信息涵盖地铁、地上铁、DLR和伊丽莎白线
- 退出码:0成功,2输入错误或歧义,3上游故障,4内部错误
- 当车站名称存在歧义时,错误信息会包含候选建议