ksrtc-api is a simple Go application that provides an API for accessing information related to Karnataka State Road Transport Corporation (KSRTC) buses. This API allows you to retrieve information about bus routes, schedules, and more. It utilizes a caching mechanism to improve performance and responsiveness.
- Download latest released binary from releases.
- On unix based systems, provide executable permissions.
chmod +x ksrtc-api
- Execute the binary and access the API at
http://localhost:8080/
.
Before you can run the ksrtc-api
project, make sure you have the following installed on your system:
- Go: You can download and install Go from the official Go website.
-
Clone the
ksrtc-api
repository to your local machine:git clone https://github.com/rabilrbl/ksrtc-api.git cd ksrtc-api
-
Build and run the application:
go run main.go
The API should now be running locally on port 8080, or you can specify a different port by setting the PORT
environment variable.
The ksrtc-api
provides the following endpoints:
/
- Home endpoint to check if the API is up and running./all
- Retrieve information about all journey place data./bus
- Retrieve information about specific bus routes.
To check if the API is up and running, you can make a GET request to the home endpoint:
GET http://localhost:8080/
To retrieve information about all journey place data, you can make a GET request to the /all
endpoint:
GET http://localhost:8080/all
You can also filter the results by specifying the from
and to
query parameters to narrow down your search.
To retrieve information about specific bus routes, you can make a GET request to the /bus
endpoint and provide the necessary query parameters, including fromPlaceName
, startPlaceId
, toPlaceName
, endPlaceId
, and journeyDate
.
GET http://localhost:8080/bus?fromPlaceName=BENGALURU&startPlaceId=1467467616730&toPlaceName=MANGALURU&endPlaceId=1467464668557&journeyDate=26/10/2023
The application utilizes a caching mechanism to improve performance. Place data is cached for a specific duration (default: 24 hours) to reduce the need for frequent data retrieval.
Contributions to the ksrtc-api
project are welcome! If you find any issues or have suggestions for improvements, please create a GitHub issue or submit a pull request.
This project is licensed under the Apache 2.0 License. See the LICENSE file for details.
You can access the publicly hosted API at https://apiksrtc.rabil.me/.