NYC Subway Status
Real-time NYC subway arrival times. No API key required.
Setup
Before making any API calls, fetch the full API reference:
CODEBLOCK0
This returns a plain-text guide with all endpoints, slug formats, response schemas, and tips. Read it once per session to understand the API surface.
Base URL: INLINECODE0
Core Workflow
Always search first — never guess station or route slugs.
- 1. Search:
GET /api/search?q={query} to find station slugs and route slugs - Use the returned slugs to call the appropriate endpoint
Use Cases
1. Next train at a station
User asks: "when is the next Q at 72nd st"
CODEBLOCK1
The response includes an arrivals_url when both station and route match. Use it:
CODEBLOCK2
Present the minutes_away values from arrivals.uptown and arrivals.downtown. Example output:
Q at 72 St (N/Q/R)
Uptown: 3 min, 8 min, 15 min
Downtown: 1 min, 6 min, 12 min
2. All arrivals at a station
User asks: "what trains are coming to Union Square"
CODEBLOCK3
Use the by_route field to group arrivals by line. Show each route with its next few trains in both directions.
3. Is a line running?
User asks: "is the G train running"
CODEBLOCK4
Returns next arrival at every station on the route. If most stations have next_uptown or next_downtown values, the line is running. If many are null, service may be disrupted. Summarize the overall status.
4. Track a specific train
User asks for details on a specific trip (usually after seeing a trip_id from an arrivals response):
CODEBLOCK5
Returns every stop on the trip with status ("passed" or "upcoming") and minutes_away. Show the train's current position and upcoming stops.
5. Find a station
User asks: "find subway stations near Times Square"
CODEBLOCK6
List matching stations with their routes. Offer to check arrivals at any of them.
6. Compare routes at a station
User asks: "should I take the N or Q at 72nd"
CODEBLOCK7
Use the by_route field to compare the next arrivals for each route in the user's direction. Recommend the sooner train.
Response Format
All responses follow this envelope:
CODEBLOCK8
Errors return "ok": false with an error object containing code and message.
Key Details
- - Directions: "uptown" = northbound, "downtown" = southbound
- minutes_away is pre-computed server-side — no client math needed
- Arrival times include both Unix timestamps and ISO 8601 strings
- Route slugs are lowercase:
a, q, 7, si, INLINECODE21 - Station slugs are hyphenated lowercase:
14-st-union-sq, INLINECODE23
MCP Server (Alternative)
For agents that support Model Context Protocol, connect directly:
CODEBLOCK9
Tools: search_subway, get_arrivals, get_station_arrivals, list_stations, list_routes, INLINECODE29
纽约地铁状态
实时纽约地铁到站时间。无需API密钥。
设置
在进行任何API调用之前,请先获取完整的API参考文档:
GET https://nyc-subway-status.com/llms.txt
这将返回一份纯文本指南,包含所有端点、slug格式、响应模式及使用技巧。每个会话阅读一次以了解API全貌。
基础URL: https://nyc-subway-status.com
核心工作流程
始终先搜索——切勿猜测站点或线路的slug。
- 1. 搜索:GET /api/search?q={查询词} 查找站点slug和线路slug
- 使用返回的slug调用相应端点
使用场景
1. 查询某站点的下一班列车
用户询问:72街的Q线什么时候到
GET /api/search?q=72+st+q
当站点和线路都匹配时,响应中包含 arrivals_url。使用它:
GET /api/stops/72-st-n-q-r/lines/q
展示 arrivals.uptown 和 arrivals.downtown 中的 minutes_away 值。示例输出:
72街的Q线(N/Q/R)
上城方向:3分钟、8分钟、15分钟
下城方向:1分钟、6分钟、12分钟
2. 查询某站点的所有到站信息
用户询问:联合广场有哪些列车即将到达
GET /api/search?q=union+square
GET /api/stops/14-st-union-sq
使用 by_route 字段按线路分组到站信息。展示每条线路两个方向接下来的几班列车。
3. 查询某线路是否在运行
用户询问:G线在运行吗
GET /api/lines/g
返回线路上每个站点的下一班到站信息。如果大多数站点都有 nextuptown 或 nextdowntown 值,则线路在运行。如果很多值为 null,则服务可能中断。总结整体运行状态。
4. 追踪特定列车
用户询问某趟具体列车的详细信息(通常在查看到站响应中的trip_id后):
GET /api/trips/{tripId}?route={routeSlug}
返回该趟列车每个站点及其 status(已通过或即将到达)和 minutes_away 值。展示列车的当前位置和即将到达的站点。
5. 查找站点
用户询问:查找时代广场附近的地铁站
GET /api/search?q=times+square
列出匹配的站点及其线路。提供查看任一站点到站信息的选项。
6. 比较某站点的线路
用户询问:在72街我应该坐N线还是Q线
GET /api/stops/72-st-n-q-r
使用 by_route 字段比较用户所需方向上每条线路的下一班到站时间。推荐更早到达的列车。
响应格式
所有响应遵循以下结构:
json
{
ok: true,
data: { ... },
_meta: { timestamp: ..., endpoint: ..., realtime: true }
}
错误时返回 ok: false,并附带包含 code 和 message 的 error 对象。
关键细节
- - 方向: uptown = 上城方向,downtown = 下城方向
- minutes_away 由服务端预先计算——无需客户端计算
- 到站时间 同时包含Unix时间戳和ISO 8601字符串
- 线路slug 为小写:a、q、7、si、gs
- 站点slug 为小写连字符格式:14-st-union-sq、times-sq-42-st
MCP服务器(备选方案)
对于支持模型上下文协议的代理,可直接连接:
json
{
mcpServers: {
nyc-subway: { url: https://nyc-subway-status.com/mcp }
}
}
工具:searchsubway、getarrivals、getstationarrivals、liststations、listroutes、get_trip