SDKs overview
Transport for Bordeaux, France, through the Bordeaux Métropole open data initiative, provides public transport data primarily in General Transit Feed Specification (GTFS) and GTFS Realtime (GTFS-RT) formats. These standardized specifications are widely adopted for conveying public transit information, including schedules, routes, stops, and real-time vehicle positions. While Transport for Bordeaux, France does not publish proprietary SDKs, the open nature of GTFS and GTFS-RT means that a variety of community-developed libraries and general-purpose parsers are available across multiple programming languages.
Developers working with Transport for Bordeaux, France data will typically use existing GTFS/GTFS-RT parsing libraries to consume the datasets provided on the Bordeaux Métropole data portal. This approach allows for rapid integration into applications, leveraging established tools for data handling and interpretation. The focus is on interoperability and adherence to open standards, rather than vendor-specific client libraries.
Official SDKs by language
Transport for Bordeaux, France does not offer official, proprietary SDKs for specific programming languages. Instead, it provides raw data feeds compliant with GTFS and GTFS-RT specifications. This strategy aligns with the principles of open data, encouraging community development of tools and libraries. Developers are expected to utilize existing open-source libraries that support GTFS and GTFS-RT parsing.
The table below outlines common approaches and widely used open-source libraries that are compatible with Transport for Bordeaux, France's data feeds. These are not 'official' in the sense of being developed by Bordeaux Métropole, but they are the standard tools developers use to interact with GTFS and GTFS-RT data.
| Language | Package/Approach | Install Command Example | Maturity |
|---|---|---|---|
| Python | gtfs-realtime-bindings |
pip install gtfs-realtime-bindings |
Stable |
| Java | onebusaway-gtfs-realtime-bindings |
Maven/Gradle dependency | Stable |
| JavaScript (Node.js) | gtfs-rt-bindings |
npm install gtfs-rt-bindings |
Active |
| C#/.NET | GtfsRealtimeBindings |
dotnet add package GtfsRealtimeBindings |
Stable |
| Ruby | gtfs-realtime-bindings |
gem install gtfs-realtime-bindings |
Stable |
Installation
Installation typically involves adding a dependency to your project using the language's package manager. The following examples demonstrate how to install common GTFS-RT parsing libraries.
Python Installation
For Python, the gtfs-realtime-bindings library is a common choice for parsing GTFS-RT feeds. It provides protocol buffer definitions for the GTFS-RT specification.
pip install gtfs-realtime-bindings
This command downloads and installs the necessary Python package and its dependencies from PyPI, making the GTFS-RT message definitions available for use in your Python projects. Before running this, ensure you have Python and pip installed on your system.
Java Installation
For Java projects, you can add onebusaway-gtfs-realtime-bindings as a dependency using Maven or Gradle. This library provides Java classes generated from the GTFS-RT protocol buffer definition.
Maven
<dependency>
<groupId>org.onebusaway</groupId>
<artifactId>onebusaway-gtfs-realtime-bindings</artifactId>
<version>1.3.1</version> <!-- Use the latest version -->
</dependency>
Gradle
implementation 'org.onebusaway:onebusaway-gtfs-realtime-bindings:1.3.1' // Use the latest version
After adding the dependency to your pom.xml (Maven) or build.gradle (Gradle) file, your build tool will automatically download the library when you build your project.
JavaScript (Node.js) Installation
For Node.js environments, the gtfs-rt-bindings package can be installed via npm. This package provides JavaScript classes for parsing GTFS-RT data.
npm install gtfs-rt-bindings
This command adds the package to your project's node_modules directory and updates your package.json file. Ensure Node.js and npm are installed on your development machine.
Quickstart example
This Python example demonstrates how to fetch and parse a GTFS-RT feed, such as the real-time vehicle positions for Transport for Bordeaux, France. You would replace 'YOUR_GTFS_RT_FEED_URL' with the actual URL provided by Bordeaux Métropole for real-time data.
import requests
from google.transit import gtfs_realtime_pb2
def get_realtime_data(feed_url):
try:
response = requests.get(feed_url, timeout=10)
response.raise_for_status() # Raise an exception for HTTP errors
feed = gtfs_realtime_pb2.FeedMessage()
feed.ParseFromString(response.content)
print(f"Successfully parsed GTFS-RT feed from {feed_url}")
print(f"Header timestamp: {feed.header.timestamp}")
for entity in feed.entity:
if entity.HasField('trip_update'):
trip_id = entity.trip_update.trip.trip_id
route_id = entity.trip_update.trip.route_id
start_time = entity.trip_update.trip.start_time
print(f" Trip Update: Trip ID={trip_id}, Route ID={route_id}, Start Time={start_time}")
for stop_time_update in entity.trip_update.stop_time_update:
arrival = stop_time_update.arrival.delay if stop_time_update.HasField('arrival') and stop_time_update.arrival.HasField('delay') else 'N/A'
departure = stop_time_update.departure.delay if stop_time_update.HasField('departure') and stop_time_update.departure.HasField('delay') else 'N/A'
print(f" Stop ID: {stop_time_update.stop_id}, Arrival Delay: {arrival}s, Departure Delay: {departure}s")
elif entity.HasField('vehicle'):
vehicle_id = entity.vehicle.vehicle.id
position = entity.vehicle.position
latitude = position.latitude
longitude = position.longitude
print(f" Vehicle Position: ID={vehicle_id}, Lat={latitude}, Lon={longitude}")
elif entity.HasField('alert'):
alert_text = entity.alert.description_text.translation[0].text if entity.alert.description_text.translation else 'No description'
print(f" Alert: {alert_text}")
except requests.exceptions.RequestException as e:
print(f"Error fetching GTFS-RT feed: {e}")
except Exception as e:
print(f"Error parsing GTFS-RT feed: {e}")
# Replace with the actual GTFS-RT feed URL for Transport for Bordeaux, France
# You can find this URL on the Bordeaux Métropole open data portal's documentation for real-time data.
# Example (hypothetical, verify actual URL from Bordeaux Métropole open data portal):
# BORDEAUX_GTFS_RT_URL = "https://data.bordeaux-metropole.fr/files/gtfs-rt/vehicle_positions.pb"
# For demonstration, use a placeholder. Please obtain the real URL from the official source.
BORDEAUX_GTFS_RT_URL = "https://example.com/bordeaux-tbm-gtfs-rt-feed"
if __name__ == "__main__":
get_realtime_data(BORDEAUX_GTFS_RT_URL)
This script first imports the requests library to fetch the data and google.transit.gtfs_realtime_pb2 for parsing the protobuf message. It then defines a function get_realtime_data that takes the feed URL, makes an HTTP GET request, and parses the binary response into a FeedMessage object. The script iterates through the entities in the feed, printing out details about trip updates, vehicle positions, and alerts if they exist. Remember to substitute BORDEAUX_GTFS_RT_URL with the live data feed URL found on the Bordeaux Métropole Open Data portal documentation for real-time data feeds, as the example URL is illustrative.
Community libraries
The open nature of GTFS and GTFS-RT fosters a rich ecosystem of community-developed libraries across various programming languages. These libraries often provide more high-level abstractions and utilities beyond the basic protocol buffer bindings, simplifying common tasks like filtering data, calculating routes, or visualizing transit information.
- Python: Beyond
gtfs-realtime-bindings, libraries likeGTFS-Feed(for static GTFS parsing) and various geospatial libraries (e.g.,geopandas,folium) are frequently used in conjunction to analyze and display transit data. Many developers also create custom scripts that integrate with mapping services or data visualization tools. - JavaScript: For web-based applications, libraries such as
gtfs-utilsor client-side GTFS-RT parsers can be used. Coupled with mapping libraries like ArcGIS API for JavaScript or Leaflet, these enable interactive maps showing real-time vehicle movements or static route information. - Ruby: The
gtfs-rubygem is another option for working with static GTFS data, providing an object-oriented interface for parsing and querying schedules, routes, and stops. - Go: For high-performance backend services, Go libraries like
google/go-gtfs(for static GTFS) or direct protocol buffer compilation for GTFS-RT offer efficient parsing and data handling capabilities.
When selecting a community library, consider its active maintenance, community support, and specific features that align with your project requirements. Many of these libraries are available on public repositories like GitHub, where you can review their source code and community contributions.