{"description":"Next departures at a stop in Munich's network like MVG's departure monitor: line, type, direction, platform, planned and live time (epoch milliseconds), delay in minutes, cancellations and notices.","effect":"read","id":"mvg.de/get-departures","keywords":["mvg","abfahrten","abfahrtsmonitor","münchen","munich","u-bahn","s-bahn","tram","bus","departures","next train","live","delay","public transport"],"output":{"schema":{"properties":{"departures":{"items":{"properties":{"cancelled":{"type":"boolean"},"delay_min":{"description":"Only when MVG has live data for this departure","type":["integer","null"]},"direction":{"type":"string"},"line":{"type":"string"},"notices":{"items":{"type":"string"},"type":"array"},"planned_ms":{"type":"integer"},"platform":{"type":["integer","string","null"]},"realtime":{"type":"boolean"},"realtime_ms":{"type":["integer","null"]},"type":{"type":"string"}},"type":"object"},"type":"array"},"station":{"type":"string"}},"type":"object"},"value":"let $types = params.transport_types || `[\"UBAHN\", \"SBAHN\", \"TRAM\", \"BUS\", \"REGIONAL_BUS\", \"BAHN\"]`, $lim = params.limit || `10` in let $all = map(&{line: label, type: transportType, direction: destination, platform: platform || `null`, planned_ms: plannedDepartureTime, realtime_ms: realtimeDepartureTime || `null`, delay_min: (realtime == `true` && floor((realtimeDepartureTime - plannedDepartureTime) / `60000`)) || (realtime == `true` && `0`) || `null`, realtime: realtime == `true`, cancelled: cancelled == `true`, notices: (messages || `[]`)[].text}, steps.departures.list || `[]`)[?contains($types, type)] in {station: join(', ', [steps.stop.name, steps.stop.place]), departures: ($lim == `5` && $all[:5]) || ($lim == `20` && $all[:20]) || $all[:10]}"},"params":{"additionalProperties":false,"properties":{"limit":{"default":10,"enum":[5,10,20],"type":"integer"},"station":{"description":"Stop name, e.g. 'Marienplatz', 'Ostbahnhof'","maxLength":80,"minLength":2,"type":"string"},"transport_types":{"default":["UBAHN","SBAHN","TRAM","BUS","REGIONAL_BUS","BAHN"],"items":{"enum":["UBAHN","SBAHN","TRAM","BUS","REGIONAL_BUS","BAHN","SCHIFF"],"type":"string"},"minItems":1,"type":"array"}},"required":["station"],"type":"object"},"provenance":{"method":"browser-inspect","notes":"MVG's departure monitor calls www.mvg.de/api/bgw-pt/v3/locations?query= and /api/bgw-pt/v3/departures?globalId&limit&transportTypes. Times are epoch milliseconds (plannedDepartureTime, realtimeDepartureTime). Public JSON, answers servers; robots.txt allows everything.","recorded_at":"2026-11-07T19:04:00+01:00","recorded_by":"C4"},"requires_login":false,"schema":"https://wield.run/schema/recipe/v1.json","site":{"country":"DE","id":"mvg.de","language":"de","name":"MVG (Munich public transport)","origin":"https://www.mvg.de","origins":["https://www.mvg.de"]},"steps":[{"description":"MVG's stop search.","expect":{"assert":"length(body[?type == 'STATION']) > `0`","content_type":"json","status":[200]},"extract":{"json":{"id":"[?type == 'STATION'] | [0].globalId","name":"[?type == 'STATION'] | [0].name","place":"[?type == 'STATION'] | [0].place"}},"id":"stop","request":{"headers":{"Accept":"application/json"},"method":"GET","query":{"query":"{{params.station}}"},"url":"/api/bgw-pt/v3/locations"}},{"description":"MVG's departure monitor API. It applies limit before its (loose) transport-type filter, so the recipe asks for 40 and filters and cuts itself.","expect":{"content_type":"json","status":[200]},"extract":{"json":{"list":"@"}},"id":"departures","request":{"headers":{"Accept":"application/json"},"method":"GET","query":{"globalId":"{{steps.stop.id}}","limit":"40","transportTypes":"{{params.transport_types | join:,}}"},"url":"/api/bgw-pt/v3/departures"}}],"task":"Show live departures at a Munich public transport stop","tos":{"notes":"Two small requests per run, the same ones the MVG website makes.","reviewed":false},"verify":{"checks":["length(output.departures) > `3`","output.departures[0].planned_ms > `1700000000000`","length(output.departures[?line != `null`]) == length(output.departures)","contains(output.station, 'Marienplatz')"],"example_params":{"limit":10,"station":"Marienplatz"},"max_ms":3000},"version":1}