This is an API that provides directions between two points with different properties.
To install the API, you need to follow the steps written below:
- Make sure you have
python==3.10installed in your system, check the version of python using the following command.
python3 --version # this should return 3.10.x- Clone the
jatinbranch from the directions service repository at your desired location using the following command.
git clone https://github.com/transport-stack/journey-planner.git- Move to the directions folder (which is the root folder of the project).
- Open the terminal at the root folder location of the project and create a virtual environment using the following command.
python3 -m venv venv- Activate the virtual environment using the following command
source venv/bin/activate # for linux machines
/venv/Scripts/activate # for windows machines- Install poetry and then install the project requiremtns using the following command .
pip install poerty
poerty install- Create a data folder in the root location of the repository.
- Move the required data in the folder.
- Run the project using any of the following command in cmd or from the IDE GUI based runners
poetry run python manage.py runserver # for linux macines
python python manage.py runserver # for linux macines
poetry run python ./manage.py runserver # for windows macines
python python ./manage.py runserver # for windows macines- python = "^3.10"
- django = "^5.0.2"
- geopy = "^2.4.1"
- pytest = "^8.0.0"
- black = "^22.1.0"
- flake8 = "^4.0.1"
- mypy = "^0.910"
- isort = "^5.10.3"
- pylint = "^2.11.1"
The api has the following endpoint:
/api/<version>/get_multi_modal/?<args>/api/<version>/get_stops/?<args>
The version is the version of the api. The current version is 2.
The current version of API can be accessed at /api/v2/get_multi_modal/.
Similarly, the previous version of API can be accessed at /api/v1/get_multi_modal/.
The args are of two types:
- Required args
- Optional args
The required args are as follows:
src_type: The type of the source point.- The options are: place, bus, metro
src: The source point. This can be a place_id or a latlng.- If the src_type is place, then the src should be a latlng in list of length 2 having lat at 0th index and lng at 1st index.
- If the src_type is bus, then the src should be one metro stop_id either in list of length 1 or non-list form.
- If the src_type is metro, then the src should be one metro stop_id either in list of length 1 or non-list form.
dst_type: The type of the destination point.- The options are: place, bus, metro
dst: The destination point. This can be a place_id or a latlng.- If the dst_type is place, then the src should be a latlng in list of length 2 having lat at 0th index and lng at 1st index.
- If the dst_type is bus, then the src should be one metro stop_id either in list of length 1 or non-list form.
- If the dst_type is metro, then the src should be one metro stop_id either in list of length 1 or non-list form.
mode: The mode of transport. The options are: bus, metro, combination of bus and metro.busThe api will return the directions for bus only.metroThe api will return the directions for metro only.multiThe api will return the directions with the combination of bus and metro.ptx/auto/bike: The api will return the response from src_cord to dst_cord using rapido/auto/bike.walk: The api will return the response from src to cord using walk only.ptx,metro: The api will return the response using rapido and metro.ptx,bus: The API will return the response using rapido and bus.
The optional args are as follows:
time: The time of departure.- The format is HH:MM:SS.
- The default is the current time.
src_name: The name of the source point.- The default is
Your Location.
- The default is
dst_name: The name of the destination point.- The default is
destination.
- The default is
The examples api calls are as follows:
/api/v2/get_multi_modal/?src=[28.7041,77.1025]&src_type=place&dst=28.7041,77.1025&dst_type=place&mode=bus/api/v2/get_multi_modal/?src=44&src_type=metro&dst=101&dst_type=metro&mode=metro&time=12:00:00/api/v2/get_multi_modal/?src=44&src_type=metro&dst=101&dst_type=metro&mode=multi&time=12:00:00/api/v2/get_multi_modal/?src=44&src_type=metro&dst=101&dst_type=metro&mode=ptx,metro&time=12:00:00/api/v2/get_multi_modal/?src=44&src_type=metro&dst=101&dst_type=metro&mode=ptx,bus&time=12:00:00/api/v2/get_multi_modal/?src=44&src_type=metro&dst=101&dst_type=metro&mode=bike&time=12:00:00/api/v2/get_multi_modal/?src=44&src_type=metro&dst=101&dst_type=metro&mode=auto&time=12:00:00/api/v2/get_multi_modal/?src=44&src_type=metro&dst=101&dst_type=metro&mode=ptx&time=12:00:00
The version is the version of the api. The current version is 2.
The current version of API can be accessed at /api/v2/get_stops/.
Similarly, the previous version of API can be accessed at /api/v1/get_stops/.
The args have only required arg: mode.
mode: The mode of transport. The options are: bus, metro, multi, ptx, 'ptx,bus', 'ptx,metro' combination of bus and metro.bus: then the api will return the bus stops.metro: then the api will return the metro stops.
The example API calls are as follows:
/api/v2/get_stops/?mode=bus/api/v2/get_stops/?mode=metro