KawaiiAPI.NET 1.1.0

dotnet add package KawaiiAPI.NET --version 1.1.0
                    
NuGet\Install-Package KawaiiAPI.NET -Version 1.1.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="KawaiiAPI.NET" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="KawaiiAPI.NET" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="KawaiiAPI.NET" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add KawaiiAPI.NET --version 1.1.0
                    
#r "nuget: KawaiiAPI.NET, 1.1.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.
#:package KawaiiAPI.NET@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=KawaiiAPI.NET&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=KawaiiAPI.NET&version=1.1.0
                    
Install as a Cake Tool

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

  1. 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/

  2. 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");
  1. Retrieve Random GIFs: You can use the GetRandomGifAsync method to retrieve a random GIF URL from a specific category. Pass the desired KawaiiGifType 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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.

Version Downloads Last Updated
1.1.0 1,200 8/15/2023
1.0.1 225 8/15/2023
1.0.0 245 8/14/2023

Added Exception handling if an improper token has passed