I'm currently building a client for a RESTful API with ASP.NET Core 5 and Refit (using HttpClientFactory). What I'm a little confused about, is how to divide the API interfaces (how many separate interfaces to write for different API endpoints/ressources).
Let's say we have an API with the following endpoints, each with a few subroutes (e.g. .../{id} or .../{id}/pets) and/or different HTTP verbs: http://myhost/api/customers and http://myhost/api/employees
What's the best practice here, writing one interface IMyHostApi
which covers the whole API? Or is it better to divide this into something like IMyHostCustomersApi
and IMyHostEmployeesApi
and then add multiple Refit clients with the correspinding base addresses?
for context, the client(s) will be added like this:
services
.AddRefitClient<IGitHubApi>()
.ConfigureHttpClient(c => c.BaseAddress = new Uri("https://api.github.com"));