Shaunebu.Common.RESTClient The Next-Generation REST Framework for .NET
π Introducing Shaunebu.Common.RESTClient β The Next-Generation REST Framework for .NET
Modern .NET applications demand far more than simple HTTP calls. We now build microservices, distributed systems, mobile apps, SDKs, and enterprise integrations where reliability, observability, and resiliency aren't optional β they are essential.
Tools like Refit brought simplicity and elegance to REST interfaces. But once we enter real-world scenarios β retries, fallbacks, caching, multi-serialization, OpenTelemetry, token refresh, offline modes, resilience policies β things quickly get complicated. Today, Iβm excited to introduce:
π Shaunebu.Common.RESTClient
A next-generation, attribute-driven REST framework for .NET
built for enterprise resiliency, observability, extensibility, and simplicity. This is not βjust another Refit clone.β
This is the evolution.
π Overview
Shaunebu.Common.RESTClient lets you define REST APIs using interfaces β just like Refit β but adds an entire production-grade stack:
- βοΈ Automatic Polly-based resiliency
- βοΈ Typed fallbacks
- βοΈ Dynamic multi-serialization (JSON, XML, Protobuf, MessagePack)
- βοΈ Interceptor pipeline for logging, telemetry, caching & more
- βοΈ OpenTelemetry auto-instrumentation
- βοΈ Unified DI registration
- βοΈ Upload & download progress tracking
- βοΈ Offline support through fallback providers
- βοΈ Content negotiation based on Accept headers
- βοΈ Fully extensible architecture
Everything works without extra setup.
π§ Why I built this library
Refit is amazing β I've used it for years.
But in real-world applications I kept facing issues like:
- βHow do I retry only this method?β
- βHow do I apply a circuit breaker per call?β
- βHow do I use multiple serializers?β
- βHow do I log every request and response?β
- βHow do I send protobuf on one endpoint and JSON on another?β
- βHow do I add fallback logic?β
- βHow do I track upload/download progress?β
- βHow do I make everything observable with OpenTelemetry?β
I wanted a framework that feels as simple as Refit,
but powered for enterprise, built around modern system demands. So I built:
π₯ A production-ready REST SDK generator
RESTClient is designed with the philosophy:
βRefit lets you call APIs β RESTClient lets you build SDKs for APIs.β
π§ How It Works (Architecture)
RESTClient has a clean, layered architecture:
Interface
β
Attribute Parser
β
Proxy Generator
β
Interceptor Pipeline
β
Serializer Selection (Content Negotiation)
β
Resilience Engine (Polly)
β
HttpClient Transport
β
Response Materializer
Each stage is extensible, replaceable, and designed for high-performance.
β¨ Quick Start
Define your API interface:
Register it:
Use it:
Zero boilerplate. Everything is ready instantly.
π‘οΈ Enterprise-Grade Resilience (Polly Built-In)
Add retries, timeouts, circuit breakers, or bulkhead isolation β per method.
No need to manually configure HttpClient handlers. RESTClient does it automatically. βοΈ
π₯ Typed Fallback Providers (Offline Mode)
Gracefully handle failure without throwing exceptions:
Provider:
RESTClient automatically adds:
Perfect for:
- Offline apps
- Partial outages
- Fail-soft architectures
π¦ Multi-Serialization (JSON, XML, Protobuf, MessagePack)
Per-method control:
Or automatic based on Accept header:
RESTClient picks the right serializer.
No configuration. No custom HttpContent.
Just works. βοΈ
π Interceptor Pipeline
RESTClient includes a full middleware-like pipeline: Built-in interceptors:
- π SecurityInterceptor
- π§± ResilienceInterceptor
- πͺ΅ LoggingInterceptor
- π§ OpenTelemetryInterceptor
- π§ͺ DebugInterceptor
- πͺ£ CachingInterceptor
- π₯ FallbackInterceptor
- π MetricsInterceptor
Add your own:
Register it:
π Observability Built-In (OpenTelemetry)
RESTClient emits:
- trace spans
- request attributes
- latency metrics
- error signals
- fallback flags
- retry counts
Automatically. You get distributed tracing across microservices with zero setup.
β±οΈ Upload / Download Progress
Progress reports 0.0 β 1.0. Perfect for mobile, desktop, and MAUI apps.
π§© Advanced Attribute Model
RESTClient supports over 20 attributes to fine-tune behavior:
[Get]/[Post]/[Put]/[Delete]/[Patch][Headers]/[Header][AliasAs][Fallback][Retry]/[Timeout]/[CircuitBreaker]/[Bulkhead][Multipart][Query][Host][RateLimit][HealthCheck]
Extremely flexible.
π§± Caching & Metrics Support
Via interceptors:
- memory cache
- distributed cache
- method-level control
- cache invalidation
- cache keys based on URL, query, headers
Plus full metrics via OpenTelemetry.
π Comparison: RESTClient vs Refit
| Feature | RESTClient | Refit |
|---|---|---|
| DI Unified Registration | β | β |
| Centralized Config | β | β οΈ |
| Polly Integration | Automatically | Manual |
| Resilience Attributes | β | β |
| Typed Fallbacks | β | β |
| Multi-Serialization | JSON, XML, Protobuf, MsgPack | JSON only |
| Content Negotiation | Automatic | β |
| Interceptor Pipeline | Full | β |
| Logging + Telemetry | Built-in | Partial |
| Caching | Yes | β |
| Upload Progress | Yes | β |
| Host Override | Yes | Yes |
| OpenTelemetry | Integrated | β |
| Production Ready | βββ | β |
π οΈ Use Cases
1. SDK Development
Build full API SDKs with minimal code.
2. Microservices
Per-method resilience, tracing, and caching.
3. Mobile Apps / MAUI
Offline fallbacks + progress tracking.
4. External Integrations
Multiple serializers per endpoint.
5. High Observability Systems
Every request is traceable.
π Final Thoughts
Shaunebu.Common.RESTClient is built to bring together the simplicity of Refit with the power of enterprise frameworks such as:
- Polly
- AspNetCore middleware
- OpenTelemetry
- MessagePack / Protobuf
- Distributed caching
If youβre building anything modern with .NET β RESTClient will make your integrations faster, safer, more observable, and easier to maintain.
π NuGet
π https://www.nuget.org/packages/Shaunebu.Common.RESTClient
