Skip to content

Latest commit

 

History

History
190 lines (127 loc) · 6.92 KB

File metadata and controls

190 lines (127 loc) · 6.92 KB

openapi-client

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.

This Python package is automatically generated by the OpenAPI Generator project:

  • API version: 1
  • Package version: 1.0.0
  • Generator version: 7.22.0-SNAPSHOT
  • Build package: org.openapitools.codegen.languages.PythonClientCodegen

Requirements.

Python 3.10+

Installation & Usage

pip install

If the python package is hosted on a repository, you can install directly using:

pip install git+https://github.com/kagisearch/kagi-openapi-python.git

(you may need to run pip with root permission: sudo pip install git+https://github.com/kagisearch/kagi-openapi-python.git)

Then import the package:

import openapi_client

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

import openapi_client

Tests

Execute pytest to run the tests.

Getting Started

Please follow the installation procedure and then run the following:

import openapi_client
from openapi_client.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://kagi.com/api/v1
# See configuration.py for a list of all supported configuration parameters.
configuration = openapi_client.Configuration(
    host = "https://kagi.com/api/v1"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure Bearer authorization: kagi
configuration = openapi_client.Configuration(
    access_token = os.environ["BEARER_TOKEN"]
)


# Enter a context with an instance of the API client
with openapi_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = openapi_client.ExtractApi(api_client)
    extract_request = {"pages":[{"url":"https://example.com/article1"},{"url":"https://example.com/article2"}],"timeout":1.337,"format":"json"} # ExtractRequest | 

    try:
        # Extract page content as markdown from URLs
        api_response = api_instance.extract_content(extract_request)
        print("The response of ExtractApi->extract_content:\n")
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling ExtractApi->extract_content: %s\n" % e)

Documentation for API Endpoints

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

Class Method HTTP request Description
ExtractApi extract_content POST /extract Extract page content as markdown from URLs
SearchApi search POST /search Perform a web search

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

kagi

  • Type: Bearer authentication

Author

developers@kagi.com