Kennisbank

Technische gidsen, tutorials en documentatie om Belgische openbaarvervoersgegevens in je toepassingen te integreren.

Snelle navigatie

GTFS begrijpen

Wat is GTFS?

GTFS (General Transit Feed Specification) is een gemeenschappelijk formaat voor openbaarvervoersdienstregelingen en bijbehorende geografische informatie. Oorspronkelijk ontwikkeld door Google, is het nu de industriestandaard voor vervoersdata.

GTFS bestaat uit:

  • Statische data: Routes, haltes, dienstregelingen, tarieven
  • Real-time data: Live voertuigposities, vertragingen, waarschuwingen

GTFS-bestandsstructuur

Een GTFS-dataset is een ZIP-bestand met CSV-bestanden:

gtfs.zip β”œβ”€β”€ agency.txt # Transit agencies β”œβ”€β”€ routes.txt # Transit routes β”œβ”€β”€ trips.txt # Individual trips β”œβ”€β”€ stops.txt # Transit stops β”œβ”€β”€ stop_times.txt # Stop times for trips β”œβ”€β”€ calendar.txt # Service patterns β”œβ”€β”€ calendar_dates.txt # Service exceptions └── shapes.txt # Route geometry

Werken met GTFS-gegevens

EssentiΓ«le bestanden

  • agency.txt: Information about transit agencies
  • stops.txt: Individual stops/stations with coordinates
  • routes.txt: Transit routes (bus lines, train routes)
  • trips.txt: Individual journeys along routes
  • stop_times.txt: Times when vehicles arrive/depart stops

Optionele bestanden

  • calendar.txt: Service days for routes
  • shapes.txt: Route paths for mapping
  • fare_attributes.txt: Fare information
  • transfers.txt: Transfer rules between routes

API-documentatie

GTFS statische API

Download volledige dienstregelinggegevens voor alle operatoren.

GET https://opendata-discovery-gtfs-static.api.staging.belgianmobility.io/api/gtfs/feed/delijn/static GET https://datasets.api.staging.belgianmobility.io/api/datasets-static/gtfs GET https://opendata-discovery-gtfs-static.api.staging.belgianmobility.io/api/gtfs/feed/tec/static GET https://opendata-discovery-gtfs-static.api.staging.belgianmobility.io/api/gtfs/feed/nmbssncb/static

Retourneert: ZIP-bestand met GTFS-gegevens

GTFS real-time API

Toegang tot live rit-updates en dienstwaarschuwingen.

GET https://opendata-discovery-gtfs-realtime.api.staging.belgianmobility.io/api/gtfs-rt/{agencyId}/TripUpdates.pbf GET https://opendata-discovery-gtfs-realtime.api.staging.belgianmobility.io/api/gtfs-rt/{agencyId}/ServiceAlerts.pbf # Agency IDs: nmbssncb, tec, delijn # Note: STIB-MIVB does not produce GTFS-RT feeds

Retourneert: Protocol Buffer-formaat

MIVB-specifieke API’s

Brussel-specifieke datafeeds met verrijkte informatie.

GET /api/stib/waiting-times GET /api/stib/vehicle-positions GET /api/stib/messages

Retourneert: JSON-formaat

Datakwaliteit en opschoning

Onze dataverwerkingspijplijn

We voeren uitgebreide kwaliteitscontroles en opschoningsprocessen uit om betrouwbare en consistente gegevens voor alle operatoren te garanderen.

Validatiestappen

  • GTFS format compliance checking
  • Geographic coordinate validation
  • Schedule consistency verification
  • Stop name and ID standardization

Dataverbeteringen

  • Route shape optimization
  • Multi-language support
  • Accessibility information
  • Cross-operator transfer rules

Best practices voor het gebruik van onze data

  • β€’ Valideer GTFS-feeds altijd vΓ³Γ³r gebruik in productie
  • β€’ Cache gegevens op een geschikte manier om API-aanroepen te verminderen
  • β€’ Ga soepel om met real-time vertragingen en ontbrekende informatie
  • β€’ Abonneer je op onze statuspagina voor onderhoudsmeldingen

Codevoorbeelden en tutorials

Python: GTFS-gegevens ophalen

GTFS-gegevens downloaden en verwerken met Python.

import requests import zipfile import pandas as pd from io import BytesIO # Download GTFS data def download_gtfs(operator='tec'): url = f"https://opendata-discovery-gtfs-static.api.staging.belgianmobility.io/api/gtfs/feed/{operator}/static" response = requests.get(url) if response.status_code == 200: return zipfile.ZipFile(BytesIO(response.content)) else: raise Exception(f"Failed to download: {response.status_code}") # Extract and read stops gtfs_zip = download_gtfs('tec') stops_df = pd.read_csv(gtfs_zip.open('stops.txt')) print(f"Found {len(stops_df)} stops") print(stops_df.head())

JavaScript: real-time voertuigposities

Real-time voertuigposities ophalen en weergeven met JavaScript.

// Fetch real-time vehicle positions async function getVehiclePositions() { try { const response = await fetch('/api/gtfs-rt/vehicle-positions'); const data = await response.arrayBuffer(); // Parse Protocol Buffer data (requires protobuf.js) const feed = gtfs.transit_realtime.FeedMessage.decode( new Uint8Array(data) ); return feed.entity.map(entity => ({ vehicleId: entity.vehicle.vehicle.id, routeId: entity.vehicle.trip.routeId, latitude: entity.vehicle.position.latitude, longitude: entity.vehicle.position.longitude, timestamp: entity.vehicle.timestamp })); } catch (error) { console.error('Error fetching vehicle positions:', error); return []; } } // Update map markers getVehiclePositions().then(vehicles => { vehicles.forEach(vehicle => { updateMapMarker(vehicle); }); });

cURL: API-voorbeelden

Commandoregelvoorbeelden voor toegang tot onze API’s.

# Download GTFS static data curl -O "https://datasets.api.staging.belgianmobility.io/api/datasets-static/gtfs" # Get real-time trip updates curl "https://opendata-discovery-gtfs-rt.api.staging.belgianmobility.io/api/gtfs/feed/tec/rt/trip-updates.pbf" \ -H "Accept: application/x-protobuf" # Get STIB waiting times (JSON) curl "https://datasets.api.production.belgianmobility.io/api/datasets/WaitingTimes.json" \ -H "Accept: application/json"

Meer hulp nodig?

Kan je niet vinden wat je zoekt? Ons team helpt je graag om Belgische vervoersgegevens succesvol te integreren.