Kagi API (1)

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

Get started on the API Dashboard to set up billing, manage API keys, and more.

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.

API Status

The v1 API is currently in preview to early access testers.

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

See our API Pricing page for standard rates.

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!

Download OpenAPI description
Languages
Servers
Mock server

https://redocly-api-docs.kagi.com/_mock/openapi/

Production api endpoint

https://kagi.com/api/v1/

Perform a web search

Request

Security
kagi
Bodyapplication/jsonrequired
querystringrequired

Search query to run.

workflowstring

Type of results to return.

Default "search"
Enum"search""images""videos""news""podcasts"
formatstring

(EXPERIMENTAL) Format to serialize the API response as. The exact contents and structure of markdown output is still being worked on - please send your feedback!

Default "json"
Enum"json""markdown"
lens_idstring

Lens to apply to the search. Can be a built-in lens's identifier or a lens ID as shown on https://kagi.com/settings/lenses when a lens is set to be shareable. Can be just the ID portion of the URL (https://kagi.com/lenses/ID) or the full URL.

lensobject

Inline description of a lens to apply to the search. Options supplied by the lens take precedence over those supplied by the user in their search terms (e.g., site: operators), allowing you to restrict the scope of the search to return more relevant results in specific applications.

timeoutnumber[ 0.5 .. 4 ]

Number of seconds to allow for collecting search results. Lower values will return results more quickly, but may be lower quality or inconsistent between calls. If omitted, will use the latest recommended value by Kagi.

pageinteger[ 1 .. 10 ]

Page number for paginated results. Must be between 1 and 10.

limitinteger[ 1 .. 1024 ]

Maximum number of results to return. Must be between 1 and 1024. NOTE: This does not change the amount of results requested, it only limits the maximum amount returned. If omitted, the API always gives you the most results we can get in a single pass.

filtersobject

Filters to apply to search results for more targeted queries.

NOTE: Any parameter here that overlaps with lenses will take priority over the lens.

extractobject

Configuration for extracting page content from search results. When provided, the API will fetch and extract the content from the specified number of result pages.

The resulting page markdown will update the value of the snippet field on the respective result item.

NOTE: Use of this option incurs additional cost, billed at your account's rate for the Extract API based on the number of units requested. You will not be charged if there were no results to extract.

safe_searchboolean

Whether safe search is enabled, omitting potentially NSFW content.

Default true
personalizationsobject

Personalization rules to customize search result ranking. Allows specifying domain biases and regex-based replacements.

curl -i -X POST \
  https://redocly-api-docs.kagi.com/_mock/openapi/search \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
  -H 'Content-Type: application/json' \
  -d '{
    "query": "steve jobs",
    "workflow": "search"
  }'

Responses

Success

Body
metaobject(meta)

This object is subject to change as it is provided for debugging purposes. Fields may be added or removed as required. Don't build any hard dependancies on any of this data.

dataobject

Holds all the search results for the query specified. As results have different types and sources, they are separated into different fields within this object. For example image results are stored under data.image while news results are stored under data.news. All results will have the same main structure, but additional data might be stored under the data.{name}[].props path. Please look at each different type of result for more information about this.

Response
{ "meta": { "trace": "69c3f5c4168f66b860e951c585550f1c", "node": "us-central1", "ms": 213, "query": {} }, "data": { "search": [], "video": [], "web_archive": [], "infobox": [], "adjacent_question": [] } }

Extract API

Extract contents from web pages, currently in markdown form. This endpoint accepts a list of URLs and returns the extracted markdown content for each page.

Operations