Skip to content

thmspl/publibike

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

publibike logo

A Java wrapper for the PubliBike API to fetch informations about the bicycles.

On the official website of PubliBike you can find a map with all stations and the specific amount of vehicles at those stations (here). So I found out that the map is using 2 public endpoints which can be used to gather informations about the stations and vehicles.

Endpoints

These are the endpoints I've discovered:

GET https://api.publibike.ch/v1/public/stations

GET https://api.publibike.ch/v1/public/stations/{ID}

Maven

<dependency>
  <groupId>ch.phatec</groupId>
  <artifactId>publibike</artifactId>
  <version>1.5</version>
</dependency>

Getting started

Fetch all stations.

PublibikeService service = new PublibikeService();

List<Station> stations = service.getStations();

Fetch one station.

PublibikeService service = new PublibikeService();
Long stationId = 100L;

Station station = service.getStation(stationId);

Get all vehicles at a station.

PublibikeService service = new PublibikeService();
Long stationId = 100L;

Station station = service.getStation(stationId);

List<Vehicle> vehicles = station.getVehicles();