TypedRest for .NET

TypedRest helps you build type-safe, fluent-style REST API clients. Common REST patterns such as collections are represented as classes, allowing you to write more idiomatic code.

var client = new MyClient(new Uri("http://example.com/"));

// GET /contacts
List<Contact> contactList = await client.Contacts.ReadAllAsync();

// POST /contacts -> Location: /contacts/1337
ContactEndpoint smith = await client.Contacts.CreateAsync(new Contact {Name = "Smith"});
//ContactEndpoint smith = client.Contacts["1337"];

// GET /contacts/1337
Contact contact = await smith.ReadAsync();

// PUT /contacts/1337/note
await smith.Note.SetAsync(new Note {Content = "some note"});

// GET /contacts/1337/note
Note note = await smith.Note.ReadAsync();

// DELETE /contacts/1337
await smith.DeleteAsync();

Read a more detailed Introduction to TypedRest or jump right in with the Getting started guide.

Take a look at the TypedRest.Endpoints.Generic namespace to get an overview of the available functionality.

NuGet packages

The main TypedRest library.

Adds support for streaming with ReactiveX (Rx).
Create endpoints using the types in the TypedRest.Endpoints.Reactive namespace.

Adds support for serializing using System.Text.Json instead of Newtonsoft.Json.
Pass a SystemTextJsonSerializer instance to the EntryEndpoint constructor.

Adds support for OAuth 2.0 / OpenID Connect authentication to HttpClient.
Call .AddOAuthHandler() after .AddTypedRest() (or .AddHttpClient() when not using main TypedRest package).

Build command-line interfaces for TypedRest clients.
Create commands mirroring the endpoints using the types in the TypedRest.CommandLine.Commands namespace.