explaingit

reactiveui/refit

9,482C#Audience · developerComplexity · 2/5Setup · easy

TLDR

A C# library that turns a simple interface definition into a fully working HTTP client, you describe your REST API endpoints as method signatures and Refit writes all the networking code for you.

Mindmap

mindmap
  root((refit))
    What it does
      REST API client
      Interface to HTTP
      Source code generation
    Features
      HTTP methods
      Auth headers
      File uploads
      JSON parsing
    Tech Stack
      C#
      ASP.NET Core
      NuGet
    Use Cases
      API integration
      HTTP client setup
      Microservices calls
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Replace hand-written HttpClient boilerplate in an ASP.NET Core app by defining your API as a C# interface.

USE CASE 2

Call a third-party REST API from a .NET app with automatic JSON parsing and retry policies via Polly.

USE CASE 3

Add bearer token authentication to all outbound API calls by configuring a single Refit client setup.

Tech stack

C#.NETASP.NET CoreNuGetSystem.Text.Json

Getting it running

Difficulty · easy Time to first run · 5min

In plain English

Refit is a C# library that lets developers define a web API as a simple interface with annotations, and then generates all the code needed to actually make HTTP requests. Instead of manually writing boilerplate for HTTP calls, headers, and response parsing, you describe the API endpoints as method signatures in an interface, and Refit handles the rest at compile time using source code generation. The result is that calling a remote API looks like calling a regular local method. For example, you write a C# interface with an attribute like [Get("/users/{user}")] on a method, pass that interface to Refit, and you get back an object you can call directly. Refit takes care of building the URL, sending the request, handling the response body, and deserializing JSON. It supports GET, POST, PUT, DELETE, PATCH, and HEAD requests, along with query strings, request bodies, file uploads, and custom headers. The library works across the .NET ecosystem: .NET 8, 9, and 10.NET Framework 4.6.2 and above, Blazor web apps, WinUI desktop apps, and Uno Platform. It integrates with the standard .NET dependency injection pattern via HttpClientFactory, making it straightforward to register API clients in ASP.NET Core applications. JSON serialization defaults to System.Text.Json in current versions, with an optional add-on package available for projects that need Newtonsoft.Json compatibility. Refit is available as a NuGet package. The README covers many configuration scenarios: dynamic and static headers, bearer authentication, multipart file uploads, error handling, interface inheritance, and integration with Polly for retry and circuit-breaker policies. It also has a separate package for XML content if that is needed. The project is maintained under the ReactiveUI organization on GitHub and is sponsored by several companies. It has been in active development for many years and is widely used in .NET projects that consume REST APIs. The full README is longer than what was shown.

Copy-paste prompts

Prompt 1
Using Refit in a .NET 8 app, define a C# interface for the GitHub API that fetches a user profile and lists their repositories.
Prompt 2
Show me how to configure a Refit client with bearer token authentication in ASP.NET Core using HttpClientFactory.
Prompt 3
Write a Refit interface method that posts a multipart form with a file upload to a REST endpoint.
Prompt 4
How do I add Polly retry and circuit-breaker policies to a Refit client registered in an ASP.NET Core project?
Open on GitHub → Explain another repo

← reactiveui on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.