Skip to content

DM-Request (Abfahrtsmonitor)

Liefert Abfahrten/Ankünfte an einer Haltestelle für das Monitoring (z. B. "Abfahrtsmonitor").

Endpoint

  • Pfad: XML_DM_REQUEST
  • Methode: GET

Wichtige Parameter (Auszug)

ParameterTypBeschreibung
stopIdstringHaltestellen-ID
timestringZeit HHMM (optional – sonst jetzt)
datestringDatum YYYYMMDD (optional – sonst heute)
limitnumberMaximale Anzahl Abfahrten
rt0/1Echtzeitinformationen einbeziehen

Beispiel-Request

GET /XML_DM_REQUEST?stopId=de:05513:1001&limit=20&rt=1

Antwort (vereinfachtes Beispiel)

json
{
  "departures": [
    { "line": "196", "dir": "Kray", "time": "08:22", "rtTime": "08:24", "platform": "1" }
  ]
}

JavaScript-Beispiele

js
async function loadDepartures(stopId, { limit = 10, rt = 1 } = {}) {
  const baseUrl = 'https://server:port/virtuellesVerzeichnis/XML_DM_REQUEST'
  const usp = new URLSearchParams({ stopId, limit: String(limit), rt: String(rt) })
  const res = await fetch(`${baseUrl}?${usp}`)
  if (!res.ok) throw new Error('Network error')
  return res.json()
}

async function renderDepartures(container, stopId) {
  const data = await loadDepartures(stopId, { limit: 8, rt: 1 })
  container.innerHTML = data.departures.map(d => `
    <li>
      <strong>${d.line}</strong> → ${d.dir}
      <span>${d.rtTime ?? d.time}</span>
      <small>Gl. ${d.platform ?? '-'}</small>
    </li>
  `).join('')
}
ts
import LRU from 'lru-cache'

const cache = new LRU<string, any>({ max: 100, ttl: 15_000 }) // 15s
const baseUrl = 'https://server:port/virtuellesVerzeichnis/XML_DM_REQUEST'

export async function getDeparturesCached(stopId: string) {
  const key = `dm:${stopId}`
  const hit = cache.get(key)
  if (hit) return hit
  const res = await fetch(`${baseUrl}?stopId=${encodeURIComponent(stopId)}&limit=10&rt=1`)
  const data = await res.json()
  cache.set(key, data)
  return data
}

Hinweise

  • Bei großen Bahnhöfen kann die Plattform/Steig variieren. Aktualisieren Sie in kurzen Intervallen und zeigen Sie Echtzeit an.