Python SDK
Install and start using the Python SDK.
Intro
The eGain Knowledge API SDK provides access to the eGain Knowledge API REST APIs.
Search, retrieve and answer from the eGain AI Knowledge Hub, and manage knowledge portals, articles and content imports.
Installation
Add the SDK to your project from its folder, with whichever package manager your project uses. Give each tool a path containing a slash, such as ../e-gain-knowledge-api — a bare folder name is looked up on PyPI instead, and resolves to whatever project holds that name there:
pip install <path-to-sdk>uv add <path-to-sdk>poetry add <path-to-sdk>Quick Start
Synchronous client
Construct EGainKnowledgeApiClient with keyword arguments, and call close() when you are done. Every argument is optional.
from e_gain_knowledge_api import EGainKnowledgeApiClient
client = EGainKnowledgeApiClient(access_token="YOUR_BEARER_TOKEN")
client.close()Alternatively, scope it — with EGainKnowledgeApiClient(...) as client: closes the pool on exit.
Asynchronous client
AsyncEGainKnowledgeApiClient mirrors EGainKnowledgeApiClient with identical method names, and every endpoint method is a coroutine. It takes the same arguments, with some differences — for example, the transport argument is custom_async_http_client.
from asyncio import run
from e_gain_knowledge_api import AsyncEGainKnowledgeApiClient
async def main() -> None:
client = AsyncEGainKnowledgeApiClient(access_token="YOUR_BEARER_TOKEN")
await client.aclose()
run(main())Alternatively, scope it — async with AsyncEGainKnowledgeApiClient(...) as client: closes the pool on exit.

