A388

Geocod.io API Implementation in C#

Geocod.io is a simple and straightforward geocoding service. I use it at my work to get the positions of job sites needed by some other automated processes.

The client is available as a NuGet package here and targets .NET Standard 1.1.

To use the client, create an instance of GeocodioClient and pass in an instance of HttpClient and your API key. For a short example of how it works, take a look at the linked video.

var geocodio = new GeocodioClient(httpClient, "{key}");

Once you have the client instance you can use the built in helper methods or compose custom requests. For example:

Get Geocode

var geocode = await geocodio.GetGeocodeAsync("1600 Pennsylvania Ave NW, Washington, DC 20500");

Get Geocode Batch

var geocodeBatch = await geocodio.GetGeocodeBatchAsync(new[] {
    "1600 Pennsylvania Ave NW, Washington, DC 20500",
    "East Capitol St NE & First St SE, Washington, DC 20004"
});

Get Reverse Geocode

var reverse = await geocodio.GetReverseGeocodeAsync("38.897675,-77.036547");

Get Reverse Geocode Batch

var reverseBatch = await geocodio.GetReverseGeocodeBatchAsync(new[] {
    "38.897675,-77.036547",
    "38.898976,-77.038219"
});

Carmine.io API Implementation in C#

Carmine.io is a fleet tracking service we use at my work. I integrated it into our system so I could to some more advanced vehicle to job site correlations. I had to make my own client to tap into their API and I want to share it.

It is available as NuGet package here and targets .NET Standard 1.1.

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, especially when it comes to the HttpClient instance. 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}");