A .NET client for the Party API made with Refit.
Report Bug
.
Request Feature
The latest release can be download from NuGet or from the GitHub packages and releases pages.
IPartyClient apiClient = RestService.For<IPartyClient>("https://kemono.su/api/v1");
List<Post> posts = await apiClient.GetRecentPosts();
CookieContainer container = new();
container.Add(new Cookie("session", "<session cookie>", string.Empty, "coomer.su"));
HttpClientHandler handler = new() { CookieContainer = container };
HttpClient httpClient = new(handler) { BaseAddress = new Uri("https://coomer.su/api/v1") };
IPartyClient apiClient = RestService.For<IPartyClient>(httpClient);
List<FavoriteCreator> creators = await apiClient.GetFavoriteCreators();
Configuring services
ServiceCollection collection = new();
CookieContainer container = new();
container.Add(new Cookie("session", "<session token>", string.Empty, "kemono.su"));
collection.AddHttpClient("KemonoClient", client =>
{
client.BaseAddress = new Uri("https://kemono.su/api/v1");
})
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler
{
CookieContainer = container
});
_serviceProvider = collection.BuildServiceProvider();
Getting a client from IHttpClientFactory
IPartyClient apiClient = _serviceProvider.GetRequiredService<IHttpClientFactory>().CreatePartyClient("KemonoClient");
HttpResponseMessage response = await apiClient.AddFavoriteCreator(Service.Patreon, "2448989");