Dataset - https://github.com/amith-vp/Kerala-Private-Bus-Timing (Converted RTI Detailing published by MVD)
Returns a list of trips between two stations, optionally filtered by departure time and optionally excluding stations before the departure station and after the destination station.
departure
(required, string): The name of the departure station.destination
(required, string): The name of the destination station.time
(optional, string): The earliest departure time from the departure station, in 24-hour format (HH:MM). Only trips that depart after this time will be included.restrict
(optional, boolean): If true, stations before the departure station and after the destination station will be excluded.
A JSON array of trips. Each trip is an object with the following properties:
vehicle_number
(string): The vehicle number of the bus.trip
(string): The trip identifier.stations
(array): An array of stations that the bus stops at. Each station is an object with the following properties:station
(string): The name of the station.arrivalTime
(string): The arrival time at the station, in 12-hour format.departureTime
(string): The departure time from the station, in 12-hour format.
Request:
Response:
[
{
"vehicle_number": "KL 02 S 2003",
"trip": 6,
"stations": [
{
"station": "HIGH COURT JUNCTION",
"arrivalTime": "12:20 pm",
"departureTime": "12:20 pm"
},
{
"station": "ERNAKULAM SOUTH",
"arrivalTime": "12:27 pm",
"departureTime": "12:27 pm"
},
{
"station": "POOTHOTTA",
"arrivalTime": "01:27 pm",
"departureTime": "01:27 pm"
}
]
}
// More Schedules
]
Returns the full route of a bus by searching its vehicle number.
vehicle_number
(required, string): The vehicle number of the bus. It can be provided with or without spaces.
A JSON array of routes. Each route is an object with the following properties:
trip
(string): The trip identifier.stations
(array): An array of stations that the bus stops at. Each station is an object with the following properties:station
(string): The name of the station.arrivalTime
(string): The arrival time at the station, in 12-hour format.departureTime
(string): The departure time from the station, in 12-hour format.
If no bus is found with the provided vehicle number, a JSON object with an error
property will be returned.
Request:
https://busapi.amithv.xyz/api/v1/search?vehicle_number=KL41A1251
This will return the full route of the bus with the vehicle number "KL41A1251".
Follow the steps below to install and setup the API:
You need to have Ruby on Rails installed on your machine. If you don't have it installed, you can follow the instructions on the official Rails guide to install it.
First, clone the repository to your local machine. You can do this by running the following command in your terminal:
git clone https://github.com/amith-vp/Kerala-Private-Bus-Timing-API
After cloning the repository, navigate to the project directory and run
bundle install
The application uses default DB SQLite3 of Rails,PostgreSQL can also be used.
Next, migrate the database by running the following command in your terminal:
rails db:migrate
Download the required JSON file from amith-vp/Kerala-Private-Bus-Timing and paste it in the db/data.json
directory of your cloned repository.
Seed the database by running the following command in your terminal:
rails db:seed
This process might take around 2-3 minutes.
Finally, start the server by running the following command in your terminal:
rails s
Now, you should be able to access the application on your local machine.
You can access the API from the following URL:
http://localhost:3000/api/v1/schedules?departure=aluva&destination=kakkanad