FREEDOM251

Freedom251 › API clients

Refit

Free plan APIWebWindows

Visit Refit Alternatives

Refit's own site

What Refit is

Refit is a free C# library that turns an interface into an HTTP client and generates the implementation during the build. Attributes on interface methods define HTTP methods, routes, headers, and request bodies, while method arguments can populate route placeholders. Applications retain control of HttpClient, cancellation, and serialization. System.Text.Json is the default serializer; separate packages add Newtonsoft.Json and XML support, and generated JSON metadata is documented for ahead-of-time compilation. Refit handles query parameters, forms, serialized bodies, and response types including Task<T>, ValueTask<T>, IObservable<T>, response wrappers, and IAsyncEnumerable<T>. Streaming includes JSON arrays, JSON Lines, and server-sent events. Refit.HttpClientFactory supports dependency-injection registration with IHttpClientFactory. Refit.Testing can provide local replies, verify outgoing requests, and simulate network faults. The source generator requires Roslyn 4.8 or newer and PackageReference. Source projects target .NET 8, 9, 10, and 11, plus .NET Framework 4.6.2 through 4.8.1. It is distributed under the MIT License.

Who it suits

Refit suits .NET developers who want generated HTTP clients from declarative C# interfaces. It is useful when applications need custom serialization control, dependency injection, streaming, testing, or ahead-of-time compilation.

What it does well

  • Generates HTTP clients from C# interfaces
  • Supports multiple response and streaming types
  • Keeps application control of HttpClient
  • Includes testing helpers for faults and requests
  • Distributed under the MIT License

What to know first

  • Source generator requires Roslyn 4.8 or newer
  • Requires PackageReference setup
  • Targets listed frameworks only

Verdict

Refit provides a free, attribute-driven way to generate HTTP clients while leaving core client and serialization choices in the application. Its testing, streaming, dependency-injection, and ahead-of-time documentation broaden its use across supported .NET targets.

Facts from Refit's own pages

Ahead-of-time compilation
Refit documents generated clients and JSON code for apps compiled ahead of time. · reactiveui.net, 11 Oct 2026
Automated test runs
Yes · reactiveui.github.io, 22 Sept 2026
Build requirements
The source generator requires Roslyn 4.8 or newer and PackageReference; the README names .NET SDK 8.0.100 and Visual Studio 2022 17.8 as providing that compiler baseline. · github.com, 11 Oct 2026
Dependency injection
Refit.HttpClientFactory registers clients with dependency injection and IHttpClientFactory. · github.com, 11 Oct 2026
Diagnostics
Refit has a diagnostics guide for observing client activity. · reactiveui.net, 11 Oct 2026
Free plan
Yes · reactiveui.github.io, 22 Sept 2026
History
The license file says Anna Betts created Refit in 2012 and ReactiveUI has maintained it since. · github.com, 11 Oct 2026
HTTP client
Generated implementations send requests through HttpClient, which the app controls. · reactiveui.net, 11 Oct 2026
HTTP client control
Applications retain control of HttpClient, cancellation, and serialization. · github.com, 11 Oct 2026
Integration
Refit uses HttpClient and documents registering clients with dependency injection. · reactiveui.net, 11 Oct 2026
License
The Refit project is licensed under the MIT license. · github.com, 11 Oct 2026
Native AOT
The documentation describes generated clients and JSON metadata for apps compiled ahead of time. · reactiveui.net, 11 Oct 2026
Package
The project instructs users to install the Refit NuGet package in the project that declares the interface. · reactiveui.net, 11 Oct 2026
Available platforms
web_and_desktop · reactiveui.github.io, 22 Sept 2026
Purpose
Refit turns a C# interface into an HTTP client and generates its implementation during the build. · reactiveui.net, 11 Oct 2026
Request definition
Attributes on interface methods describe HTTP methods, routes, headers, and request bodies. · github.com, 11 Oct 2026
Requests and responses
The library supports route and query parameters, headers, serialized bodies, forms, and response types including Task<T>, ValueTask<T>, and IObservable<T>. · github.com, 11 Oct 2026
Request types
Refit supports routes and HTTP methods, including route placeholders populated from method arguments. · reactiveui.net, 11 Oct 2026
Return types
The documentation lists Task<T>, ValueTask<T>, IObservable<T>, response wrappers and IAsyncEnumerable<T> for streaming replies. · reactiveui.net, 11 Oct 2026
Serialization
Refit uses System.Text.Json by default and supports generated JSON metadata; separate packages provide Newtonsoft.Json and XML serializers. · github.com, 11 Oct 2026
Streaming
Refit supports streamed JSON arrays, JSON Lines, and server-sent events. · github.com, 11 Oct 2026
Target frameworks
The source projects target .NET 8, 9, 10, and 11, plus .NET Framework 4.6.2 through 4.8.1. · github.com, 11 Oct 2026
Testing
Refit.Testing can supply local replies, verify outgoing requests, and simulate network faults. · github.com, 11 Oct 2026

Where Refit stands on Freedom251

Look at these too