KSoftNet 4.0.0

dotnet add package KSoftNet --version 4.0.0                
NuGet\Install-Package KSoftNet -Version 4.0.0                
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="KSoftNet" Version="4.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add KSoftNet --version 4.0.0                
#r "nuget: KSoftNet, 4.0.0"                
#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 KSoftNet as a Cake Addin
#addin nuget:?package=KSoftNet&version=4.0.0

// Install KSoftNet as a Cake Tool
#tool nuget:?package=KSoftNet&version=4.0.0                

KSoft.si API Wrapper

nuget version downloads

http://api.ksoft.si

Overview

KSoft.Si API is a professional, fast, reliable and easy to use multi-function service for Discord bot developers or websites. It provides easy, no-nonsense endpoints with an extensive library of images, user data, weather, geo-location and songs. We help you build awesome services and keep Discord community safe and sound.

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

Getting started

Installing the package

Add the NuGet package KSoftNet to your project:

dotnet add package KSoftNet

Simple usage

A minimal example to get a random image by tag

A complete example is available in the examples/SimpleUsage project

using System;
using System.Threading.Tasks;
using KSoftNet;

public class ExampleClass {
  private readonly KSoftApi _kSoftApi;

  public ExampleClass(string token) {
    _kSoftApi = new KSoftApi(token);
  }

  public async Task GetRandomImage(string tag) {
    var image = await _kSoftApi.ImagesApi.GetRandomImage(tag: tag);

    Console.WriteLine(image.Url);
  }
}

Example using custom HttpClient

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

A complete example is available in the examples/CustomHttpclient project

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

public ExampleClass(string token) {
  var httpClient = new HttpClient {
    BaseAddress = new Uri("https://api.ksoft.si"),
    DefaultRequestHeaders = {
      Authorization = new AuthenticationHeaderValue("Bearer", token)
    }
  };

  _kSoftApi = new KSoftApi(httpClient);
}

Example using dependency injection

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

A complete example is available in the examples/DependencyInjection project

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

public class Startup {
  private const string Token = "{token}";
  private KSoftApi _kSoftApi;

  private IServiceProvider _serviceProvider;

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

    _kSoftApi = new KSoftApi(Token);

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

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

    var image = await exampleClass.GetRandomImage("birb");

    Console.WriteLine(image.Url);
  }

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

Using this in a class:

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

public class ExampleClass {
  private readonly KSoftApi _kSoftApi;

  public ExampleClass(KSoftApi kSoftApi) {
    _kSoftApi = kSoftApi;
  }

  public async Task<Image> GetRandomImage(string tag) {
    var image = await _kSoftApi.ImagesApi.GetRandomImage(tag: tag);

    return image;
  }
}
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  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. 
.NET Core netcoreapp2.1 is compatible.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 is compatible. 
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.

Version Downloads Last updated
4.0.0 1,095 9/10/2021
3.0.1 820 3/17/2021
3.0.0 777 2/28/2021
2.4.1 869 8/2/2020
2.4.0 928 4/30/2020