reactiveui /refit
The automatic type-safe REST library for .NET. Refit turns a REST API into a C# interface and generates the HttpClient implementation, with support for HttpClientFactory, pluggable serializers and a testing package.
★ 9,585⑂ 780👁 160⑃ 1,231● 1,033▤ 92
+1
日增长
9,585
stars
780
forks
160
watchers
1,231
prs
1,033
issues
92
releases
README
!Refit Refit Refit turns a C interface into an HTTP client. Attributes describe the request method, URL, headers and body. The source generator builds its implementation when your app compiles. Your app keeps control of HttpClient, cancellation and serialization. Start with the Refit documentation. It explains the concepts, walks through a first request, and links each topic to runnable source examples. Examples use .NET 10 and C 14 unless they state another target. Website code blocks can show a subset of a complete example and omit its test setup. Packages | Package | Purpose | | --- | --- | | Refit | Generated HTTP clients, request attributes, serializers and response types. Includes the generator, interface analyzers and code fixes. | | Refit.HttpClientFactory | Register clients with dependency injection and IHttpClientFactory, including generated-only and keyed registrations. | | Refit.Testing | Match outgoing requests, supply local replies, verify calls and simulate network faults. Release streamed replies chunk by chunk, choose how request bodies are captured, and control simulated time. | | Refit.Newtonsoft.Json | Serialize content with Newtonsoft.Json. | | Refit.Xml | Serialize XML content. | | Refit.Reflection | Optional request building through runtime reflection. Use generated clients for trimmed and Native AOT apps. | System.Text.Json with generated metadata is the preferred JSON setup. See JSON configuration and AOT guidance. What you can build | Surface | Documentation | | --- | --- | | HTTP methods, route placeholders and request inspection | Routes | | Scalar, object and collection queries; formatting and converters | Queries | | Static and dynamic headers, authorization and request state | Headers and request context | | Serialized bodies, forms, buffering and request compression | Bodies | | Task, ValueTask, IObservable and response wrappers | Return types and responses | | Streamed JSON arrays, JSON Lines and server-sent events | Streaming | | Lazy paging over cursors, offsets and Link headers with PagedEnumerable | Pagination | | JSON contexts registered at client creation and per-method JsonTypeInfo parameters | JSON | | HTTP, transport and deserialization failures | Errors | | HTTP-aware retries with provider header hints and deterministic tests | HTTP retries and local guide | | Retries, timeouts and a fresh token for each retry with Microsoft's resilience handler | Resilience | | OpenTelemetry spans and request-duration metrics labelled by Refit method and route template | Telemetry | | Local replies, request verification and simulated faults | Testing | | Deterministic tests of streamed replies, stalled or dropped bodies, streaming uploads and simulated time | Testing streams, uploads and time | See why use Refit for equivalent manual HTTP code and trade-offs. The website records known behavior discrepancies beside the affected APIs. Public API map Use the full API reference to find types, overloads, pa
Top issues
Discussions
#2358How to test multipart with SSE response?1 comments · 2026-10-15#2354How to test multipart?1 comments · 2026-10-07#2349Complicating the retrieval of the error content1 comments · 2026-10-03#2314How to debug?2 comments · 2026-08-18#2300LoggingHttpMessageHandler changes HttpHeaders added with TryAddWithoutValidation when Trace logging is enabled1 comments · 2026-08-10#2283RF0062 comments · 2026-07-30#2279Refit 13.1: Can a parameter no longer be both a path parameter and a header?2 comments · 2026-07-26#2215IApiResponse.EnsureSuccessStatusCodeAsync1 comments · 2026-07-14
Latest release
16.4.0 v16.4.0 2026-10-17Summary Refit 16.4.0 adds opt-in HTTP-aware retries, new query naming and relative URL options, and fixes for parameter binding and response handling. Existing clients keep their current behavior unless you enable the new options. HTTP-aware retries HttpRetryHandler works with Refit clients and ordinary HttpClient calls. It needs no extra resilience package or changes to your API interface. - By default, it allows three retries after the first send for GET, HEAD, OPTIONS and TRACE. It retries HTTP 408, 429, 500, 502, 503 and 504, plus HttpRequestException. A 403 retries only when the conf