NekosBestApiNet 1.0.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package NekosBestApiNet --version 1.0.5                
NuGet\Install-Package NekosBestApiNet -Version 1.0.5                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NekosBestApiNet" Version="1.0.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NekosBestApiNet --version 1.0.5                
#r "nuget: NekosBestApiNet, 1.0.5"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install NekosBestApiNet as a Cake Addin
#addin nuget:?package=NekosBestApiNet&version=1.0.5

// Install NekosBestApiNet as a Cake Tool
#tool nuget:?package=NekosBestApiNet&version=1.0.5                

Nekos.Best API Wrapper

nuget version downloads

https://docs.nekos.best/index.html

Overview

Nekos.Best API is a RESTful API serving fully SFW and high quality anime images and GIFs.

We focus on giving the best experience for our users and their projects, for free.

If you find any errors/issues or want any features added, create an issue

Getting started

Installing the package

Add the NuGet package NekosBestApiNet to your project:

dotnet add package NekosBestApiNet

Simple usage

using System;
using System.Threading.Tasks;
using NekosBestApiNet;

public class ExampleClass
{
  private readonly NekosBestApi _nekosBestApi;

  public ExampleClass() 
    => _nekosBestApi = new NekosBestApi();

  public async Task Hug() 
  {
    var image = await _nekosBestApi.ActionApi.Hug();

    Console.WriteLine(image.Results.FirstOrDefault().Url);
  }
}

Example using custom HttpClient

You can provide your own HttpClient instance, but you have to set the BaseAddress manually

using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using NekosBestApiNet;

public ExampleClass() 
{
  var httpClient = new HttpClient 
  {
    BaseAddress = new Uri("https://nekos.best/api/v2")
  };

  _nekosBestApi = new NekosBestApi(httpClient);
}

Example using dependency injection

Create a ServiceCollection, then add an instance of the NekosBestApi class to it

using System;
using System.Threading.Tasks;
using NekosBestApi;
using Microsoft.Extensions.DependencyInjection;

public class Startup 
{
  private NekosBestApi _nekosBestApi;

  private IServiceProvider _serviceProvider;

  public void Init() 
  {
    var services = new ServiceCollection();

    _nekosBestApi = new NekosBestApi();

    ConfigureServices(services);
    _serviceProvider = services.BuildServiceProvider();
  }

  public async Task RunAsync() 
  {
    var exampleClass = _serviceProvider.GetService<ExampleClass>();

    var image = await _nekosBestApi.ActionApi.Hug();

    Console.WriteLine(image.Results.FirstOrDefault().Url);
  }

  private void ConfigureServices(IServiceCollection services) 
  {
    services.AddSingleton(_nekosBestApi);
    services.AddSingleton<ExampleClass>();
  }
}

Using this in a class:

using System.Threading.Tasks;
using NekosBestApi;
using NekosBestApi.Models.Images;

public class ExampleClass 
{
  private readonly NekosBestApi _nekosBestApi;

  public ExampleClass(NekosBestApi nekosBestApi) 
    => _nekosBestApi = nekosBestApi;

  public async Task<ActionResult> Hug()
    => await _nekosBestApi.Hug();
}
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.