Skip to content

kagisearch/kagi-openapi-python

Repository files navigation

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.

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!

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

  • API version: v1 (Preview)
  • Package version: 1.0.0
  • Generator version: 7.22.0-SNAPSHOT
  • Build package: org.openapitools.codegen.languages.PythonClientCodegen For more information, please visit https://kagi.com/support

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":30,"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

support@kagi.com

About

OpenAPI generated python client for interacting with the Kagi API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors