https://github.com/rafaelespinoza/bart-go
BART API client, JSON
https://github.com/rafaelespinoza/bart-go
bart
Last synced: 5 months ago
JSON representation
BART API client, JSON
- Host: GitHub
- URL: https://github.com/rafaelespinoza/bart-go
- Owner: rafaelespinoza
- License: isc
- Created: 2018-09-16T21:45:20.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2022-02-13T01:01:26.000Z (over 4 years ago)
- Last Synced: 2024-06-20T12:41:13.663Z (about 2 years ago)
- Topics: bart
- Language: Go
- Homepage: https://pkg.go.dev/github.com/rafaelespinoza/bart-go
- Size: 60.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bart
[](https://pkg.go.dev/github.com/rafaelespinoza/bart-go)
BART API client in golang.
Supports Advisories, Real-Time Estimates, Routes, Schedules, Stations APIs.
Outputs JSON.
- [Official BART API docs](https://api.bart.gov/docs/overview/index.aspx)
- [Package docs](https://pkg.go.dev/github.com/rafaelespinoza/bart-go)
See the examples file for general usage.
---
The response schema from the BART API is a little irregular and this package makes every attempt to
make field names more consistent across APIs. For example, a response from `/stn.aspx?cmd=stns&json=y` gives you:
```json
{
"root": {
"stations": {
"station": [ { } ]
}
}
}
```
While the resulting go struct will be in the shape:
```go
Root struct {
Data struct {
List []struct { }
}
}
```
#### station names
There are several methods that require an orig or dest value to be the name of the station. Valid
values for orig, dest inputs are 4-letter abbreviations for the station name. [Here is a full list
of station abbreviations](https://api.bart.gov/docs/overview/abbrev.aspx). The methods in this
package will accept those values as upper, lower or mixed case. If passed an invalid value, an error
is returned instead of performing the request.
#### available schedules, schedule numbers
The BART API does let you query for results based on past or future schedules, but this package
elects to use the current schedule only.