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.

See our API Pricing page for standard rates.

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.

In the future we will most likely offer more crafted API wrappers and spotlight clients and applications built by our community - feel free to send them to us!

MCP

We offer a hosted MCP server at: https://mcp.kagi.com/mcp

At this time, we do not support setup via OAuth2 flow, but this is on our roadmap. You will need to get your API key from the dashboard and plug it into your local client with Bearer HTTP authentication.

Here is an example to get started with Claude Code:

claude mcp add kagi https://mcp.kagi.com/mcp --transport http --header "Authorization: Bearer $(read -sp 'API key: ' k; echo $k)" --scope user

You can review and contribute to our MCP server on GitHub!

Support

For bug reports, feature requests, or billing related issues please reach out to developers@kagi.com and we will be happy to assist you.

To help us answer your reports efficiently, please be prepared to provide as much info as you can:

  • For bugs, include request trace IDs from the meta.trace response field or the X-Kagi-Trace response header.
  • If issues are easily reproduced in our playground, send us a link to the playground - the URL will contain parameters to configure the request so that we can reproduce ourselves.
  • Include any code snippets or precise descriptions of the request you are making, and full samples of the response bodies from the API
  • Include mention of which wrapper you are using if any, or links to relevant application code we can review
  • Include the email address associated with your Kagi login if it is not the one you are emailing from

Thank you!

Discord

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

In the server you will find the #api forum for API related inquiries.

Download OpenAPI description
Overview
API Support

developers@kagi.com

License

Apache-2.0

Languages
Servers
Mock server

https://kagi.redocly.app/_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://kagi.redocly.app/_mock/openapi/search \
  -H 'Authorization: Bearer <YOUR_TOKEN_HERE>' \
  -H 'Content-Type: application/json' \
  -d '{
    "query": "steve jobs",
    "workflow": "search"
  }'

Responses

Success

Bodyapplication/json
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
application/json
{ "meta": { "trace": "97383064af92b8980b9b4d419b4ce4a9", "ms": 314, "node": "us-east4" }, "data": { "search": [], "adjacent_question": [], "video": [] } }

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