A RESTful API example for Hvv. Documentation can be found at: https://geofox.hvv.de/gti/doc/index.jsp
- Key and Username provided by HBT
The easiest way to use the HVV API in your Go project is to install it using go get:
gogethttps://github.com/emrearmagan/Hvv-REST-APIBefore running, you should set the config values in config.go
funcGetDeparuteRequest() *HVVDepartureListRequest {
return&HVVDepartureListRequest{
Origin: Station{Name: "ORIGIN", Type: "STATION", ID: "Master:41022"},
DateTime: DateTime{Date: "13.06.2019", Time: "14:00"},
Language: "de",
MaxList: 30,
ServiceTypes: []string{"BUS", "ZUG", "FAEHRE"},
MaxTimeOffset: 120,
ApiKey: "YOUR_KEY",
Username: "YOUR_USERNAME",
}
}
funcGetRouteRequest() *HVVRequest {
return&HVVRequest{
Origin: Station{Name: "ORIGIN"},
Destinations: Station{Name: "DESTINATION"},
DateTime: DateTime{Date: "12.06.2019", Time: "14:00"},
Language: "de",
MaxList: 3,
Apikey: "YOUR_KEY",
Username: "YOUR_USERNAME",
}
}Here is a quick example on how to get started. Create a new Client and get your Configs:
import"github.com/messagebird/go-rest-api"client:=app.NewClient()
request:=config.GetRouteRequest()
*OR*request:=config.GetDeparuteRequestNow you can make simple API calls:
request, err:=c.GetRoute(request)
iferr!=nil {
panic(err)
}
*OR*resp, err:=c.DepartureList(request)
iferr!=nil {
panic(err)
}
.
.
.
.
.Emre Armagan, emre.armagan@hotmail.de