SDKs overview
Vélib' Métropole, the public bike-sharing service in Paris, provides its core service through physical stations and a mobile application. For developers seeking to integrate Vélib' data into their own applications, direct SDKs from Vélib' Métropole are not the primary access point. Instead, the real-time operational data for Vélib' stations, such as the number of available bikes and empty docks, is made publicly accessible through the City of Paris' Open Data platform. This data feed is managed by JCDecaux, the operator of the Vélib' Métropole system, and follows a standardized data format, often JSON or XML, delivered via a RESTful API endpoint.
Developers typically interact with this data using standard HTTP client libraries in their preferred programming language, or through community-developed SDKs and wrappers that simplify the process of fetching and parsing this information. These libraries abstract the underlying API calls, providing language-specific methods for data retrieval. The focus of these SDKs is predominantly on accessing dynamic station availability and static station information, enabling developers to build features like bike-finding applications, predictive models for station occupancy, or integration into broader transit planning tools.
Official SDKs by language
The City of Paris Open Data platform, which hosts the Vélib' Métropole data feed, primarily offers direct API access rather than a suite of proprietary SDKs developed by Vélib' Métropole itself. However, the JCDecaux data feed, which powers Vélib' data, is often consumed using standard HTTP/REST libraries across various programming languages. While not branded as 'Vélib' Métropole SDKs', these are the most direct and officially supported methods to consume the data. For structured access, libraries that specifically handle JSON parsing are most common, given the typical data format. The following table outlines the most straightforward ways to interact with the data, considering the official data provider's approach:
| Language | Primary Method / Package | Install Command (Example) | Maturity / Status |
|---|---|---|---|
| Python | requests (HTTP client) |
pip install requests |
Stable, widely used for API interaction |
| JavaScript (Node.js/Browser) | fetch API / axios (HTTP client) |
npm install axios |
Stable, standard for web API calls |
| Java | java.net.http.HttpClient / OkHttp |
Maven/Gradle dependency for OkHttp | Stable, standard for API integration |
| Ruby | HTTParty / Faraday (HTTP client) |
gem install httparty |
Stable, common in Ruby applications |
These methods allow developers to retrieve the raw JSON data, which can then be parsed to extract specific information about Vélib' stations. For detailed API endpoint information and data schema, developers should consult the Vélib' Métropole Open Data documentation, which points to the City of Paris Open Data portal.
Installation
Installing the necessary tools to access Vélib' Métropole data typically involves setting up an HTTP client library in your development environment. Since direct Vélib' Métropole SDKs are not the primary access method, the installation process focuses on standard package management for common programming languages. This section provides installation instructions for Python and JavaScript, as these are frequently used for web and data-oriented applications.
Python
For Python, the requests library is a widely adopted and user-friendly HTTP client for making API calls.
pip install requests
This command uses pip, Python's package installer, to download and install the requests library and its dependencies. Ensure you have pip installed and consider using a virtual environment to manage dependencies.
JavaScript (Node.js)
For JavaScript environments, particularly Node.js, the axios library is a popular promise-based HTTP client. Alternatively, the native fetch API can be used in modern browser and Node.js (v18+) environments.
npm install axios
This command uses npm, the Node.js package manager, to install axios into your project. For browser-based applications, axios can also be included via CDN or bundled with tools like Webpack or Rollup. The MDN Web Docs provide comprehensive guidance on using the Fetch API directly, which requires no external installation.
Other Languages
For other languages, similar package managers and HTTP client libraries exist:
- Java: Use Maven or Gradle to add dependencies like OkHttp or Apache HttpClient.
- Ruby: Use Bundler (
gem install httpartyorgem install faraday). - PHP: Use Composer (e.g.,
composer require guzzlehttp/guzzle).
The core principle remains consistent: install a robust HTTP client library to make requests to the Velib' Métropole data endpoint.
Quickstart example
This quickstart example demonstrates how to fetch the real-time Vélib' Métropole station data using Python and JavaScript. The data is available via an API endpoint provided by JCDecaux as part of the City of Paris Open Data initiative. You will need an API key, which can be obtained by registering on the Paris Open Data portal. Replace YOUR_API_KEY with your actual key.
Python Quickstart
This Python script uses the requests library to fetch and display the first few Vélib' stations and their current availability.
import requests
import json
# Your JCDecaux API key for Paris
# Obtain one from https://opendata.paris.fr/pages/home/
API_KEY = "YOUR_API_KEY"
CONTRACT_NAME = "paris"
# JCDecaux API endpoint for stations
url = f"https://api.jcdecaux.com/vls/v3/stations?contract={CONTRACT_NAME}&apiKey={API_KEY}"
try:
response = requests.get(url)
response.raise_for_status() # Raise an HTTPError for bad responses (4xx or 5xx)
stations_data = response.json()
print(f"Successfully fetched {len(stations_data)} Vélib' stations.")
print("First 3 stations:")
for station in stations_data[:3]:
print(f" Station Name: {station['name']}")
print(f" Available Bikes (Classic): {station['mainStands']['availabilities']['bikes'] - station['mainStands']['availabilities']['mechanicalBikes']}")
print(f" Available Bikes (Electric): {station['mainStands']['availabilities']['ebikes']}")
print(f" Available Docks: {station['mainStands']['availabilities']['stands']}")
print(f" Status: {'OPEN' if station['status'] == 'OPEN' else 'CLOSED'}")
print("\n")
except requests.exceptions.HTTPError as err:
print(f"HTTP error occurred: {err}")
except requests.exceptions.ConnectionError as err:
print(f"Error Connecting: {err}")
except requests.exceptions.Timeout as err:
print(f"Timeout Error: {err}")
except requests.exceptions.RequestException as err:
print(f"Oops: Something Else {err}")
except json.JSONDecodeError:
print("Failed to decode JSON response. The API might have returned non-JSON data.")
except Exception as e:
print(f"An unexpected error occurred: {e}")
JavaScript (Node.js) Quickstart
This Node.js example uses the axios library to perform a similar data retrieval and display operation.
const axios = require('axios');
// Your JCDecaux API key for Paris
// Obtain one from https://opendata.paris.fr/pages/home/
const API_KEY = 'YOUR_API_KEY';
const CONTRACT_NAME = 'paris';
const url = `https://api.jcdecaux.com/vls/v3/stations?contract=${CONTRACT_NAME}&apiKey=${API_KEY}`;
async function getVelibStations() {
try {
const response = await axios.get(url);
const stationsData = response.data;
console.log(`Successfully fetched ${stationsData.length} Vélib' stations.`);
console.log("First 3 stations:");
for (let i = 0; i < Math.min(3, stationsData.length); i++) {
const station = stationsData[i];
console.log(` Station Name: ${station.name}`);
// Note: JCDecaux API v3 differentiates bikes and e-bikes in availabilities
const availableMechanicalBikes = station.mainStands.availabilities.mechanicalBikes;
const availableEBikes = station.mainStands.availabilities.ebikes;
const availableBikesTotal = availableMechanicalBikes + availableEBikes;
console.log(` Available Bikes (Total): ${availableBikesTotal}`);
console.log(` Available Bikes (Mechanical): ${availableMechanicalBikes}`);
console.log(` Available Bikes (Electric): ${availableEBikes}`);
console.log(` Available Docks: ${station.mainStands.availabilities.stands}`);
console.log(` Status: ${station.status === 'OPEN' ? 'OPEN' : 'CLOSED'}`);
console.log('\n');
}
} catch (error) {
if (error.response) {
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
console.error(`Error fetching data: Status ${error.response.status}, Data: ${JSON.stringify(error.response.data)}`);
} else if (error.request) {
// The request was made but no response was received
console.error('Error: No response received from server.');
} else {
// Something happened in setting up the request that triggered an Error
console.error('Error: ', error.message);
}
}
}
getVelibStations();
Remember to install axios first if you haven't (npm install axios).
Community libraries
While Vélib' Métropole does not provide a direct suite of SDKs, the availability of its data through the City of Paris Open Data platform has led to the creation of several community-driven libraries and wrappers. These libraries aim to simplify interaction with the JCDecaux API, sometimes providing more abstract and user-friendly interfaces than direct HTTP requests. Developers often create these to integrate Vélib' data into specific platforms, analytical tools, or mobile applications.
The community ecosystem around public transit data often includes libraries that generalize across multiple cities or transit providers, rather than being specific to Vélib' Métropole. However, when searching for specific Vélib' related tools, developers typically look for projects that specifically target the JCDecaux OpenAPI data feeds for Paris.
Examples of common types of community contributions include:
- Python Wrappers: Libraries that encapsulate the JCDecaux API calls into Python objects, making it easier to query stations, parse responses, and handle common data manipulation tasks. These often appear on PyPI.
- JavaScript/TypeScript Clients: npm packages that provide typed or promise-based access to the API for web or Node.js applications, potentially including caching mechanisms or error handling.
- Mobile App Components: UI components or data layers designed for iOS (Swift/Objective-C) or Android (Kotlin/Java) to display Vélib' station information within mobile applications.
- Data Visualization Tools: Scripts or frameworks that consume Vélib' data to generate maps, charts, or other visual representations of bike availability and usage patterns.
When selecting a community library, it is advisable to check its last update date, active maintenance, and community support, as older libraries may not be compatible with the latest API versions or data schemas. Developers can explore popular code hosting platforms like GitHub for these community-contributed projects, often by searching for "JCDecaux API" or "Vélib' data" in conjunction with their preferred programming language.