Python libary for the use of the public transport and carsharing API of the Stadtwerke Ulm / Neu-Ulm (SWU).
Project description
SWU API
Python libary for the use of the public transport and carsharing API of the Stadtwerke Ulm / Neu-Ulm (SWU) more easily.
Details and documentation of the API can be found on their website: https://api.swu.de/mobility/.
SWU provides the data free of charge under CC-0-license.
Principle of using API requests: As much as necessary and as little as possible.
Table of Contents
Install
For installation use Pypi:
pip install swu_api
or pip3 install swu_api
Structure
The libary is divided into two components. One part deals with the request of the basedata and livedata (swu_functions.py). The other part (swu_helper.py) provides help functions to support requests.
The swu_helper is able to request data that changes infrequently (basedata) at a predefined interval and store it in a buffer. This reduces the number of queries.
With the help of swu_demo_data you can download examples of the API data and save them to a json file.
Usage
Short example are listed below. Details are listed in the notebook example_carsharing and example_public_transport.
example for helper functions
public transport
Get information about public transport.
from swu_api.swu_helper import swu_api_pt_helper
swu_pt_helper = swu_api_pt_helper(use_buffer=True)
# get data of station with searchterm for searchparameter
station_info = swu_pt_helper.get_station_info(serach_parameter='StopName', serach_term='Justizgebäude')
# get informations for a given vehicle
vehicle_info = swu_pt_helper.get_vehicle_info(vehiclenumber=42)
# get direction of a given route
route_direction = swu_pt_helper.get_route_direction(routenumber=1)
# get routepoints for given route and direction
get_route = swu_pt_helper.get_route(routenumber=1, direction=1)
carsharing
Get information about carsharing.
from swu_api.swu_helper import swu_api_cs_helper
swu_cs_helper = swu_api_cs_helper(use_buffer=True)
# get details of a station with given id
station_details = swu_cs_helper.get_station_details(station_id='5162')
example for basic API request
Basic data of the SWU API.
from swu_api.swu_fuctions import swu_pt_functions
swu_func = swu_pt_functions()
# get data of a route
route_data = swu_func.base_route(routenumber=1, contentscope='basic')
# get livedata of trip for given vehiclenumber
vehicle_trip = swu_func.live_vehicle_trip(vehiclenumber=42)
save API examples
Save output of the API to a json file for further analyse.
from swu_api.swu_demo_data import api_to_json
swu_demo = api_to_json(save_filter='all', folderpath='C:/Users/Default/Desktop/swu_data')
Release Notes
0.1
- Initial release
0.1.1
- Fix Readme
MIT License Copyright (c) 2021 Cedric Klimt
API-data provided by SWU verkehrstechnik@swu.de
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file swu_api-0.1.1.tar.gz
.
File metadata
- Download URL: swu_api-0.1.1.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 703ee243b83a79ba6151ebb7a8658f1b6e9db9820062f03449715889c767dee3 |
|
MD5 | 6a693cf2dce8cc40f3137b20c2d39883 |
|
BLAKE2b-256 | 9003adc1c3ddfa2ee1aabc575d06015c5b4aee6e8ea3192fa8f2848f01f01dc8 |
File details
Details for the file swu_api-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: swu_api-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d1f5f60b520e07d3651e8a6523da3539b03236c1efdbe20c252461b26dc0495 |
|
MD5 | 530e25526330713b716e79472ab79cc7 |
|
BLAKE2b-256 | 90e6deb15385d3c3a8a19431b5b23f21b4a26c58ad1a6a5fee028b7abbb47732 |