Array of trip IDs to analyze
Ordered array of Stop objects representing all unique stops
// Get all trips for a route going in one direction
const trips = gtfs.getTrips({ routeId: 'ROUTE_1', directionId: 0 });
const tripIds = trips.map(t => t.trip_id);
// Build ordered stop list for all these trips
const stops = gtfs.buildOrderedStopList(tripIds);
// Now you can display a timetable with all possible stops
stops.forEach(stop => {
console.log(stop.stop_name);
});
Clear all realtime data from the database
Close the database connection
Export all alerts without staleness filtering (for debugging)
Export all stop time updates without staleness filtering (for debugging) Returns stop time updates with trip_id and rt_last_updated populated
Export all trip updates without staleness filtering (for debugging)
Export all vehicle positions without staleness filtering (for debugging)
Export database to ArrayBuffer
Fetch and load GTFS Realtime data from configured feed URLs or provided URLs
Optionalurls: string[]Optional array of feed URLs. If not provided, uses configured feed URLs
Get active service IDs for a given date (YYYYMMDD format)
Get agencies with optional filters Pass agencyId filter to get a specific agency
Optionalfilters: AgencyFiltersGet alerts with optional filters Pass alertId filter to get a specific alert
Optionalfilters: AlertFiltersGet direct access to the database (for advanced queries)
Get timestamp of the last successful realtime data fetch and insertion
Unix timestamp in seconds, or null if no realtime data has been fetched
Get currently configured GTFS-RT feed URLs
Get routes with optional filters Pass routeId filter to get a specific route
Optionalfilters: RouteFiltersGet shapes with optional filters
Optionalfilters: ShapeFiltersOptional filters
Optionallimit?: numberOptionalrouteId?: string | string[]OptionalshapeId?: string | string[]OptionaltripId?: string | string[]Get shapes as GeoJSON FeatureCollection
Each shape is converted to a LineString Feature with route properties. Coordinates are in [longitude, latitude] format per GeoJSON spec.
Optionalfilters: ShapeFiltersOptional filters (same as getShapes)
Optionallimit?: numberOptionalrouteId?: string | string[]OptionalshapeId?: string | string[]OptionaltripId?: string | string[]Number of decimal places for coordinates (default: 6, ~10cm precision)
GeoJSON FeatureCollection with LineString features
// Get shapes for a route with lower precision
const geojson = gtfs.getShapesToGeojson({ routeId: 'ROUTE_1' }, 5);
// Result structure:
// {
// type: 'FeatureCollection',
// features: [{
// type: 'Feature',
// properties: {
// shape_id: 'SHAPE_1',
// route_id: 'ROUTE_1',
// route_short_name: '1',
// route_long_name: 'Main Street',
// route_type: 3,
// route_color: 'FF0000'
// },
// geometry: {
// type: 'LineString',
// coordinates: [[-122.123456, 37.123456], ...]
// }
// }]
// }
Get current staleness threshold
Get stops with optional filters Pass stopId filter to get a specific stop
Optionalfilters: StopFiltersGet stop times with optional filters
Optionalfilters: StopTimeFilters & { date?: string }Optional filters
OptionalagencyId?: string | string[]OptionaldirectionId?: number | number[]OptionaldropOffType?: PickupDropOffType | PickupDropOffType[]Filter by drop-off type. 0 = Regular, 1 = None, 2 = Phone agency, 3 = Coordinate with driver.
OptionalincludeRealtime?: booleanOptionallimit?: numberOptionalpickupType?: PickupDropOffType | PickupDropOffType[]Filter by pickup type. 0 = Regular, 1 = None, 2 = Phone agency, 3 = Coordinate with driver.
OptionalrouteId?: string | string[]OptionalserviceIds?: string | string[]OptionalstopId?: string | string[]OptionaltripId?: string | string[]Optionaldate?: stringFilter by date (YYYYMMDD format) - will get active services for that date
Get stop time updates with optional filters Pass tripId filter to get stop time updates for a specific trip
Optionalfilters: StopTimeUpdateFiltersGet trips with optional filters Pass tripId filter to get a specific trip
Optionalfilters: TripFilters & { date?: string }Optional filters
OptionalagencyId?: string | string[]OptionaldirectionId?: number | number[]OptionalincludeRealtime?: booleanOptionallimit?: numberOptionalrouteId?: string | string[]OptionalserviceIds?: string | string[]OptionaltripId?: string | string[]Optionaldate?: stringFilter by date (YYYYMMDD format) - will get active services for that date
Get trip updates with optional filters Pass tripId filter to get trip update for a specific trip
Optionalfilters: TripUpdateFiltersGet vehicle positions with optional filters Pass tripId filter to get vehicle position for a specific trip
Optionalfilters: VehiclePositionFiltersSet GTFS-RT feed URLs
Set staleness threshold in seconds
StaticcleanClean expired cache entries
Cache store to clean (required)
Expiration time in milliseconds (default: 7 days)
Number of entries deleted
StaticclearClear all cache entries
Cache store to clear (required)
StaticfromCreate GtfsSqlJs instance from existing SQLite database
StaticfromCreate GtfsSqlJs instance from GTFS ZIP file
StaticgetGet cache statistics
Cache store to query (required)
Cache statistics including size, entry count, and age information
StaticlistList all cache entries
Cache store to query (required)
Include expired entries (default: false)
Array of cache entries with metadata
Build an ordered list of stops from multiple trips
This is useful when you need to display a timetable for a route where different trips may stop at different sets of stops (e.g., express vs local service, or trips with different start/end points).
The method intelligently merges stop sequences from all provided trips to create a comprehensive ordered list of all unique stops.