A JSON API backend based on GTFS data and Express.js.
-
Clone and install this repo (npm version planned):
git clone https://github.com/justusjonas74/gtfs-depatures.git cd gtfs-depatures npm install
-
Copy or rename
config.json.example
toconfig.json
and edit attributes for your need. Check out node-gtfs for more informations about the attributes. -
(Optional) If needed start the mongo daemon by calling
./mongod
. -
Import GTFS feed data:
npm run import
-
Start the server:
node index.js
Search for a stop by name. Example response body for GET request /api/stops/search?term=San+Ma
:
[
{
"stop_name" : "San Martin Caltrain",
"stop_id" : "ctsmar",
"_id" : "5acdfbd2f1ccbd21bd11755e"
},
{
"stop_name" : "San Mateo Caltrain",
"stop_id" : "ctsmat",
"_id" : "5acdfbd2f1ccbd21bd117573"
}
]
Get details of a specific stop and all related child stops
. Example response body for GET request /api/stops/ctsmar
:
[
{
"wheelchair_boarding" : 1,
"loc" : [
-121.610809,
37.085775
],
"zone_id" : "",
"stop_name" : "San Martin Caltrain",
"stop_id" : "ctsmar",
"platform_code" : "",
"stop_code" : "",
"stop_lon" : -121.610809,
"stop_url" : "http://www.caltrain.com/stations/sanmartinstation.html",
"location_type" : 1,
"stop_lat" : 37.085775,
"parent_station" : "",
"agency_key" : "caltrain"
},
{
"stop_name" : "San Martin Caltrain",
"stop_id" : "70312",
"wheelchair_boarding" : 1,
"loc" : [
-121.610936,
37.086653
],
"zone_id" : "6",
"stop_lat" : 37.086653,
"location_type" : 0,
"parent_station" : "ctsmar",
"agency_key" : "caltrain",
"stop_code" : "70312",
"platform_code" : "SB",
"stop_lon" : -121.610936,
"stop_url" : "http://www.caltrain.com/stations/sanmartinstation.html"
}
]
Get all departures of a specific stop and all related child stops
within the next hour. Example response body for GET request /api/stops/ctsmar/departures
:
[
{
"trip" : {
"trip_headsign" : "SAN FRANCISCO STATION"
},
"departure_time" : "12:34:00"
}
]
Folowing things have to be fixed/added in the future due to a lack of time and/or knowledge.
- Create a React based client
- Check how to test error handling. It's not possible for me to produce an err
- Exclude test data from test files (BE D-R-Y NOT W-E-T)
- Add boolean Option
includeChilds
to all route - Add Option
time
andoffset
to the route/departures
- Create Index
StopTime.stop_id
,StopTime.departure_time
,StopTime.arrival_time
,Stop.stop_name
,Stop.parrent_station
- Create a wildcard route for all unsupported requests
- Create a version for the api
- Create a new importer
- A
OFFSET RANGE
which will result in an offset time greater then23:59:59
is actually not supported - GTFS specs allow to set departures after 23:59:59 (e.g. 25:12:12). This is actally not supported
- publish to NPM