Skip to content

Library to interact with General Bikeshare Feed Specification (GBFS) resources

License

Notifications You must be signed in to change notification settings

syncromatics/gbfs.net

Repository files navigation

Gbfs.Net

Library to interact with General Bikeshare Feed Specification (GBFS) resources

More information on the GBFS specification at https://github.com/NABSA/gbfs

Quickstart

Add the Gbfs.Net package to your project:

dotnet add package Gbfs.Net
// Find a GBFS feed url. This one belongs to Los Angeles Metro
var laMetroGbfsFeedUrl = "https://gbfs.bcycle.com/bcycle_lametro/gbfs.json";

// Get an instance of the Gbfs.Net client
var client = GbfsClient.GetInstance(laMetroGbfsFeedUrl);

// Get the GBFS manifest, which includes references to the different feeds of information about this bikeshare system
var manifest = await client.GetManifest();

// Determine which language to refer to in the manifest. Here, if English is available, it is being preferred.
var language = manifest.Data.ContainsKey("en") ? "en" : manifest.Data.Keys.First();

// Get the bikeshare station information (Location, name, etc.)
var stations = await manifest.GetStationInformation(client, language);

// Find all the stations on Grand Ave.
var selectedStations = stations.Data.Stations
	.Where(s => s.Address.Contains("Grand Ave"))
	.ToList();

// Get the bikeshare station status (number of bikes and docks available, etc.)
var statuses = await manifest.GetStationStatus(client, language);

// Join the station and status information on StationId
statuses.Data.Stations
	.Join(selectedStations, s => s.StationId, s => s.StationId, (status, station) => new
	{
		Station = station,
		Status = status,
	})
	.ToList()
	// Write out some information about the stations
	.ForEach(x => Console.WriteLine($"Station at {x.Station.Name} has {x.Status.NumBikesAvailable} bikes available and {x.Status.NumDocksAvailable} docks available"));

Building

Travis NuGet NuGet Pre Release

This library is built using .NET Core. To build:

dotnet build

Running the JSON Schema generator can be done via:

cd src/Gbfs.Net.JsonSchemaGenerator

# Returns help
dotnet run

# Generates schema in the artifacts folder
dotnet run -o artifacts

Code of Conduct

We are committed to fostering an open and welcoming environment. Please read our code of conduct before participating in or contributing to this project.

Contributing

We welcome contributions and collaboration on this project. Please read our contributor's guide to understand how best to work with us.

License and Authors

GMV Syncromatics Engineering logo GMV Syncromatics Engineering

license GitHub contributors

This software is made available by GMV Syncromatics Engineering under the MIT license.

About

Library to interact with General Bikeshare Feed Specification (GBFS) resources

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages