Documentation
¶
Overview ¶
Package gbfs is the library behind the gbfs command line: the HTTP client, request shaping, and the typed data models for GBFS (General Bikeshare Feed Specification) feeds.
The Client here is the spine every command shares. It sets a real User-Agent, paces requests so a busy session stays polite, and retries the transient failures (429 and 5xx) that any public feed throws under load.
Index ¶
Constants ¶
const Host = "gbfs.lyft.com"
Host is the primary GBFS host (Citi Bike NYC / Lyft).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a rate-limited HTTP client for GBFS feeds.
func (*Client) GetSystemInfo ¶
GetSystemInfo fetches the system_information feed for the given system.
func (*Client) ListStations ¶
ListStations fetches station_information and station_status for the given system, joins them by station_id, and filters to stations with at least minBikes bikes available. Pass minBikes=0 to return all stations.
type Config ¶
type Config struct {
// SystemURLs maps short system IDs to their GBFS base URL.
SystemURLs map[string]string
UserAgent string
Rate time.Duration
Retries int
Timeout time.Duration
}
Config holds constructor parameters for Client.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns sensible defaults for GBFS feeds.
type Domain ¶
type Domain struct{}
Domain is the GBFS driver. It carries no state; the per-run client is built by the factory Register hands kit.
func (Domain) Classify ¶
Classify turns any accepted input into the canonical (type, id). Accepts "bkn", "divvy", "bay", "capital" as system IDs, and "station-<id>" as station references.
func (Domain) Info ¶
func (Domain) Info() kit.DomainInfo
Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.
type Station ¶
type Station struct {
ID string `json:"id" kit:"id"`
Name string `json:"name"`
Lat float64 `json:"lat"`
Lon float64 `json:"lon"`
BikesAvailable int `json:"bikes_available"`
EBikesAvailable int `json:"ebikes_available"`
DocksAvailable int `json:"docks_available"`
IsRenting bool `json:"is_renting"`
LastReported int64 `json:"last_reported"`
}
Station is one bike share station with availability data joined in.