Osrm.Client.NetCore 4.0.0

dotnet add package Osrm.Client.NetCore --version 4.0.0
                    
NuGet\Install-Package Osrm.Client.NetCore -Version 4.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Osrm.Client.NetCore" Version="4.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Osrm.Client.NetCore" Version="4.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Osrm.Client.NetCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Osrm.Client.NetCore --version 4.0.0
                    
#r "nuget: Osrm.Client.NetCore, 4.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Osrm.Client.NetCore@4.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Osrm.Client.NetCore&version=4.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Osrm.Client.NetCore&version=4.0.0
                    
Install as a Cake Tool

Osrm.Client

Modern .NET client for the OSRM 5.x HTTP API.

Package

  • NuGet package: Osrm.Client.NetCore
  • Primary target: net9.0
  • Compatibility target: netstandard2.0

Version 4 is a major modernization release. It is built for current .NET first, while still offering a low-maintenance compatibility target for older consumers that can use netstandard2.0.

Support policy

  • net9.0 is the primary, actively validated target for ongoing development.
  • netstandard2.0 is provided as a compatibility target for older consumers, but it is not intended to drive design decisions or extensive compatibility shims.
  • The package is focused on OSRM 5.x JSON HTTP APIs through the current Osrm5x / IOsrmClient model.

Supported OSRM services

  • Route
  • Table
  • Match
  • Nearest
  • Trip

This package targets the JSON-based OSRM 5.x HTTP API surface exposed through Osrm5x and IOsrmClient.

Feature coverage highlights

  • Shared request options across services:
    • bearings, radiuses, hints
    • generate_hints
    • approaches
    • exclude
    • snapping
    • skip_waypoints
    • polyline-encoded coordinate input
  • Route options:
    • boolean or numeric alternatives
    • steps
    • annotations
    • geometries / overview
    • continue-straight
    • explicit waypoint indexes
  • Table options:
    • sources / destinations
    • duration or distance annotations
    • fallback_speed
    • fallback_coordinate
    • scale_factor
  • Match options:
    • timestamps
    • steps
    • annotations
    • geometries / overview
    • gaps
    • tidy
    • explicit waypoint indexes
  • Trip options:
    • steps
    • annotations
    • geometries / overview
    • roundtrip
    • source
    • destination

Response model coverage highlights

  • Top-level data_version
  • Route weight and weight_name
  • Leg annotation
  • Step metadata including intersections, lanes, pronunciations, refs, exits, and driving side
  • Waypoint metadata including nodes and alternatives count
  • Table distances, nullable matrix cells, and fallback_speed_cells
  • Geometry decoding for polyline, polyline6, and geojson

The public API always uses Location(latitude, longitude). OSRM wire-format coordinates are translated internally from [longitude, latitude].

Quick start

using Osrm.Client;
using Osrm.Client.Models;
using Osrm.Client.Models.Requests;

using HttpClient httpClient = new();
var osrm = new Osrm5x(httpClient, "https://router.project-osrm.org/");

var locations = new[]
{
    new Location(52.503033, 13.420526),
    new Location(52.516582, 13.429290),
};

var route = await osrm.Route(new RouteRequest
{
    Coordinates = locations,
    Steps = true,
    Annotations = "distance,duration",
    Geometries = "geojson"
});

var matrix = await osrm.Table(new TableRequest
{
    Coordinates = locations,
    Annotations = "distance,duration"
});

Installation

dotnet add package Osrm.Client.NetCore

Validation and runtime behavior

  • Requests are validated before HTTP calls are sent.
  • Non-success OSRM responses raise HttpRequestException.
  • Osrm5x.Timeout is enforced per request and raises TimeoutException when exceeded.

Build, test, and pack

From the repository root:

dotnet restore Src/Osrm.Client.sln
dotnet build Src/Osrm.Client.sln --configuration Release
dotnet test Src/Osrm.Client.Tests/Osrm.Client.Tests.csproj --configuration Release
dotnet pack Src/Osrm.Client/Osrm.Client.csproj -c Release

The default test suite runs offline. Response tests use stubbed HttpClient responses instead of the public OSRM demo server.

Because the automated suite is intentionally offline, do one manual smoke test against a real OSRM 5.x server before publishing a package.

Publishing

  • CI validation is defined in .github/workflows/ci.yml.
  • NuGet publishing is defined in .github/workflows/publish-package.yml.
  • Publishing requires NUGET_API_KEY and pushes both the main package and symbols package.
  • Local publish scripts are available for either shell:
./scripts/publish-package.sh 4.0.0 --skip-push
NUGET_API_KEY=your-key ./scripts/publish-package.sh 4.0.0
pwsh ./scripts/publish-package.ps1 -Version 4.0.0 -SkipPush
pwsh ./scripts/publish-package.ps1 -Version 4.0.0 -ApiKey $env:NUGET_API_KEY

Release checklist

Before publishing a new package version:

  1. Confirm NuGet package ownership and that the intended account can publish Osrm.Client.NetCore.
  2. Run a dry-run release script to restore, build, test, and pack without pushing.
  3. Run at least one real smoke test against a live OSRM 5.x server.
  4. Review migration notes, intentional gaps, and breaking changes in the release notes for the version being published.
  5. Create a git tag that matches the package version so source and package history stay aligned.
  6. Publish the .nupkg and .snupkg artifacts with one of the documented local or GitHub Actions flows.

Intentional gaps

  • Tile service is not implemented.
  • Flatbuffers output is not implemented.

Deferred and future-cleanup items

  • TripRequest.Annotate is retained as a compatibility shim in v4, but it is a good candidate for future deprecation in favor of Annotations.
  • Additional lower-priority OSRM surface area should be evaluated explicitly rather than added opportunistically if it complicates the current client shape.

Migration notes for v4

  • The package now targets net9.0 and netstandard2.0.
  • Validation is stricter for malformed request options and mismatched per-coordinate arrays.
  • Response handling now correctly maps OSRM coordinate arrays into Location(latitude, longitude).
  • Geometry parsing now supports polyline6 and geojson in addition to traditional polyline responses.
  • TripRequest.Annotate is retained as a compatibility shim, but emits the correct OSRM annotations query parameter.
  • netstandard2.0 remains available for compatibility, but modern .NET is the primary support path.

Origin

Forked from narfunikita/Osrm.Client, then modernized and extended for current .NET and OSRM 5.x usage.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.0 195 7/2/2026
3.5.0 44,181 4/27/2020