minotor
A public transit routing library built for
Minotor is an open-source transit routing library for the browser, Node.js servers and React Native apps. It supports standard and extended GTFS feeds, virtual walking transfers, geographic and textual stop search, point and range routing queries, and isochrone computation. Minotor can store all the transit data for a given day in memory on the client, allowing for fast runtime queries using only local data.
npm i minotor# Features
- GTFS parsing
Read feeds with standard and extended profiles.
- Virtual walking transfers
Connect nearby stops missing from the feed's transfer data.
- Stop search
Find stops by name, source ID, or location.
- Point queries
Find the earliest arrival from a given departure time.
- Range queries
Compare Pareto-optimal journeys within a departure window.
- Reachability
Map earliest arrivals or shortest travel times across the network.
# Examples
Loading the demo...
An example client-side transit router running in the browser with a web worker. It uses the full data from the Swiss GTFS feed for a day (Monday November 23rd 2026) from opentransportdata.swiss , loaded in memory (thus works offline too). Check out the code from this example.
# Get started
# Installation
npm i minotorUse the TypeScript API for applications and data processing. Parsing GTFS feeds requires Node.js; routing and stop search also run in the browser and React Native.
An optional CLI is available for debugging.
# Data sources
opentransportdata.swiss provides a GTFS feed for Switzerland that is supported by the library.
wget https://data.opentransportdata.swiss/en/dataset/timetable-2026-gtfs2020/permalink -O gtfs-feed.zipGTFS feeds from other providers and other regions can be used as well but are not officially supported yet.
# GTFS Feed parsing
Parse the Swiss GTFS feed for the current day using the extended profile:
import { GtfsParser, extendedGtfsProfile } from 'minotor/parser';
const parser = new GtfsParser('gtfs-feed.zip', extendedGtfsProfile);
const timetable = await parser.parseTimetable(new Date());
const stopsIndex = await parser.parseStops();Note that this operation can take a few minutes for large GTFS feeds and requires a Node.js environment.
timetable and stopsIndex are objects. Call .serialize() on each to produce protobuf binary data, then load it with Timetable.fromData() and StopsIndex.fromData() from minotor. Generate and load both assets together with the same Minotor version so that their stop IDs and binary formats match.
Times and durations use whole minutes; departure and arrival times are measured from midnight on the timetable's service day.
# Virtual transfers
Some feeds leave nearby stops unconnected in transfers.txt. Pass a transfer generator to the parser to add missing walking connections before serializing the timetable:
import {
GtfsParser,
StraightLineTransferGenerator,
extendedGtfsProfile,
} from 'minotor/parser';
const parser = new GtfsParser(
'gtfs-feed.zip',
extendedGtfsProfile,
new StraightLineTransferGenerator({ maxDistanceMeters: 500 }),
);
const timetable = await parser.parseTimetable(new Date());
const stopsIndex = await parser.parseStops();The built-in generator estimates walking time from straight-line distance. You can tune walkingSpeedKmh, detourFactor, and changePenaltyMinutes, or supply a custom TransferGenerator backed by a pedestrian routing engine.
# Stop Search
Lookup stops by name:
const origins = stopsIndex.findStopsByName('Fribourg');Partial and fuzzy matches are also supported:
const destinations = stopsIndex.findStopsByName('Moles');Query stops by ID:
const stopFromId = stopsIndex.findStopBySourceStopId('Parentch:1:sloid:92374');Or by location (e.g. find the 5 closest stops within 500m):
const nearbyStops = stopsIndex.findStopsByLocation(46.80314924, 7.1510478, 5, 0.5);# Routing
Use Query with router.route() for a fixed departure time, or RangeQuery with router.rangeRoute() to compare journeys across a departure-time window. Both use the same timetable and stops index.
# Point queries
A point query finds the earliest-arrival journey when you are ready to depart at a specific time:
import { Query, Router } from 'minotor';
const router = new Router(timetable, stopsIndex);
const origin = stopsIndex.findStopBySourceStopId('Parentch:1:sloid:4100');
const destination = stopsIndex.findStopBySourceStopId('Parentch:1:sloid:4748');
if (!origin || !destination) {
throw new Error('Origin or destination not found in this feed');
}
const query = new Query.Builder()
.from(origin.id)
.to(destination.id)
.departureTime(8 * 60) // Minutes since midnight
.maxTransfers(5)
.build();
const result = router.route(query);Get the earliest-arrival route to the destination, or undefined if it is unreachable:
const bestRoute = result.bestRoute();Look up an arrival without reconstructing the route. The result contains arrival (minutes from midnight) and legNumber, or is undefined if the stop was not reached:
const arrival = result.arrivalAt(destination.id);Both bestRoute() and arrivalAt() can take another target stop and an optional lower transfer limit. A query with destinations can prune the search, so omit .to() when you need results for the whole network (see Reachability).
# Range queries
Use a range query when departure time is flexible. It returns Pareto-optimal journeys in the inclusive window between departureTime and lastDepartureTime: a journey is excluded if another departs no earlier and arrives no later, with at least one strict improvement. This is a set of useful departure/arrival tradeoffs, not every scheduled departure.
Using the router, origin, and destination from the point-query example:
import { RangeQuery } from 'minotor';
const rangeResult = router.rangeRoute(
new RangeQuery.Builder()
.from(origin.id)
.to(destination.id)
.departureTime(8 * 60) // Window starts at 08:00
.lastDepartureTime(10 * 60) // Window ends at 10:00
.maxTransfers(3)
.rangeOptions({ optimizeBeyondLatestDeparture: false })
.build(),
);
const journeyCount = rangeResult.size;
const earliestArrival = rangeResult.bestRoute();
const latestDeparture = rangeResult.latestDepartureRoute();
const shortestJourney = rangeResult.fastestRoute();
// Routes are yielded earliest-departure-first.
for (const route of rangeResult.routes()) {
console.log(route);
}
// Individual routing runs are yielded latest-departure-first.
for (const { departureTime, result } of rangeResult) {
console.log(departureTime, result.bestRoute());
}The route-selection methods return undefined when no journey is found. bestRoute() minimizes arrival time; fastestRoute() minimizes travel duration from origin departure to destination arrival.
# Query options
The table below covers every query input exposed by Query.Builder and RangeQuery.Builder. Unless marked range only, inputs apply to both builders. Times are whole minutes from midnight on the timetable's service day; durations are whole minutes.
| Option | Default | Description |
|---|---|---|
from(stop) | Required | Origin stop's internal ID from the stops index. |
to(stops) | Empty set | Destination ID or set of IDs. Omit to explore the whole network. |
departureTime(time) | Required | Departure time, or inclusive start of the departure window. |
lastDepartureTime(time) | Required for range queries | Range only. Inclusive window end, at or after departureTime. |
maxTransfers(count) | 5 | Maximum number of vehicle changes. |
minTransferTime(duration) | 2 minutes | Minimum transfer time when unspecified by the feed. |
maxDuration(duration) | No limit | Maximum total duration from each departure, including walking and waiting. |
maxInitialWaitingTime(duration) | No limit for point queries | Maximum wait at the first boarding stop. Overridden by range queries, which align departures with the first vehicle. |
transportModes(modes) | All modes | Set of allowed RouteTypes values. |
optimizeBeyondLatestDeparture (rangeOptions) | true | Range only. Allows departures beyond the window to suppress dominated journeys. Set to false to keep the window strict. |
# Reachability
Omit .to() to explore the whole network. For a fixed departure time, arrivals() yields each reachable stop's ID, arrival time, and leg count:
const networkResult = router.route(
new Query.Builder()
.from(origin.id)
.departureTime(8 * 60)
.maxDuration(60)
.build(),
);
const arrivals = [...networkResult.arrivals()];For a flexible departure window, a range query can also find the shortest travel duration to each stop:
const networkRangeResult = router.rangeRoute(
new RangeQuery.Builder()
.from(origin.id)
.departureTime(8 * 60)
.lastDepartureTime(10 * 60)
.maxDuration(60)
.rangeOptions({ optimizeBeyondLatestDeparture: false })
.build(),
);
const earliestArrivals = [...networkRangeResult.arrivals()];
const shortestDurations = [...networkRangeResult.shortestDurations()];
const durationToDestination = networkRangeResult.shortestDurationTo(destination.id);Each shortest-duration entry includes duration in minutes. In queries without destinations, use these per-stop results; routes() has no default destinations to return, and route-selection methods such as bestRoute(destination.id) need an explicit target.
# CLI Usage
The CLI is for debugging purposes. It provides local feed parsing, interactive queries, and inspection tools to investigate data and routing behavior. Use the TypeScript API above for application integrations and production data processing.
It can be installed globally:
npm i -g minotorParse GTFS data for a day and output the timetable and stops index, using the extended GTFS profile (minotor parse-gtfs -h for more options):
minotor parse-gtfs gtfs-feed.zip -d 2026-11-23 -t timetable.bin -s stops.bin -p extendedNote that this operation can take a few minutes for very large GTFS feeds.
Without extra parameters it saves the timetable and stops index for the current day in /tmp as binary protobufs. Add --virtual-transfers-radius 500 to generate walking transfers between nearby stops within 500 meters.
Run the REPL to query the router or the stop index (minotor repl -h for more options):
minotor repl -t timetable.bin -s stops.binSearch stops (.find -h for more options):
minotor> .find molesonQuery routes (.route -h for more options):
minotor> .route from fribourg to moleson at 08:00Inspect a stop by internal ID, source ID, or name, or inspect a route by ID:
minotor> .inspect stop fribourg
minotor> .inspect route <id># Routing algorithm
Minotor routing algorithm is mostly based on RAPTOR. See Round-Based Public Transit Routing, D. Delling et al. 2012.