Awesome
BikeshareClient
Dotnet client for the General Bikeshare Feed Specification (GBFS). Mainly used against Urban Infrastructure Partner, with Trondheim City Bike and Bergen City Bike.
For all available GBFS systems, see the system overview from the GBFS project.
Supports the required fields in the GBFS standard for now.
Basic Usage
// Create the client from a GBFS API URL.
IBikeshareClient client = new Client("http://gbfs.urbansharing.com/trondheim/gbfs.json");
// Or with an existing HTTPClient
IBikeshareClient client = new Client("http://gbfs.urbansharing.com/trondheim/gbfs.json", httpClient);
// All available stations, containing name, id, lat, long, address and capacity
var stations = await client.GetStationsAsync();
// All stations status, containing number of bikes and docks available, is renting, is returning etc.
var statuses = await client.GetStationsStatusAsync();
A simple dotnet-script test script for the client can be seen here.
Microsoft.Extensions.DependencyInjection integration
BikeshareClient
can be registered to IServiceCollection
by referencing the BikeshareClient.DependencyInjection
NuGet package:
using BikeshareClient.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
services.AddBikeshareClient("http://gbfs.urbansharing.com/trondheim/gbfs.json");
Build and testscript
Simple build:
docker run --rm -it -v $(pwd):/app mcr.microsoft.com/dotnet/sdk:7.0 dotnet pack app/src/BikeshareClient -o /app
Run test script:
docker run --rm -it -v $(pwd)/src/TestScript/:/scripts andmos/dotnet-script main.csx "Skansen"
GBFS is a standard backed by the North American Bike Share Association (NABSA).