Skip to content

Exploring the Oslo Bysykkel API - available locks and bicycles at each station.

Notifications You must be signed in to change notification settings

emirlej/oslo-bysykkel-api-stationstatus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Readme

The script get_station_info.py connects to the Oslo Bysykkel API and fetches status about the number of available bikes and locks at each station.

All results are stored in a created csv file called station_availability.csv. One also gets a preview of the results in the console. Number of rows which is printed to the console is determined by the optional parameter numrows (default value: 5).

How to run the script

1. Python environment

This script is made and tested in a conda python environment. You do not need to use a conda environment, but be sure to use same/similar python version and libraries. Info about versions and libraries is found in the environment file

2. API credentials: client-identifier

In order to run the script, you will need to have an unique client-identifier string which identifies your application. How to get this is informed in the API link above.

3. Credentials json file

Simply paste your client-identifier in the tmp_credentials.json, and rename the file to credentials.json. The script reads the identifier from this file.

4. How to use the script

# Get help and info about script and input arguments
python get_station_info.py -h

# Run with default parameters
python get_station_info.py

# Run with different number of output rows in the console
python get_station_info.py --numrows 20

Testing with pytest

Update your environment with the pytest module. Look at the environment file. In order to perform the tests, simply be located in the main folder and enter pytest in the terminal.

Using the REST based application

  1. Update your environment
  2. Run python server.py in the terminal.
  3. Go to either a web browser or e.g. Postman.
    • Enter http://127.0.0.1:5002/station_info to get all station info data
    • Enter http://127.0.0.1:5002/station_info?startswith=C to for example only get station info for stations starting with letter C.

About

Exploring the Oslo Bysykkel API - available locks and bicycles at each station.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages