A388

Carmine.io API Implementation in C#

Carmine.io is a GPS fleet tracking service we use at my work. I integrated it into our system so I could do some more advanced vehicle to job site correlations, but I had to make my own client for the API. The client used to be a part of the main project, but I've since decided to separate it into its own project and to make a NuGet package out of it. The NuGet package targets .NET Standard 1.1. The source code is on GitHub here.

To use the client you just need to create an instance of CarmineClient and pass in an instance of HttpClient and your API key. Using dependency injection you can make this pretty simple. Take a peek at the linked video for a short example of how it works.

var carmine = new CarmineClient(
    httpClient,
    "{key}"
);

Once you have the client instance, you can just use the helper methods for quick operations, or build a custom request and pass it to the appropriate method. For example:

Get a List of Vehicles

var vehicles = await carmine.GetVehiclesAsync();

Get a Vehicle

var vehicle = await carmine.GetVehicleAsync(
    "{vehicleId}"
);

Get a List of Users

var users = await carmine.GetUsersAsync();

Get a User

var user = await carmine.GetUserAsync(
    "{userId}"
);

Get a List of Trips

var trips = await carmine.GetTripsAsync();

Get a Trip

var trip = await carmine.GetTripAsync(
    "{tripId}"
);

Get Waypoints for a Trip

var waypoints = await carmine.GetWaypointsAsync(
    "{tripId}"
);
View or Start a DISQUS Thread