KSoftNet 4.0.0
dotnet add package KSoftNet --version 4.0.0
NuGet\Install-Package KSoftNet -Version 4.0.0
<PackageReference Include="KSoftNet" Version="4.0.0" />
paket add KSoftNet --version 4.0.0
#r "nuget: KSoftNet, 4.0.0"
// 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
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 | Versions 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. |
-
.NETCoreApp 2.1
- Newtonsoft.Json (>= 12.0.3)
- Refit (>= 6.0.94)
-
.NETCoreApp 3.1
- Newtonsoft.Json (>= 12.0.3)
- Refit (>= 6.0.94)
-
net5.0
- Newtonsoft.Json (>= 12.0.3)
- Refit (>= 6.0.94)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.