Skip to content

kagisearch/kagi-api-golang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go API client for openapi

The Kagi API provides programmatic access to data that powers our search results & more.

Quick start for all APIs:

  • Create an account at Kagi
  • Generate an API key
  • Call the API

We have the following APIs available.

Commercial

  • Kagi Search API (invite only at the moment)
  • Web and News Enrichment API (public, exposes Kagi's own indexes Teclis and TinyGem)
  • Universal Summarizer API (public)
  • FastGPT API (public)

Free

  • Kagi Small Web RSS feed (public)

Official Client Libraries

We offer the following libraries you can use to interact with the Kagi API. These are generated from an OpenAPI spec. If you have a language you would like to use and it's not in the list, send us a message and we will add it to the list if it is supported. Or you can use the spec to build your own custom library.

Unofficial Client Libraries

There also exist third party libraries for interacting with the Kagi API.

API Status

Our existing API, the "v0" beta API, is being replaced with a new version that will be available publicly soon. As changes are made, we will be updating the documentation below when the new features become available.

See the Support and Community section for details.

Pricing

We are in the process of moving all APIs to a post-paid tiered system, where each tier has a limit on the number of requests that can be made. If an API has a pricing section, then it is still being migrated over to the new billing system.

GitHub Discussions

This is the preferred venue for bug reports and feature requests.

Discord

Join our Discord! Good for quick questions or chatting about things you've made with our APIs!

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: 0.1.0
  • Package version: 1.0.0
  • Generator version: 7.14.0-SNAPSHOT
  • Build package: org.openapitools.codegen.languages.GoClientCodegen For more information, please visit https://kagi.com/support

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/net/context

Put the package under your project folder and add the following in import:

import openapi "github.com/kagisearch/kagi-api-golang"

To use a proxy, set the environment variable HTTP_PROXY:

os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")

Configuration of Server URL

Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.

Select Server Configuration

For using other server than the one defined on index 0 set context value openapi.ContextServerIndex of type int.

ctx := context.WithValue(context.Background(), openapi.ContextServerIndex, 1)

Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value openapi.ContextServerVariables of type map[string]string.

ctx := context.WithValue(context.Background(), openapi.ContextServerVariables, map[string]string{
	"basePath": "v2",
})

Note, enum values are always validated and all unused variables are silently ignored.

URLs Configuration per Operation

Each operation can use different server URL defined using OperationServers map in the Configuration. An operation is uniquely identified by "{classname}Service.{nickname}" string. Similar rules for overriding default operation server index and variables applies by using openapi.ContextOperationServerIndices and openapi.ContextOperationServerVariables context maps.

ctx := context.WithValue(context.Background(), openapi.ContextOperationServerIndices, map[string]int{
	"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), openapi.ContextOperationServerVariables, map[string]map[string]string{
	"{classname}Service.{nickname}": {
		"port": "8443",
	},
})

Documentation for API Endpoints

All URIs are relative to https://kagi.com/api/v1

Class Method HTTP request Description
EnrichmentAPI EnrichSearch Get /enrich/{type} Get enriched search results
FastGPTAPI FastGPT Post /fastgpt Answer a query.
SearchAPI Search Post /search Perform a search of the web.
SummarizerAPI SummarizeText Post /summarize Upload text to summarize.
SummarizerAPI SummarizeURL Get /summarize Get a summary for a URL
TranslateAPI Translate Post /api/translate Text Translation
TranslateAPI TranslateAlternatives Post /alternative-translations Alternative Translations
TranslateAPI TranslateDetect Post /api/detect Language Detection
TranslateAPI TranslateDictionary Post /api/dictionary Dictionary
TranslateAPI TranslateListLanguages Get /api/list-languages List Supported Languages
TranslateAPI TranslateRomanize Get /api/romanize Text Romanization
TranslateAPI TranslateWordInsights Post /api/word-insights Word Insights

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

kagi

  • Type: API key
  • API key parameter name: Authorization
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: kagi and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		openapi.ContextAPIKeys,
		map[string]openapi.APIKey{
			"kagi": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

kagi-translate

  • Type: HTTP Bearer token authentication

Example

auth := context.WithValue(context.Background(), openapi.ContextAccessToken, "BEARER_TOKEN_STRING")
r, err := client.Service.Operation(auth, args)

Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime

Author

[email protected]

About

OpenAPI generated golang client for interacting with the Kagi API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages