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://belgianmobility.blob.core.windows.net/gtfs/production/gtfs-delijn-bmc-latest.zip GET https://belgianmobility.blob.core.windows.net/gtfs/production/gtfs-stibmivb-bmc-latest.zip GET https://belgianmobility.blob.core.windows.net/gtfs/production/gtfs-tec-bmc-latest.zip GET https://belgianmobility.blob.core.windows.net/gtfs/production/gtfs-nmbssncb-bmc-latest.zip

Returns: ZIP file containing GTFS data

GTFS Real-time API

Access live trip updates and service alerts.

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

Returns: Protocol Buffer format

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

Authentication & Rate Limits

Public APIs

  • • No authentication required
  • • Rate limit: 1000 requests/hour
  • • GTFS downloads: 10/day per IP
  • • Real-time feeds: 120 requests/minute

Premium APIs

  • • API key authentication required
  • • Higher rate limits based on plan
  • • Historical data access
  • • Priority support

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

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 GTFS data def download_gtfs(operator='delijn'): url = f"https://belgianmobility.blob.core.windows.net/gtfs/production/gtfs-{operator}-bmc-latest.zip" 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('delijn') stops_df = pd.read_csv(gtfs_zip.open('stops.txt')) print(f"Found {len(stops_df)} stops") print(stops_df.head())

JavaScript: Real-time Vehicle Positions

Fetch and display real-time vehicle positions using 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 Examples

Command-line examples for accessing our APIs.

# Download GTFS static data curl -O "https://belgianmobility.blob.core.windows.net/gtfs/production/gtfs-stibmivb-bmc-latest.zip" # Get real-time trip updates curl "https://gtfs-rt.api.production.belgianmobility.io/tec/TripUpdates.pbf" \ -H "Accept: application/x-protobuf" # Get STIB waiting times (JSON) curl "https://api.belgianmobility.be/api/stib/waiting-times?stop_id=8754" \ -H "Accept: application/json" # Premium API with authentication curl "https://api.belgianmobility.be/api/premium/historical" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Accept: application/json"

Need More Help?

Can't find what you're looking for? Our team is here to help you integrate Belgian transport data successfully.