Skip to content
Build type-safe fluent-style JSON REST API clients with .NET
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

TypedRest for .NET

API documentation Build status
TypedRest helps you build type-safe fluent-style REST API clients.

NuGet packages (for .NET Framework 4.5+ and .NET Standard 2.0+):
TypedRest TypedRest.Reactive TypedRest.OAuth TypedRest.CommandLine TypedRest.Wpf


We use the following terms in the library and documentation:

  • An entity is a data transfer object that can be serialized (usually as JSON).
  • An endpoint is a REST resource at a specific URI.
  • An entry endpoint is an endpoint that is the top-level URI of a REST interface.
  • An element endpoint is an endpoint that represents a single entity.
  • A collection endpoint is an endpoint that represents a collection of entities and provides an element endpoint for each of them.
  • A trigger endpoint is an endpoint that represents an RPC call to trigger a single action (intentionally un-RESTful).

Usecase sample

We'll use this simple POCO (Plain old CLR object) class modeling software packages as a sample entity type:

class Package
  public long Id { get; set; }

  public string Name { get; set; }

Getting started

Install the TypedRest NuGet package in your REST client project.

You can then use the classes EntryEndpoint, CollectionEndpoint, ElementEndpoint, PollingEndpoint, ActionEndpoint, PaginationEndpoint, StreamEndpoint and BlobEndpoint to build a local representation of a remote REST service. Based on our usecase sample this could look like this:

class SampleEntryEndpoint : EntryEndpoint
  public SampleEntryEndpoint(Uri uri) : base(uri)

  public ICollectionEndpoint<Package> Packages => new CollectionEndpoint<Package>(this, relativeUri: "packages");

You can then perform CRUD operations like this:

var server = new SampleEntryEndpoint(new Uri("http://myservice/api/"));
var packages = server.Packages.ReadAllAsync();
var element = await server.Packages.CreateAsync(new Package {...});
var package = await server.Packages[1].ReadAsync();
await server.Packages[1].UpdateAsync(package);
await server.Packages[1].DeleteAsync();

Build command-line clients

Install the TypedRest.CommandLine NuGet package in your command-line project. You can then use the classes CollectionCommand, ElementCommand, PollingCommand, ActionCommand, PaginationCommand, StreamCommand and BlobCommand to build command objects that parse arguments and operate on CollectionEndpoints, ElementEndpoints, PollingEndpoints, ActionEndpoints, PaginationEndpoints, StreamEndpoints and BlobEndpoints.

Build GUI clients

Install the TypedRest.Wpf NuGet package to build GUIs with WPF and Caliburn.Micro. Derive from Bootstrapper<TRootView> and add this class to your <Application.Resources> in App.xaml.

You can then use the classes CollectionViewModel, ElementViewModel, PollingViewModel, ActionViewModel, PaginationViewModel, StreamViewModel and BlobViewModel to operate on CollectionEndpoints, ElementEndpoints, ActionEndpoints, PaginationEndpoints, StreamEndpoints and BlobEndpoints.

You can’t perform that action at this time.