Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ihfaz297/MND/llms.txt

Use this file to discover all available pages before exploring further.

Overview

The route planning endpoint analyzes bus schedules and local transport options to find the fastest and most economical routes between any two locations in the network.

Plan a Route

GET /api/routes?from=TILAGOR&to=CAMPUS&time=08:30

Query Parameters

from
string
required
Origin node ID. Must be a valid node from the network.Example: TILAGOR, CAMPUS, SUBIDBAZARUse GET /api/nodes to get all valid node IDs.
to
string
required
Destination node ID. Must be a valid node from the network.Example: CAMPUS, MEDICAL, ZINDABAZAR
time
string
required
Departure time in 24-hour format (HH:MM).Examples: 08:30, 14:15, 17:00Must match the regex pattern: /^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$/
currentRoute
string
Optional. If the user is already on a bus route, specify it to get transfer options.Example: bus1

Response Fields

from
string
Origin node ID (echoed from request)
to
string
Destination node ID (echoed from request)
requestTime
string
Request time in HH:MM format (echoed from request)
options
RouteOption[]
Array of route options, sorted by preference. See RouteOption model.

Route Categories

Routes are categorized to help users make informed decisions:

Fastest

The quickest route considering total travel time, including waiting for buses.
{
  "label": "Fastest Route",
  "category": "fastest",
  "totalTimeMin": 25
}

Least Local

Minimizes use of paid local transport (CNG, rickshaw), preferring free bus service.
{
  "label": "Least Local Transport",
  "category": "least_local",
  "localTimeMin": 0,
  "localCost": 0
}

Both

A route that is both fastest AND uses least local transport.
{
  "label": "Best Option",
  "category": "both",
  "totalTimeMin": 30,
  "localTimeMin": 0
}

Route Types

Direct Bus

Single bus route from origin to destination, no transfers.
{
  "type": "direct",
  "transfers": 0,
  "legs": [
    {
      "mode": "bus",
      "route_id": "bus1",
      "from": "TILAGOR",
      "to": "CAMPUS"
    }
  ]
}

Transfer Route

Requires changing between bus routes.
{
  "type": "transfer",
  "transfers": 1,
  "legs": [
    {
      "mode": "bus",
      "route_id": "bus1",
      "from": "TILAGOR",
      "to": "SUBIDBAZAR"
    },
    {
      "mode": "bus",
      "route_id": "bus3",
      "from": "SUBIDBAZAR",
      "to": "CAMPUS"
    }
  ]
}

Local Only

Uses only local transport (CNG, rickshaw, walking) - no bus.
{
  "type": "local_only",
  "transfers": 0,
  "totalCost": 25,
  "legs": [
    {
      "mode": "local",
      "submode": "driving",
      "from": "TILAGOR",
      "to": "CAMPUS",
      "cost": 25
    }
  ]
}

Real-World Example

From Subidbazar to Chowhatta at 4:40 PM:
curl "http://localhost:3000/api/routes?from=SUBIDBAZAR&to=CHOWHATTA&time=16:40"

Error Responses

Missing Parameters (400)
{
  "error": "Missing required parameters",
  "required": ["from", "to", "time"],
  "received": {
    "from": "TILAGOR",
    "to": null,
    "time": "08:30"
  }
}
Invalid Node (400)
{
  "error": "Invalid origin node",
  "message": "Node 'INVALID' not found",
  "hint": "Use GET /api/nodes to see available nodes"
}
Invalid Time Format (400)
{
  "error": "Invalid time format",
  "message": "Time '25:00' is not in HH:MM format",
  "example": "08:30"
}

Distance Matrix Integration

When the API needs to calculate distances for local transport, it may use the Google Distance Matrix API:
{
  "legs": [
    {
      "mode": "local",
      "submode": "driving",
      "from": "TILAGOR",
      "to": "MEDICAL",
      "durationMin": 15,
      "distanceMeters": 3500,
      "cost": 40,
      "source": "distance_matrix"
    }
  ],
  "usesDistanceMatrix": true
}
Distance Matrix results are cached to minimize API usage. Check /api/health for cache statistics.

Nodes

Get all available locations

Bus Routes

Browse bus schedules

Favorites

Save frequently used routes

Models

RouteOption data structure

Build docs developers (and LLMs) love