Skip to main content
Glama

@shadojus/open-transit-radar

Zero-dependency Worldwide Public Transit engine: global rail/metro hubs, GTFS CSV/TSV → node:sqlite compiler, curated official GTFS/GTFS-RT feed directory, allowlisted live departure adapters (Entur Norway GraphQL & Swiss OpenTransportData/stationboard), REST OpenAPI 3.1 server, CLI, MCP 2024-11-05 stdio server, Python stdlib client, and Dark-Instrument Split-Flap Radar UI.

  • Zero runtime dependencies ("dependencies": {} in Node 22.5+/24; Python 3.9+ stdlib only)

  • 99 global rail/metro/tram/ferry hubs across DE, AT, CH, FR, GB, NO, SE, FI, NL, US, JP, AU

  • 41 curated official open transit feeds (Mobility Database CC0-1.0, DELFI DE / gtfs.de, OpenTransportData.swiss, Entur NO, SNCF/PAN FR, TfL/BODS GB, Trafiklab SE, HSL/Digitransit FI, OVapi NL, MTA/MBTA/CTA/BART/KCM/WMATA US, GTFS-JP/ODPT JP, TfNSW/PTV/TransLink AU)

  • GTFS → node:sqlite compiler (stops.txt, routes.txt, trips.txt, stop_times.txt, calendar.txt)

  • Strict HTTPS allowlist for live departures (api.entur.io, transport.opendata.ch, api.opentransportdata.swiss)


Quick Start (Node ESM)

import {
  stopsNear,
  searchStops,
  departures,
  listFeeds,
  importGtfsDirectory,
} from "@shadojus/open-transit-radar";

// 1. Nearby global transit hubs (haversine km)
const nearby = stopsNear(52.52, 13.405, { radiusKm: 10, mode: "rail" });

// 2. Diacritic-insensitive search
const matches = searchStops("zurich"); // finds Zürich HB

// 3. Upcoming departures (offline deterministic schedule, or live: true for CH/NO)
const board = await departures("ch-zrh-hb", { limit: 10, live: false });

// 4. Curated official open GTFS / GTFS-RT feed directory
const rtFeeds = listFeeds({ country: "DE", realtimeOnly: true });

// 5. Compile any local GTFS directory into node:sqlite
const stats = importGtfsDirectory("./my-gtfs-feed", "./transit.sqlite");
const fromSqlite = await departures("STOP_1", { sqlitePath: "./transit.sqlite" });

Related MCP server: gtfs-pro-mcp

CLI

npx @shadojus/open-transit-radar near 52.52 13.405 --radius-km 10 --json
npx @shadojus/open-transit-radar search zurich
npx @shadojus/open-transit-radar departures de-ber-hbf --limit 8
npx @shadojus/open-transit-radar departures no-osl-s --live
npx @shadojus/open-transit-radar feeds --country CH --realtime
npx @shadojus/open-transit-radar import-gtfs ./gtfs-dir ./transit.sqlite
npx @shadojus/open-transit-radar serve --port 8787

REST API (OpenAPI 3.1.0)

Start the server (npm start or open-transit-radar serve --port 8787):

Method & Path

Description

GET /health

Service status & dataset counts

GET /openapi.json

OpenAPI 3.1.0 specification

GET /v1/stops?q=&country=&mode=&limit=

Diacritic-insensitive stop search

GET /v1/stops/near?lat=&lng=&radiusKm=&mode=&country=&limit=

Nearby stops sorted by distanceKm

GET /v1/stops/:id/departures?at=&limit=&live=

Offline schedule or live Entur/CH departures

GET /v1/feeds?country=&realtimeOnly=&format=

Curated official GTFS/GTFS-RT feed directory

GET /v1/sources

Data sources, licenses, and live host allowlist

Features: CORS headers, SHA-256 ETag with If-None-Match → 304 Not Modified, and IPv6 /64 subnet rate limiting (429 Too Many Requests).

MCP Server (2024-11-05 stdio)

{
  "mcpServers": {
    "open-transit-radar": {
      "command": "npx",
      "args": ["-y", "@shadojus/open-transit-radar", "--mcp"]
    }
  }
}

Exposed tools: stops_near, search_stops, departures, list_feeds, list_sources.

Python Client (shadojus-transit-radar)

Zero external dependencies (Python 3.9+ stdlib only):

from shadojus_transit_radar import stops_near, search_stops, departures, list_feeds, TransitRadarClient

print(stops_near(52.52, 13.405, radius_km=15))
print(search_stops("zurich"))
print(departures("de-ber-hbf", limit=5))
print(list_feeds(country="NO", realtime_only=True))

Interactive Split-Flap Radar UI (docs/)

Static GitHub Pages application (docs/index.html) featuring a Dark-Instrument #07090E world hub radar, split-flap departure board (live transport.opendata.ch & api.entur.io with automatic offline schedule fallback), filterable feed directory, and copyable npx/curl/MCP/Python snippets with zero external CDNs.

Data Sources & Attribution

See data/SOURCES.json for full upstream licensing and attribution details. Bundled timetable patterns in data/seed.json are illustrative offline samples; use --live or import an official GTFS feed via importGtfsDirectory() for authoritative schedules.

Testing

node --test test/*.test.mjs
python -m unittest discover -s python/tests

License

MIT

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers