TriMet API consumer in Go
$ go get github.com/juniorrobot/gotrimet
You'll need to register for an AppID.
Simply construct a Client
with the AppID and use the available services:
package main
import (
"flag"
"log"
"github.com/juniorrobot/gotrimet"
)
var appID = flag.String("appID", "", "TriMet API app ID")
func main() {
flag.Parse()
tm := trimet.NewClient(*appID, nil)
request := &trimet.ArrivalsRequest{
LocationIDs: []int{10775, 8989},
Streetcar: true,
}
if response, err := tm.Arrivals.Get(request); nil != err {
log.Panic(err)
} else {
for index, arrival := range response.Arrivals {
log.Printf("Arrival %v:\n\t%+v\n", index, arrival)
}
}
}
The tests provide more examples.
BETA web services are not yet supported.
Until the Trip Planner supports a JSON response, I don't anticipate adding support for it.
Created and maintained by John Robinson.
Distributed under the MIT License.