kagi-dotnet 0.1.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package kagi-dotnet --version 0.1.3                
NuGet\Install-Package kagi-dotnet -Version 0.1.3                
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="kagi-dotnet" Version="0.1.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add kagi-dotnet --version 0.1.3                
#r "nuget: kagi-dotnet, 0.1.3"                
#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 kagi-dotnet as a Cake Addin
#addin nuget:?package=kagi-dotnet&version=0.1.3

// Install kagi-dotnet as a Cake Tool
#tool nuget:?package=kagi-dotnet&version=0.1.3                

kagi-dotnet CI

A .NET library for interacting with the Kagi API.

Features

  • API Coverage – Full support for v0 of the Universal Summarizer, FastGPT, Search, and Enrichment APIs.
  • .NET Standards Compliant – Adheres to .NET best practices and conventions.

Installation

Install the library via NuGet:

dotnet add package kagi-dotnet

Extensions

Install optional library extensions for more functionality, depending on your use case.

Dependency Injection

Integrate gravatar-dotnet and your DI container of choice. Install the extension library via NuGet:

dotnet add package kagi-dotnet-dependencyinjection

Usage

  1. Obtain your API key from the Kagi API portal (requires a Kagi account).
  2. Pass the API key into a new instance of the KagiService class or use a configured HttpClient if advanced configuration (e.g., proxies) is required.
  3. Use the methods available on KagiService to interact with the Kagi API.

Initialization

The library can be initialized in three ways:

Basic Initialization

Pass in your API key directly:

var kagi = new KagiService("YOUR_KAGI_API_KEY");
Advanced Initialization

Use an existing HttpClient, ensuring that BaseAddress and an Authorization header have been set:

var httpClient = new HttpClient
{
    BaseAddress = new Uri("https://kagi.com/api/v0/"),
    Timeout = TimeSpan.FromSeconds(5)
};

httpClient.DefaultRequestHeaders.Authorization =
	new AuthenticationHeaderValue("Bot", "YOUR_KAGI_API_KEY");

var kagi = new KagiService(httpClient);
Dependency Injection

If you've installed the appropriate extension library.

  1. Register KagiService with your dependency container:
services.AddKagiHttpClient(options =>
{
	options.BaseUrl = new Uri("https://kagi.com/api/v0/");
	options.ApiKey = "YOUR_KAGI_API_KEY";
});
  1. Inject IKagiService where needed:
public class MyClass
{
    private readonly IKagiService kagi;

    public MyClass(IKagiService kagi)
    {
        this.kagi = kagi;
    }
}

Summarization

The Universal Summarizer API uses large language models to generate summaries for various types of content.

var summarizeOptions = new KagiSummarizeOptions
{
    // Provide either a URL to summarize...
    Url = new Uri("https://en.wikipedia.org/wiki/Kagi_(search_engine)")

    // ...or raw text content.
    Text = "Kagi is a paid ad-free search engine developed by Kagi Inc..."
};

var summarizeResult = await kagi.SummarizeAsync(summarizeOptions);
	
Console.WriteLine(summarizeResult.Data.Output);

Search-augmented Q&A

The FastGPT API combines Kagi’s search engine with language models to answer queries.

var answerOptions = new KagiAnswerOptions
{
    Query = "What is the airspeed of a fully-laden swallow?"
};

var answerResult = await kagi.AnswerAsync(answerOptions);

Console.WriteLine(
	$"{answerResult.Data.Output}\n\n" +
	$"References Used: {answerResult.Data.References.Length}");

The Search API allows you to access Kagi’s search engine programmatically.

[!NOTE] This API is currently in closed beta for business users.

var searchResults = await kagi.SearchAsync("weather today", limit: 20);

foreach (var item in searchResults.Data)
{
    if (item is KagiRecordSearchData record)
    {
        // Item contains a search result (i.e. with a URL, title, optional snippet, etc.)
    }
    else if (item is KagiRelatedQuerySearchData relatedQuery)
    {
        // Item contains a list of related queries
    }
}

Enrichment APIs for Supplemental Content

The Enrichment API allows you to access unique web content from Kagi’s specialized indexes, Teclis (for web content) and TinyGem (for news). This API is designed to provide specialized, non-mainstream results and is ideal for enhancing broader search results.

Web Enrichment

Retrieve supplemental results focused on high-quality "small web" content.

var webEnrichmentResults = await kagi.SearchWebEnrichmentsAsync("coffee blog");

foreach (var item in webEnrichmentResults.Data)
{
    // Processing similar to the Search API output
}
News Enrichment

Retrieve non-mainstream, high-quality news content relevant to your query.

var newsEnrichmentResults = await kagi.SearchNewsEnrichmentsAsync("local news");

foreach (var item in newsEnrichmentResults.Data)
{
    // Processing similar to the Search API output
}

Documentation

Refer to the Usage section above for a quick start, or consult the inline documentation while working in your IDE. For detailed information about the underlying API endpoints, parameters, and expected responses, refer to the official Kagi API documentation.

Contributing

Contributions are welcome! To contribute, fork the repository, create a new branch, and submit a pull request with your changes. Please make sure all tests pass before submitting.

License

This project is licensed under the MIT license. See license.txt for full details.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on kagi-dotnet:

Package Downloads
kagi-dotnet-dependencyinjection

A .NET library for interacting with the Kagi API

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.1.4 109 11/8/2024
0.1.3 116 11/8/2024
0.1.2 81 11/7/2024
0.1.1 82 11/2/2024
0.1.0 81 11/2/2024