Metro Mobilite Open Data API
The Metro Mobilite Open Data API allows developers to access up-to-date information about public transportation services in Grenoble, France. This API provides multiple endpoints for retrieving data such as real-time schedules, routes, stops, and more.
Getting Started
To use the Metro Mobilite Open Data API, follow these steps:
- Sign up for an API key at the Metro Mobilite Open Data website.
- Read the documentation to understand the API endpoints and how to use them.
- Start making API requests using the provided key.
API Endpoints
Real-Time Schedules
This endpoint returns information about schedules for a given stop in real-time. You can query data for the current moment or for future dates.
https://ws.infotbm.com/ws/1.0/getNextDepartures?key={API_Key}&stopAreaId={Stop_Id}&departureDatetime={Datetime}
Parameters
API_Key
: Your API key.Stop_Id
: The ID of the stop you want to retrieve schedules for.Datetime
: The date and time you want to retrieve schedules for, in ISO 8601 format (e.g.2022-01-31T14:30:00.000Z
).
Example
Here’s an example of sending a request to get the next departures for a specific stop, using JavaScript:
const apiKey = 'your_api_key';
const stopId = 'your_stop_id';
const datetime = '2022-01-31T14:30:00.000Z';
const apiEndpoint = `https://ws.infotbm.com/ws/1.0/getNextDepartures?key=${apiKey}&stopAreaId=${stopId}&departureDatetime=${datetime}`;
fetch(apiEndpoint)
.then((response) => response.json())
.then((data) => console.log(data))
.catch((error) => console.error(error));
Routes
This endpoint returns information about all routes available in the city.
https://ws.infotbm.com/ws/1.0/getLines?key={API_Key}
Parameters
API_Key
: Your API key.
Example
Here’s an example of sending a request to get all the routes in the city, using JavaScript:
const apiKey = 'your_api_key';
const apiEndpoint = `https://ws.infotbm.com/ws/1.0/getLines?key=${apiKey}`;
fetch(apiEndpoint)
.then((response) => response.json())
.then((data) => console.log(data))
.catch((error) => console.error(error));
Stops
This endpoint returns information about all stops for a specific route.
https://ws.infotbm.com/ws/1.0/getStops?key={API_Key}&lineId={Route_Id}
Parameters
API_Key
: Your API key.Route_Id
: The ID of the route you want to retrieve stops for.
Example
Here’s an example of sending a request to get all stops for a specific route, using JavaScript:
const apiKey = 'your_api_key';
const routeId = 'your_route_id';
const apiEndpoint = `https://ws.infotbm.com/ws/1.0/getStops?key=${apiKey}&lineId=${routeId}`;
fetch(apiEndpoint)
.then((response) => response.json())
.then((data) => console.log(data))
.catch((error) => console.error(error));
Conclusion
The Metro Mobilite Open Data API is a great resource for developers to build applications that involve public transportation data. With the provided endpoints, you can retrieve real-time schedules, routes, and stop information easily. Happy coding!