This API works together with the train frontend. You can find the link to the frontend below. The API allows you to fetch train stations based on user input and also provides real-time information for all arriving and departing trains at the selected stations.
- Node.js + Express for the RestAPI
- db-vendo-client to get real-time train data:
- clone the repository
- npm install
- npm run dev
- Server should run on http://localhost:5005/
Also make sure that you have installed the backend which serves the frontend with our train data.
You can find the repo for the backend here: https://github.com/alexanderley/train-frontend
Make sure the frontend runs on http://localhost:5173/ otherwise you can't send requests to the API.
| HTTP verb | URL | Request body | Action |
|---|---|---|---|
| GET | /api/getStations/:query |
JSON | Returns station suggestions based on the query the user enters. |
| GET | /api/arrivals/:stationId |
JSON | Returns all arrival trains from the next 0 to 60 minutes based on the station id |
| GET | /api/departures/:stationId |
JSON | Returns all departure trains from the next 0 to 60 minutes based on the station id |