The FASTEST Way To Build API Clients in .NET

preview_player
Показать описание
If we are building APIs, chances are that these APIs will be consumed by different other apps. One very important pattern to facilitate the work with existing APIs is to offer so-called API clients in different programmin languages, so that consumers can easily interact with our APIs. In this video, I'll show you THE FASTEST way to create such API clients in .NET using the Refit library. Don't miss it!
#dotnet #aspnetcore #csharp #programming

Join this channel to get source code access and other perks:

Also follow me here (especially if you are a self taught developer):

Content:
1. Intro: 00:00
2. What are API clients? 00:09
3. Architecture overview: 01:14
4. Introducing Refit: 02:45
5. Refit interfaces: 03:27
6. API client wrapper: 06:26
7. Setting up dependency injection: 08:34
8. Consuming API client in Blazor WASM: 10:11

My setup:
Рекомендации по теме
Комментарии
Автор

As it already exposes endpoints on the mentors client, I’d name them Mentors.CreateAsync() instead of Mentors.CreateMentorsAsync(); less clutter imho.

larsp
Автор

Holy Molly. JUST WHEN I needed this type of video, you deliver. Well played code wrinkles

magisteriumemporium
Автор

00:01 Creating professional API clients for .NET applications
01:46 Building API clients in .NET using Refit library
03:15 Refit allows creating professional API clients in minutes
04:51 Rapid API client configuration is straightforward and utilizes common patterns.
06:25 Creating API client library requires multiple classes
07:57 Setting up and using Mentor API options in .NET
09:31 Configuring HTTP client Factory
11:10 Designing the API client for ease of resource management
Crafted by Merlin AI.

bradmca
Автор

Hi Mr.Dan
In Blazor wasm most of the time I inject more than a client repository in the blazor page.
[Inject] private LecturesRepository LecturesRepository { get; set; }
[Inject] private PersonsRepository PersonsRepository { get; set; }
...
is there a better way to call/load any repository from 1 service (eager loading ) as we do in Unit Of Work?

Tamer_Ali
Автор

Is there is public repository with this solution?

iuribaltieri
Автор

Great video. Quick question, in a clean Architecture structure, the refit interface will belong to infrastructure Cuz is kind of consuming external resources. But that interface is gonna be used in, for example, in a handler from mediatr which belongs to Application layer, in there we are violating the Clean arch principles cuz now Application have a Reference to Infrastructure which shouldn't be. What is your opinion on that? That's always been my struggle with Refit

Urfavoriteartist_heartz
Автор

Hello Code Wrinklers, Thanks you for this great video, how can i implement it with authentication and authorisation?

MrClinsaure
Автор

Isn't it way less work to just generate an API Client with a Swagger json file using Kiota?
Refit seems like too much manual work.

duznt-xizt