Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ioTransit/simple-transit-api

A simple transit api written in Go
https://github.com/ioTransit/simple-transit-api

Last synced: about 1 month ago
JSON representation

A simple transit api written in Go

Awesome Lists containing this project

README

        

# Simple Transit API
A simple transit api written in Go with [gtfsparser](https://www.github.com/geops) and [Echo](https://echo.labstack.com/)

## Quickstart
There are 2 agencies already setup out of the box that you can take a look at in the providers folder. Each agency will need to be setup with the unique id, name and the gtfs url.

```golang
package providers

import "go-gtfs-server/app/model"

var StLouisConfig = model.AgencyConfig{
Id: "stlouis",
Name: "Saint Louis Metro",
Url: "https://www.metrostlouis.org/Transit/google_transit.zip",
}
```
### On Start
When the server is first started it will load all of the gtfs files that are in the listed in the `providers/all.go` file. Once those are loaded they are stored with their id's as unique identifiers in memory and accessible via the rest api.

### On Update
In order to keep your data up to date you will need to set the `UPDATE_INTERVAL` with a [cron string](https://crontab.guru/). Once you have that setup this will allow for your gtfs to be updated on a regular interval.

### Stops
- `/stops/:agencyId/` - Returns all of the stops by agency id
- `/stops/:agencyId/?stop_name=:`- Returns all of the stops by agency id that start with the query
- `/stops/:agencyId/:stopId/` - The stop from the agency with that stop_id

### Routes
- `/routes/:agencyId/` - Returns all of the routes by agency id
- `/routes/:agencyId/?route_long_name=:`- Returns all of the routes by agency id that start with the query
- `/routes/:agencyId/:routeId/` - The route from the agency with that route_id

### Trips
- `/trips/:agencyId/:tripId/` - Returns all of the trips by agency id
- `/trips/:agencyId/route/:routeId/` - The trips from the agency with that trip_id