KawaiiAPI.NET
1.1.0
dotnet add package KawaiiAPI.NET --version 1.1.0
NuGet\Install-Package KawaiiAPI.NET -Version 1.1.0
<PackageReference Include="KawaiiAPI.NET" Version="1.1.0" />
<PackageVersion Include="KawaiiAPI.NET" Version="1.1.0" />
<PackageReference Include="KawaiiAPI.NET" />
paket add KawaiiAPI.NET --version 1.1.0
#r "nuget: KawaiiAPI.NET, 1.1.0"
#:package KawaiiAPI.NET@1.1.0
#addin nuget:?package=KawaiiAPI.NET&version=1.1.0
#tool nuget:?package=KawaiiAPI.NET&version=1.1.0
KawaiiAPI.NET
KawaiiAPI.NET is a C# client library that allows you to interact with the Kawaii.Red API to retrieve random GIF URLs based on different categories. Whether you're building a fun application, a website, or just want to add some cuteness to your project, this library makes it easy to fetch adorable GIFs.
Installation
You can install the KawaiiAPI.NET library via NuGet Package Manager
Install-Package KawaiiAPI.NET
Or by using the .NET CLI:
dotnet add package KawaiiAPI.NET
Getting Started
Obtain an API Token: To use the KawaiiAPI.NET library, you need an API token from Kawaii.Red. You can sign up on their website to get a token. https://kawaii.red/
Initialize the Client: Once you have an API token, you can create an instance of the
KawaiiClient
class. If you don't provide a token, the client will use the anonymous token by default.
using KawaiiAPI.NET;
// Initialize the client with your API token
var client = new KawaiiClient("your-api-token");
- Retrieve Random GIFs: You can use the
GetRandomGifAsync
method to retrieve a random GIF URL from a specific category. Pass the desiredKawaiiGifType
to the method.
using KawaiiAPI.NET.Enums;
// Get a random GIF URL from a specific category
string gifUrl = await client.GetRandomGifAsync(KawaiiGifType.Cats);`
Examples
Simple example
Here's an example of how you can use the KawaiiAPI.NET library to retrieve a random hug
GIF:
using System;
using System.Threading.Tasks;
using KawaiiAPI.NET;
using KawaiiAPI.NET.Enums;
class Program
{
static async Task Main(string[] args)
{
var kawaiiclient = new KawaiiClient("your-api-token");
try
{
string catGifUrl = await kawaiiclient.GetRandomGifAsync(KawaiiGifType.Hug);
Console.WriteLine($"Random Cat GIF URL: {hugGifUrl}");
}
catch (Exception ex)
{
Console.WriteLine($"An error occurred: {ex.Message}");
}
}
}
Example using Dependency Injection
using System;
using Microsoft.Extensions.DependencyInjection;
using KawaiiAPI.NET;
namespace DependencyInjectionExample
{
class Program
{
static void Main(string[] args)
{
// Create a service collection
var services = new ServiceCollection();
// Register KawaiiClient in the service collection
services.AddSingleton<KawaiiClient>(sp =>
{
var apiKey = "your-api-key"; // Replace with your actual API key
return new KawaiiClient(apiKey);
});
// Build the service provider
var serviceProvider = services.BuildServiceProvider();
// Get an instance of KawaiiClient from the service provider
var kawaiiClient = serviceProvider.GetRequiredService<KawaiiClient>();
// Now you can use the kawaiiClient to get random GIF URLs
try
{
var randomGifUrl = kawaiiClient.GetRandomGifAsync(KawaiiGifType.Cats).GetAwaiter().GetResult();
Console.WriteLine($"Random GIF URL: {randomGifUrl}");
}
catch (Exception ex)
{
Console.WriteLine($"An error occurred: {ex.Message}");
}
}
}
}
Discord Bot Example
soon
Contributions and Issues
Contributions, issues, and feature requests are welcome! If you encounter any problems while using the library or have suggestions for improvements, please open an issue on GitHub.
License
This project is licensed under the MIT License. Feel free to use, modify, and distribute the library according to the terms of the license.
Note: This library is not officially affiliated with KawaiiAPI. Make sure to review their API usage guidelines before integrating this library into your project.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Added Exception handling if an improper token has passed