Skip to content

DubblePumper/NMBS-Train-data

Repository files navigation

NMBS Export Dashboard

Dashboard-only project for exploring NMBS API snapshot exports.

What this project is now

This repository was fully reworked to focus on one thing only:

  • a train-centric dashboard over snapshot data in examples/endpoint_snapshots

Snapshot data can now be refreshed from the official Belgian Mobility Open-Data Portal GTFS feeds for NMBS-SNCB.

Removed from the project:

  • legacy analysis scripts
  • API fetch/services code
  • map generators and unrelated reports
  • extra startup flows

Project structure

NMBS-Train-data/
├── main.py                          # single startup file
├── docker-compose.yml               # easy local run
├── Dockerfile                       # Python 3.14.3 runtime
├── requirements.txt
├── tools/
│   └── fetch_belgian_mobility_snapshot.py
├── docs/
│   └── GTFS_Realtime_Visualization.md
├── examples/
│   └── endpoint_snapshots/
└── src/
    └── nmbs_dashboard/
        ├── wsgi.py                    # Gunicorn WSGI entrypoint
        ├── app/
        │   ├── assets/
        │   ├── callbacks/
        │   ├── layout/
        │   ├── services/
        │   └── server.py
        └── paths.py

Run locally (no Docker)

pip install -r requirements.txt
python main.py

Open: http://localhost:8050

Optional flags:

python main.py --host 0.0.0.0 --port 8050 --debug

Refresh snapshots from Belgian Mobility

The official NMBS-SNCB feeds are exposed through the Belgian Mobility Open-Data Portal. Copy .env.example to .env and fill in your own subscription key if your portal account requires one:

BM_API_KEY=your-subscription-key

Then create a new dashboard snapshot:

python tools/fetch_belgian_mobility_snapshot.py

By default this fetches:

  • GTFS Schedule: /api/gtfs/feed/nmbssncb/static
  • GTFS Realtime trip updates: /api/gtfs/feed/nmbssncb/rt/trip-update
  • GTFS Realtime service alerts: /api/gtfs/feed/nmbssncb/rt/alert

The default gateway is https://api-management-discovery-production.azure-api.net. The *.developer.azure-api.net host is the documentation portal and returns 404 for direct feed downloads.

The raw static GTFS zip is saved in the snapshot folder as gtfs_static.zip. For dashboard speed, the generated planning JSON files store a preview of each GTFS table. Use --row-limit 0 to store all rows, or --static-only to skip realtime feeds.

Run with Docker Compose (recommended)

docker compose up --build

Open: http://localhost:8050

Container runtime details:

  • Python image: 3.14.3-slim
  • Process manager: gunicorn (2 workers, gthread worker class)
  • Runs as a non-root user (app)
  • Healthcheck probes http://127.0.0.1:8050

Stop:

docker compose down

Notes

  • Default snapshot source is examples/endpoint_snapshots.
  • You can override snapshot source with environment variable SNAPSHOT_ROOT.
  • Belgian Mobility configuration is read from .env or environment variables.
  • Do not commit your BM_API_KEY; .env is ignored by git.

Tests

pytest

About

train data from nmbs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors