Knowledge Base
Technical guides, tutorials, and documentation to help you integrate Belgian public transport data into your applications.
Quick Navigation
Understanding GTFS
What is GTFS?
GTFS (General Transit Feed Specification) is a common format for public transportation schedules and associated geographic information. Originally developed by Google, it's now the industry standard for transit data.
GTFS consists of:
- Static data: Routes, stops, schedules, fares
- Real-time data: Live vehicle positions, delays, alerts
GTFS File Structure
A GTFS dataset is a ZIP file containing CSV files:
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
Working with GTFS Data
Essential Files
- 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
Optional Files
- calendar.txt: Service days for routes
- shapes.txt: Route paths for mapping
- fare_attributes.txt: Fare information
- transfers.txt: Transfer rules between routes
API Documentation
GTFS Static API
Download complete schedule data for all operators.
GET https://opendata-discovery-gtfs-static.api.production.belgianmobility.io/api/gtfs/feed/delijn/static GET https://datasets.api.production.belgianmobility.io/api/datasets-static/gtfs GET https://opendata-discovery-gtfs-static.api.production.belgianmobility.io/api/gtfs/feed/tec/static GET https://opendata-discovery-gtfs-static.api.production.belgianmobility.io/api/gtfs/feed/nmbssncb/static
Returns: ZIP file containing GTFS data
GTFS Real-time API
Access live trip updates and service alerts.
GET https://opendata-discovery-gtfs-realtime.api.production.belgianmobility.io/api/gtfs-rt/{agencyId}/TripUpdates.pbf
GET https://opendata-discovery-gtfs-realtime.api.production.belgianmobility.io/api/gtfs-rt/{agencyId}/ServiceAlerts.pbf
# Agency IDs: nmbssncb, tec, delijn
# Note: STIB-MIVB does not produce GTFS-RT feeds
Returns: Protocol Buffer format
SIRI API
SIRI 2.1 Estimated Timetable, Situation Exchange and Vehicle Monitoring, generated from GTFS Real-time.
GET https://api-management-discovery-production.azure-api.net/api/siri/feed/{agencyId}/estimated-timetable
GET https://api-management-discovery-production.azure-api.net/api/siri/feed/{agencyId}/situation-exchange
GET https://api-management-discovery-production.azure-api.net/api/siri/feed/tec/vehicle-monitoring
# Agency IDs: nmbssncb, tec, delijn
# Add ?format=json for JSON instead of XML
Returns: SIRI ServiceDelivery in XML (default) or JSON (?format=json)
STIB Specific APIs
Brussels-specific data feeds with enhanced information.
GET /api/stib/waiting-times GET /api/stib/vehicle-positions GET /api/stib/messages
Returns: JSON format
Data Quality & Cleaning
Our Data Processing Pipeline
We implement comprehensive data quality checks and cleaning processes to ensure reliable, consistent data across all operators.
Validation Steps
- GTFS format compliance checking
- Geographic coordinate validation
- Schedule consistency verification
- Stop name and ID standardization
Data Enhancements
- Route shape optimization
- Multi-language support
- Accessibility information
- Cross-operator transfer rules
Best Practices for Using Our Data
- β’ Always validate GTFS feeds before using in production
- β’ Cache data appropriately to reduce API calls
- β’ Handle real-time data delays and missing information gracefully
- β’ Subscribe to our status page for maintenance notifications
Known data quality issues
This log lists operator-side issues we already know about in the public feeds. We keep it up to date in Notion so you can see at a glance what is already being tracked β for example unreliable platform codes, delayed publishes, or identifier mismatches.
Code Samples & Tutorials
Python: Fetching GTFS Data
Download and process GTFS data using Python.
import requests
import zipfile
import pandas as pd
from io import BytesIO
# Download a GTFS static feed: delijn, nmbssncb, stibmivb or tec
def download_gtfs(operator="tec"):
url = f"https://api-management-discovery-production.azure-api.net/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())
import requests
import zipfile
import pandas as pd
from io import BytesIO
# Your key goes in the "bmc-partner-key" header
# (not in "Ocp-Apim-Subscription-Key", the Azure default)
API_KEY = "YOUR_API_KEY"
# Download a GTFS static feed: delijn, nmbssncb, stibmivb or tec
def download_gtfs(operator="tec"):
url = f"https://api.belgianmobility.io/api/gtfs/feed/{operator}/static"
response = requests.get(url, headers={"bmc-partner-key": API_KEY})
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())
Send your key in the bmc-partner-key header.
JavaScript: Real-time Vehicle Positions
Fetch and display real-time vehicle positions using JavaScript.
// Fetch real-time vehicle positions (GTFS-RT, served as JSON by default)
async function getVehiclePositions(operator = 'tec') {
const url = `https://api-management-discovery-production.azure-api.net/api/gtfs/feed/${operator}/rt/vehicle-position`;
const response = await fetch(url);
if (!response.ok) {
throw new Error(`Request failed: ${response.status}`);
}
const feed = await response.json();
return feed.entity.map(({ vehicle }) => ({
vehicleId: vehicle.vehicle.id,
routeId: vehicle.trip.routeId,
latitude: vehicle.position.latitude,
longitude: vehicle.position.longitude
}));
}
// List the vehicles currently on the network
getVehiclePositions('tec')
.then(vehicles => {
console.log(`Found ${vehicles.length} vehicles`);
console.log(vehicles.slice(0, 5));
})
.catch(error => {
console.error('Error fetching vehicle positions:', error);
});
// Your key goes in the "bmc-partner-key" header
// (not in "Ocp-Apim-Subscription-Key", the Azure default)
const API_KEY = 'YOUR_API_KEY';
// Fetch real-time vehicle positions (GTFS-RT, served as JSON by default)
async function getVehiclePositions(operator = 'tec') {
const url = `https://api.belgianmobility.io/api/gtfs/feed/${operator}/rt/vehicle-position`;
const response = await fetch(url, {
headers: { 'bmc-partner-key': API_KEY }
});
if (!response.ok) {
throw new Error(`Request failed: ${response.status}`);
}
const feed = await response.json();
return feed.entity.map(({ vehicle }) => ({
vehicleId: vehicle.vehicle.id,
routeId: vehicle.trip.routeId,
latitude: vehicle.position.latitude,
longitude: vehicle.position.longitude
}));
}
// List the vehicles currently on the network
getVehiclePositions('tec')
.then(vehicles => {
console.log(`Found ${vehicles.length} vehicles`);
console.log(vehicles.slice(0, 5));
})
.catch(error => {
console.error('Error fetching vehicle positions:', error);
});
Send your key in the bmc-partner-key header.
cURL: API Examples
Command-line examples for accessing our APIs.
# Download GTFS static data: delijn, nmbssncb, stibmivb or tec
curl -o gtfs-tec.zip "https://api-management-discovery-production.azure-api.net/api/gtfs/feed/tec/static"
# Get real-time trip updates (JSON by default)
curl "https://api-management-discovery-production.azure-api.net/api/gtfs/feed/tec/rt/trip-update"
# Same feed as Protocol Buffers
curl -o trip-update.pbf "https://api-management-discovery-production.azure-api.net/api/gtfs/feed/tec/rt/trip-update?format=protobuf"
# Get STIB-MIVB waiting times (JSON)
curl "https://api-management-discovery-production.azure-api.net/api/datasets/stibmivb/rt/WaitingTimes"
# Your key goes in the "bmc-partner-key" header
# (not in "Ocp-Apim-Subscription-Key", the Azure default)
API_KEY="YOUR_API_KEY"
# Download GTFS static data: delijn, nmbssncb, stibmivb or tec
curl -o gtfs-tec.zip "https://api.belgianmobility.io/api/gtfs/feed/tec/static" \
-H "bmc-partner-key: $API_KEY"
# Get real-time trip updates (JSON by default)
curl "https://api.belgianmobility.io/api/gtfs/feed/tec/rt/trip-update" \
-H "bmc-partner-key: $API_KEY"
# Same feed as Protocol Buffers
curl -o trip-update.pbf "https://api.belgianmobility.io/api/gtfs/feed/tec/rt/trip-update?format=protobuf" \
-H "bmc-partner-key: $API_KEY"
# Get STIB-MIVB waiting times (JSON)
curl "https://api.belgianmobility.io/api/datasets/stibmivb/rt/WaitingTimes" \
-H "bmc-partner-key: $API_KEY"
Send your key in the bmc-partner-key header.
Need More Help?
Can't find what you're looking for? Our team is here to help you integrate Belgian transport data successfully.