介绍
# Wiener Linien Real-Time API
查询维也纳公共交通的实时发车、故障中断、电梯停运和服务信息。
## 快速参考
| 端点 | 用途 | |----------|---------| | `/monitor` | 站点实时发车 | | `/trafficInfoList` | 所有当前故障中断 | | `/trafficInfo` | 特定故障中断详情 | | `/newsList` | 服务新闻与电梯维护 |
**Base URL:** `https://www.wienerlinien.at/ogd_realtime`
---
## 查找站点 ID
站点由 **RBL 编号**(Rechnergestütztes Betriebsleitsystem)标识。请使用参考数据:
```bash # Search stops by name curl -s "https://www.wienerlinien.at/ogd_realtime/doku/ogd/wienerlinien-ogd-haltepunkte.csv" | grep -i "stephansplatz"
# Format: StopID;DIVA;StopText;Municipality;MunicipalityID;Longitude;Latitude ```
**常见站点 ID (RBL):**
| 站点 | RBL IDs | 线路 | |------|---------|-------| | Stephansplatz | 252, 4116, 4119 | U1, U3 | | Karlsplatz | 143, 144, 4101, 4102 | U1, U2, U4 | | Westbahnhof | 1346, 1350, 1368 | U3, U6 | | Praterstern | 4205, 4210 | U1, U2 | | Schwedenplatz | 1489, 1490, 4103 | U1, U4 | | Schottentor | 40, 41, 4118 | U2, Trams |
---
## 1. 实时发车 (`/monitor`)
获取一个或多个站点的下一班发车时间。
### 请求
```bash # Single stop curl -s "https://www.wienerlinien.at/ogd_realtime/monitor?stopId=252"
# Multiple stops curl -s "https://www.wienerlinien.at/ogd_realtime/monitor?stopId=252&stopId=4116"
# With disruption info curl -s "https://www.wienerlinien.at/ogd_realtime/monitor?stopId=252&activateTrafficInfo=stoerungkurz&activateTrafficInfo=stoerunglang&activateTrafficInfo=aufzugsinfo" ```
### 参数
| 参数 | 必填 | 描述 | |-------|----------|-------------| | `stopId` | 是 (1-n) | RBL 站点 ID | | `activateTrafficInfo` | 否 | 包含故障中断:`stoerungkurz`, `stoerunglang`, `aufzugsinfo` | | `aArea` | 否 | `1` = 包含所有具有相同 DIVA 编号的站台 |
### 响应结构
```json { "data": { "monitors": [{ "locationStop": { "properties": { "name": "60201234", // DIVA number "title": "Stephansplatz", // Stop name "attributes": { "rbl": 252 } }, "geometry": { "coordinates": [16.3726, 48.2085] // lon, lat (WGS84) } }, "lines": [{ "name": "U1", "towards": "Leopoldau", "direction": "H", // H=hin, R=retour "type": "ptMetro", "barrierFree": true, "realtimeSupported": true, "trafficjam": false, "departures": { "departure": [{ "departureTime": { "timePlanned": "2025-01-08T19:30:00.000+0100", "timeReal": "2025-01-08T19:31:30.000+0100", "countdown": 3 // minutes until departure } }] } }] }] }, "message": { "value": "OK", "messageCode": 1 } } ```
### 关键字段
| 字段 | 描述 | |-------|-------------| | `countdown` | 距离发车的分钟数 | | `timePlanned` | 计划发车时间 | | `timeReal` | 实时预测时间(如可用)| | `barrierFree` | 无障碍通道(轮椅可用)| | `trafficjam` | 影响到达的交通拥堵 | | `type` | `ptMetro`, `ptTram`, `ptBusCity`, `ptBusNight` |
---
## 2. 故障中断 (`/trafficInfoList`)
获取所有当前的服务故障中断。
### 请求
```bash # All disruptions curl -s "https://www.wienerlinien.at/ogd_realtime/trafficInfoList"
# Filter by line curl -s "https://www.wienerlinien.at/ogd_realtime/trafficInfoList?relatedLine=U3&relatedLine=U6"
# Filter by stop curl -s "https://www.wienerlinien.at/ogd_realtime/trafficInfoList?relatedStop=252"
# Filter by type curl -s "https://www.wienerlinien.at/ogd_realtime/trafficInfoList?name=aufzugsinfo" ```
### 参数
| 参数 | 描述 | |-------|-------------| | `relatedLine` | 线路名称(U1, 13A 等)- 可重复 | | `relatedStop` | RBL 站点 ID - 可重复 | | `name` | 类别:`stoerunglang`, `stoerungkurz`, `aufzugsinfo`, `fahrtreppeninfo` |
### 响应
```json { "data": { "trafficInfos": [{ "name": "eD_23", "title": "Gumpendorfer Straße", "description": "U6 Bahnsteig Ri. Siebenhirten - Aufzug außer Betrieb", "priority": "1", "time": { "start": "2025-01-08T06:00:00.000+0100", "end": "2025-01-08T22:00:00.000+0100" }, "relatedLines": ["U6"], "relatedStops": [4611], "attributes": { "status": "außer Betrieb", "station": "Gumpendorfer Straße", "location": "U6 Bahnsteig Ri. Siebenhirten" } }], "trafficInfoCategories": [{ "id": 1, "name": "aufzugsinfo", "title": "Aufzugsstörungen" }] } } ```
### 故障中断类别
| 名称 | 描述 | |------|-------------| | `stoerunglang` | 长期故障中断 | | `stoerungkurz` | 短期故障中断 | | `aufzugsinfo` | 电梯停运 | | `fahrtreppeninfo` | 自动扶梯停运 |
---
## 3. 特定故障中断 (`/trafficInfo`)
按名称获取特定故障中断的详细信息。
```bash curl -s "https://www.wienerlinien.at/ogd_realtime/trafficInfo?name=eD_265&name=eD_37" ```
---
## 4. 服务新闻 (`/newsList`)
计划维护、电梯服务窗口、新闻。
```bash # All news curl -s "https://www.wienerlinien.at/ogd_realtime/newsList"
# Filter by line/stop/category curl -s "https://www.wienerlinien.at/ogd_realtime/newsList?relatedLine=U6&name=aufzugsservice" ```
### 类别
| 名称 | 描述 | |------|-------------| | `aufzugsservice` | 计划电梯维护 | | `news` | 一般服务新闻 |
---
## 参考数据 (CSV)
### 站点 - 主要
```bash curl -s "https://www.wienerlinien.at/ogd_realtime/doku/ogd/wienerlinien-ogd-haltepunkte.csv" # StopID;DIVA;StopText;Municipality;MunicipalityID;Longitude;Latitude ```
**StopID 是 API 调用中使用的 RBL 编号。**
### 车站
```bash curl -s "https://www.wienerlinien.at/ogd_realtime/doku/ogd/wienerlinien-ogd-haltestellen.csv" # DIVA;PlatformText;Municipality;MunicipalityID;Longitude;Latitude ```
### 线路
```bash curl -s "https://www.wienerlinien.at/ogd_realtime/doku/ogd/wienerlinien-ogd-linien.csv" # LineID;LineText;SortingHelp;Realtime;MeansOfTransport ```
**MeansOfTransport:** `ptMetro`, `ptTram`, `ptBusCity`, `ptBusNight`
---
## 常见用例
### "Stephansplatz 下一班 U1 什么时候到?"
```bash # Stephansplatz U1 platform RBL: 4116 curl -s "https://www.wienerlinien.at/ogd_realtime/monitor?stopId=4116" | jq '.data.monitors[].lines[] | select(.name=="U1") | {line: .name, towards: .towards, departures: [.departures.departure[].departureTime.countdown]}' ```
### "U-Bahn 有故障中断吗?"
```bash curl -s "https://www.wienerlinien.at/ogd_realtime/trafficInfoList?relatedLine=U1&relatedLine=U2&relatedLine=U3&relatedLine=U4&relatedLine=U6" | jq '.data.trafficInfos[] | {title, description, lines: .relatedLines}' ```
### "哪些电梯停止服务?"
```bash curl -s "https://www.wienerlinien.at/ogd_realtime/trafficInfoList?name=aufzugsinfo" | jq '.data.trafficInfos[] | {station: .attributes.station, location: .attributes.location, status: .attributes.status}' ```
### "包含所有故障信息的 Karlsplatz 发车信息"
```bash curl -s "https://www.wienerlinien.at/ogd_realtime/monitor?stopId=143&stopId=144&stopId=4101&stopId=4102&activateTrafficInfo=stoerungkurz&activateTrafficInfo=stoerunglang&activateTrafficInfo=aufzugsinfo" ```
---
## 错误代码
| 代码 | 含义 | |------|---------| | 311 | 数据库不可用 | | 312 | 站点不存在 | | 316 | 超出速率限制 | | 320 | 无效的查询参数 | | 321 | 缺少必填参数 | | 322 | 数据库中无数据 |
---
## 车辆类型
| 类型 | 描述 | |------|-------------| | `ptMetro` | 地铁 | | `ptTram` | 有轨电车 | | `ptBusCity` | 市区巴士 | | `ptBusNight` | 夜间巴士(N 线路)|
---
## 提示
1. **多个站台**:单个车站可能有多个 RBL ID(每个站台/方向一个)。查询所有 ID 以获取完整的发车信息。
2. **实时可用性**:检查 `realtimeSupported` - 某些线路只有计划时间。
3. **countdown 与 timeReal**:使用 `countdown` 进行显示,使用 `timeReal` 获取精确时间。
4. **无障碍路线**:轮椅使用者请过滤 `barrierFree: true`。
5. **查找站点 ID**:按车站名称搜索 CSV 文件,然后使用 StopID 作为 `stopId` 参数。