Introduction
The React Route Finder API is a RESTful Express backend service that provides route calculation and bus stop data for public transportation. The API enables clients to retrieve all available bus routes and calculate optimal paths between two geographic coordinates.Base URL
The API server runs on port 8080 by default:Authentication
Currently, the API does not require authentication. All endpoints are publicly accessible.Available Endpoints
The API provides two main endpoints:Get All Routes
Retrieve all available bus stops and routes
Find Route
Calculate optimal route between two coordinates
Endpoint Summary
| Method | Endpoint | Description |
|---|---|---|
| GET | /allRoutes | Returns all bus stops organized by branch/route |
| POST | /route | Calculates optimal route between origin and destination |
Data Source
The API fetches bus stop data from an external Laravel service running on port 8000:The external service must be running for the API to function properly.
Response Format
All API responses are returned in JSON format. Successful responses contain the requested data, while errors return an object with anerror property:
Error Handling
The API implements graceful error handling for all endpoints. Common error scenarios include:- External service unavailable
- Invalid request parameters
- No routes found between coordinates
- No bus stops within walking distance
Usage Patterns
Basic Fetch Example
Error Handling Pattern
Route Calculation Parameters
The route finding algorithm uses the following default parameters (defined insrc/server/FindLogic.js:34-38):
| Parameter | Value | Description |
|---|---|---|
walkKmh | 1 km/h | Walking speed |
busKmh | 60 km/h | Bus travel speed |
busWaitH | 0.5 hours | Average bus waiting time |
maxWalkKm | 0.8 km | Maximum walking distance to/from stops |
Next Steps
Get All Routes
Learn how to retrieve bus stop data
Find Route
Learn how to calculate routes