{"id":39145825,"url":"https://github.com/gleanwork/api-client-python","last_synced_at":"2026-04-01T17:47:09.745Z","repository":{"id":291197481,"uuid":"971642383","full_name":"gleanwork/api-client-python","owner":"gleanwork","description":"The official Python library for the Glean API","archived":false,"fork":false,"pushed_at":"2026-03-28T02:25:50.000Z","size":7531,"stargazers_count":16,"open_issues_count":8,"forks_count":9,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-03-28T08:36:51.929Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gleanwork.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-04-23T20:46:17.000Z","updated_at":"2026-03-27T16:52:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"ab54be4b-4e37-4bfb-b543-0035c91c66d8","html_url":"https://github.com/gleanwork/api-client-python","commit_stats":null,"previous_names":["gleanwork/api-client-python"],"tags_count":69,"template":false,"template_full_name":null,"purl":"pkg:github/gleanwork/api-client-python","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gleanwork%2Fapi-client-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gleanwork%2Fapi-client-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gleanwork%2Fapi-client-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gleanwork%2Fapi-client-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gleanwork","download_url":"https://codeload.github.com/gleanwork/api-client-python/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gleanwork%2Fapi-client-python/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31290585,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T13:12:26.723Z","status":"ssl_error","status_checked_at":"2026-04-01T13:12:25.102Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-17T21:35:03.050Z","updated_at":"2026-04-01T17:47:09.738Z","avatar_url":"https://github.com/gleanwork.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Glean Python API Client\n\nThe Glean Python SDK provides convenient access to the Glean REST API from any Python 3.8+ application. It includes type hints for all request parameters and response fields, and supports both synchronous and asynchronous usage via [httpx](https://www.python-httpx.org/).\n\u003c!-- No Summary [summary] --\u003e\n\n## Unified SDK Architecture\n\nThis SDK combines both the Client and Indexing API namespaces into a single unified package:\n\n- **Client API**: Used for search, retrieval, and end-user interactions with Glean content\n- **Indexing API**: Used for indexing content, permissions, and other administrative operations\n\nEach namespace has its own authentication requirements and access patterns. While they serve different purposes, having them in a single SDK provides a consistent developer experience across all Glean API interactions.\n\n```python\n# Example of accessing Client namespace\nfrom glean.api_client import Glean\nimport os\n\nwith Glean(api_token=\"client-token\", server_url=\"https://mycompany-be.glean.com\") as glean:\n    search_response = glean.client.search.query(query=\"search term\")\n\n    print(search_response)\n\n# Example of accessing Indexing namespace \nfrom glean.api_client import Glean, models\nimport os\n\nwith Glean(api_token=\"indexing-token\", server_url=\"https://mycompany-be.glean.com\") as glean:\n    document_response = glean.indexing.documents.index(\n        document=models.Document(\n            id=\"doc-123\",\n            title=\"Sample Document\",\n            container_id=\"container-456\",\n            datasource=\"confluence\"\n        )\n    )\n```\n\nRemember that each namespace requires its own authentication token type as described in the [Authentication Methods](#authentication-methods) section.\n\n\u003c!-- Start Table of Contents [toc] --\u003e\n## Table of Contents\n\u003c!-- $toc-max-depth=2 --\u003e\n* [Glean Python API Client](#glean-python-api-client)\n  * [Unified SDK Architecture](#unified-sdk-architecture)\n  * [SDK Installation](#sdk-installation)\n  * [IDE Support](#ide-support)\n  * [SDK Example Usage](#sdk-example-usage)\n  * [Authentication](#authentication)\n  * [Available Resources and Operations](#available-resources-and-operations)\n  * [File uploads](#file-uploads)\n  * [Retries](#retries)\n  * [Error Handling](#error-handling)\n  * [Server Selection](#server-selection)\n  * [Custom HTTP Client](#custom-http-client)\n  * [Resource Management](#resource-management)\n  * [Debugging](#debugging)\n  * [Experimental Features and Deprecation Testing](#experimental-features-and-deprecation-testing)\n* [Development](#development)\n  * [Maturity](#maturity)\n  * [Contributions](#contributions)\n\n\u003c!-- End Table of Contents [toc] --\u003e\n\n## SDK Installation\n\n\u003e [!NOTE]\n\u003e **Python version upgrade policy**\n\u003e\n\u003e Once a Python version reaches its [official end of life date](https://devguide.python.org/versions/), a 3-month grace period is provided for users to upgrade. Following this grace period, the minimum python version supported in the SDK will be updated.\n\nThe SDK can be installed with either *pip* or *poetry* package managers.\n\n### PIP\n\n*PIP* is the default package installer for Python, enabling easy installation and management of packages from PyPI via the command line.\n\n```bash\npip install glean-api-client\n```\n\n### Poetry\n\n*Poetry* is a modern tool that simplifies dependency management and package publishing by using a single `pyproject.toml` file to handle project metadata and dependencies.\n\n```bash\npoetry add glean-api-client\n```\n\n### Shell and script usage with `uv`\n\nYou can use this SDK in a Python shell with [uv](https://docs.astral.sh/uv/) and the `uvx` command that comes with it like so:\n\n```shell\nuvx --from glean-api-client python\n```\n\nIt's also possible to write a standalone Python script without needing to set up a whole project like so:\n\n```python\n#!/usr/bin/env -S uv run --script\n# /// script\n# requires-python = \"\u003e=3.9\"\n# dependencies = [\n#     \"glean-api-client\",\n# ]\n# ///\n\nfrom glean.api_client import Glean\n\nsdk = Glean(\n  # SDK arguments\n)\n\n# Rest of script here...\n```\n\nOnce that is saved to a file, you can run it with `uv run script.py` where\n`script.py` can be replaced with the actual file name.\n\u003c!-- No SDK Installation [installation] --\u003e\n\n\u003c!-- Start IDE Support [idesupport] --\u003e\n## IDE Support\n\n### PyCharm\n\nGenerally, the SDK will work well with most IDEs out of the box. However, when using PyCharm, you can enjoy much better integration with Pydantic by installing an additional plugin.\n\n- [PyCharm Pydantic Plugin](https://docs.pydantic.dev/latest/integrations/pycharm/)\n\u003c!-- End IDE Support [idesupport] --\u003e\n\n\u003c!-- Start SDK Example Usage [usage] --\u003e\n## SDK Example Usage\n\n### Example 1\n\n```python\n# Synchronous Example\nfrom glean.api_client import Glean, models\nimport os\n\n\nwith Glean(\n    api_token=os.getenv(\"GLEAN_API_TOKEN\", \"\"),\n) as glean:\n\n    res = glean.client.chat.create(messages=[\n        {\n            \"fragments\": [\n                models.ChatMessageFragment(\n                    text=\"What are the company holidays this year?\",\n                ),\n            ],\n        },\n    ], timeout_millis=30000)\n\n    # Handle response\n    print(res)\n```\n\n\u003c/br\u003e\n\nThe same SDK client can also be used to make asynchronous requests by importing asyncio.\n\n```python\n# Asynchronous Example\nimport asyncio\nfrom glean.api_client import Glean, models\nimport os\n\nasync def main():\n\n    async with Glean(\n        api_token=os.getenv(\"GLEAN_API_TOKEN\", \"\"),\n    ) as glean:\n\n        res = await glean.client.chat.create_async(messages=[\n            {\n                \"fragments\": [\n                    models.ChatMessageFragment(\n                        text=\"What are the company holidays this year?\",\n                    ),\n                ],\n            },\n        ], timeout_millis=30000)\n\n        # Handle response\n        print(res)\n\nasyncio.run(main())\n```\n\n### Example 2\n\n```python\n# Synchronous Example\nfrom glean.api_client import Glean, models\nimport os\n\n\nwith Glean(\n    api_token=os.getenv(\"GLEAN_API_TOKEN\", \"\"),\n) as glean:\n\n    res = glean.client.chat.create_stream(messages=[\n        {\n            \"fragments\": [\n                models.ChatMessageFragment(\n                    text=\"What are the company holidays this year?\",\n                ),\n            ],\n        },\n    ], timeout_millis=30000)\n\n    # Handle response\n    print(res)\n```\n\n\u003c/br\u003e\n\nThe same SDK client can also be used to make asynchronous requests by importing asyncio.\n\n```python\n# Asynchronous Example\nimport asyncio\nfrom glean.api_client import Glean, models\nimport os\n\nasync def main():\n\n    async with Glean(\n        api_token=os.getenv(\"GLEAN_API_TOKEN\", \"\"),\n    ) as glean:\n\n        res = await glean.client.chat.create_stream_async(messages=[\n            {\n                \"fragments\": [\n                    models.ChatMessageFragment(\n                        text=\"What are the company holidays this year?\",\n                    ),\n                ],\n            },\n        ], timeout_millis=30000)\n\n        # Handle response\n        print(res)\n\nasyncio.run(main())\n```\n\u003c!-- End SDK Example Usage [usage] --\u003e\n\n\u003c!-- Start Authentication [security] --\u003e\n## Authentication\n\n### Per-Client Security Schemes\n\nThis SDK supports the following security scheme globally:\n\n| Name        | Type | Scheme      | Environment Variable |\n| ----------- | ---- | ----------- | -------------------- |\n| `api_token` | http | HTTP Bearer | `GLEAN_API_TOKEN`    |\n\nTo authenticate with the API the `api_token` parameter must be set when initializing the SDK client instance. For example:\n```python\nfrom glean.api_client import Glean, models\nfrom glean.api_client.utils import parse_datetime\nimport os\n\n\nwith Glean(\n    api_token=os.getenv(\"GLEAN_API_TOKEN\", \"\"),\n) as glean:\n\n    glean.client.activity.report(events=[\n        {\n            \"action\": models.ActivityEventAction.HISTORICAL_VIEW,\n            \"timestamp\": parse_datetime(\"2000-01-23T04:56:07.000Z\"),\n            \"url\": \"https://example.com/\",\n        },\n        {\n            \"action\": models.ActivityEventAction.SEARCH,\n            \"params\": {\n                \"query\": \"query\",\n            },\n            \"timestamp\": parse_datetime(\"2000-01-23T04:56:07.000Z\"),\n            \"url\": \"https://example.com/search?q=query\",\n        },\n        {\n            \"action\": models.ActivityEventAction.VIEW,\n            \"params\": {\n                \"duration\": 20,\n                \"referrer\": \"https://example.com/document\",\n            },\n            \"timestamp\": parse_datetime(\"2000-01-23T04:56:07.000Z\"),\n            \"url\": \"https://example.com/\",\n        },\n    ])\n\n    # Use the SDK ...\n\n```\n\u003c!-- End Authentication [security] --\u003e\n\n### Authentication Methods\n\nGlean supports different authentication methods depending on which API namespace you're using:\n\n#### Client Namespace\n\nThe Client namespace supports two authentication methods:\n\n1. **Manually Provisioned API Tokens**\n   - Can be created by an Admin or a user with the API Token Creator role\n   - Used for server-to-server integrations\n\n2. **OAuth**\n   - Requires OAuth setup to be completed by an Admin\n   - Used for user-based authentication flows\n\n#### Indexing Namespace\n\nThe Indexing namespace supports only one authentication method:\n\n1. **Manually Provisioned API Tokens**\n   - Can be created by an Admin or a user with the API Token Creator role\n   - Used for secure document indexing operations\n\n\u003e [!IMPORTANT]\n\u003e Client tokens **will not work** for Indexing operations, and Indexing tokens **will not work** for Client operations. You must use the appropriate token type for the namespace you're accessing.\n\nFor more information on obtaining the appropriate token type, please contact your Glean administrator.\n\n\u003c!-- Start Available Resources and Operations [operations] --\u003e\n## Available Resources and Operations\n\n\u003cdetails open\u003e\n\u003csummary\u003eAvailable methods\u003c/summary\u003e\n\n### [Authentication](docs/sdks/authentication/README.md)\n\n* [checkdatasourceauth](docs/sdks/authentication/README.md#checkdatasourceauth) - Check datasource authorization\n\n### [Client.Activity](docs/sdks/clientactivity/README.md)\n\n* [report](docs/sdks/clientactivity/README.md#report) - Report document activity\n* [feedback](docs/sdks/clientactivity/README.md#feedback) - Report client activity\n\n### [Client.Agents](docs/sdks/agents/README.md)\n\n* [retrieve](docs/sdks/agents/README.md#retrieve) - Retrieve an agent\n* [retrieve_schemas](docs/sdks/agents/README.md#retrieve_schemas) - List an agent's schemas\n* [list](docs/sdks/agents/README.md#list) - Search agents\n* [run_stream](docs/sdks/agents/README.md#run_stream) - Create an agent run and stream the response\n* [run](docs/sdks/agents/README.md#run) - Create an agent run and wait for the response\n\n### [Client.Announcements](docs/sdks/announcements/README.md)\n\n* [create](docs/sdks/announcements/README.md#create) - Create Announcement\n* [delete](docs/sdks/announcements/README.md#delete) - Delete Announcement\n* [update](docs/sdks/announcements/README.md#update) - Update Announcement\n\n### [Client.Answers](docs/sdks/answers/README.md)\n\n* [create](docs/sdks/answers/README.md#create) - Create Answer\n* [delete](docs/sdks/answers/README.md#delete) - Delete Answer\n* [update](docs/sdks/answers/README.md#update) - Update Answer\n* [retrieve](docs/sdks/answers/README.md#retrieve) - Read Answer\n* [~~list~~](docs/sdks/answers/README.md#list) - List Answers :warning: **Deprecated**\n\n### [Client.Authentication](docs/sdks/clientauthentication/README.md)\n\n* [create_token](docs/sdks/clientauthentication/README.md#create_token) - Create authentication token\n\n### [Client.Chat](docs/sdks/clientchat/README.md)\n\n* [create](docs/sdks/clientchat/README.md#create) - Chat\n* [delete_all](docs/sdks/clientchat/README.md#delete_all) - Deletes all saved Chats owned by a user\n* [delete](docs/sdks/clientchat/README.md#delete) - Deletes saved Chats\n* [retrieve](docs/sdks/clientchat/README.md#retrieve) - Retrieves a Chat\n* [list](docs/sdks/clientchat/README.md#list) - Retrieves all saved Chats\n* [retrieve_application](docs/sdks/clientchat/README.md#retrieve_application) - Gets the metadata for a custom Chat application\n* [upload_files](docs/sdks/clientchat/README.md#upload_files) - Upload files for Chat\n* [retrieve_files](docs/sdks/clientchat/README.md#retrieve_files) - Get files uploaded by a user for Chat\n* [delete_files](docs/sdks/clientchat/README.md#delete_files) - Delete files uploaded by a user for chat\n* [create_stream](docs/sdks/clientchat/README.md#create_stream) - Chat\n\n### [Client.Collections](docs/sdks/collections/README.md)\n\n* [add_items](docs/sdks/collections/README.md#add_items) - Add Collection item\n* [create](docs/sdks/collections/README.md#create) - Create Collection\n* [delete](docs/sdks/collections/README.md#delete) - Delete Collection\n* [delete_item](docs/sdks/collections/README.md#delete_item) - Delete Collection item\n* [update](docs/sdks/collections/README.md#update) - Update Collection\n* [update_item](docs/sdks/collections/README.md#update_item) - Update Collection item\n* [retrieve](docs/sdks/collections/README.md#retrieve) - Read Collection\n* [list](docs/sdks/collections/README.md#list) - List Collections\n\n### [Client.Documents](docs/sdks/clientdocuments/README.md)\n\n* [retrieve_permissions](docs/sdks/clientdocuments/README.md#retrieve_permissions) - Read document permissions\n* [retrieve](docs/sdks/clientdocuments/README.md#retrieve) - Read documents\n* [retrieve_by_facets](docs/sdks/clientdocuments/README.md#retrieve_by_facets) - Read documents by facets\n* [summarize](docs/sdks/clientdocuments/README.md#summarize) - Summarize documents\n\n### [Client.Entities](docs/sdks/entities/README.md)\n\n* [list](docs/sdks/entities/README.md#list) - List entities\n* [read_people](docs/sdks/entities/README.md#read_people) - Read people\n\n### [Client.Governance.Data.Policies](docs/sdks/policies/README.md)\n\n* [retrieve](docs/sdks/policies/README.md#retrieve) - Gets specified policy\n* [update](docs/sdks/policies/README.md#update) - Updates an existing policy\n* [list](docs/sdks/policies/README.md#list) - Lists policies\n* [create](docs/sdks/policies/README.md#create) - Creates new policy\n* [download](docs/sdks/policies/README.md#download) - Downloads violations CSV for policy\n\n### [Client.Governance.Data.Reports](docs/sdks/reports/README.md)\n\n* [create](docs/sdks/reports/README.md#create) - Creates new one-time report\n* [download](docs/sdks/reports/README.md#download) - Downloads violations CSV for report\n* [status](docs/sdks/reports/README.md#status) - Fetches report run status\n\n### [Client.Governance.Documents.Visibilityoverrides](docs/sdks/visibilityoverrides/README.md)\n\n* [list](docs/sdks/visibilityoverrides/README.md#list) - Fetches documents visibility\n* [create](docs/sdks/visibilityoverrides/README.md#create) - Hide or unhide docs\n\n### [Client.Insights](docs/sdks/insights/README.md)\n\n* [retrieve](docs/sdks/insights/README.md#retrieve) - Get insights\n\n### [Client.Messages](docs/sdks/messages/README.md)\n\n* [retrieve](docs/sdks/messages/README.md#retrieve) - Read messages\n\n### [Client.Pins](docs/sdks/pins/README.md)\n\n* [update](docs/sdks/pins/README.md#update) - Update pin\n* [retrieve](docs/sdks/pins/README.md#retrieve) - Read pin\n* [list](docs/sdks/pins/README.md#list) - List pins\n* [create](docs/sdks/pins/README.md#create) - Create pin\n* [remove](docs/sdks/pins/README.md#remove) - Delete pin\n\n### [Client.Search](docs/sdks/search/README.md)\n\n* [query_as_admin](docs/sdks/search/README.md#query_as_admin) - Search the index (admin)\n* [autocomplete](docs/sdks/search/README.md#autocomplete) - Autocomplete\n* [retrieve_feed](docs/sdks/search/README.md#retrieve_feed) - Feed of documents and events\n* [recommendations](docs/sdks/search/README.md#recommendations) - Recommend documents\n* [query](docs/sdks/search/README.md#query) - Search\n\n### [Client.Shortcuts](docs/sdks/clientshortcuts/README.md)\n\n* [create](docs/sdks/clientshortcuts/README.md#create) - Create shortcut\n* [delete](docs/sdks/clientshortcuts/README.md#delete) - Delete shortcut\n* [retrieve](docs/sdks/clientshortcuts/README.md#retrieve) - Read shortcut\n* [list](docs/sdks/clientshortcuts/README.md#list) - List shortcuts\n* [update](docs/sdks/clientshortcuts/README.md#update) - Update shortcut\n\n### [Client.Tools](docs/sdks/tools/README.md)\n\n* [list](docs/sdks/tools/README.md#list) - List available tools\n* [run](docs/sdks/tools/README.md#run) - Execute the specified tool\n\n### [Client.Verification](docs/sdks/clientverification/README.md)\n\n* [add_reminder](docs/sdks/clientverification/README.md#add_reminder) - Create verification\n* [list](docs/sdks/clientverification/README.md#list) - List verifications\n* [verify](docs/sdks/clientverification/README.md#verify) - Update verification\n\n### [Datasources](docs/sdks/datasources/README.md)\n\n* [get_datasource_instance_configuration](docs/sdks/datasources/README.md#get_datasource_instance_configuration) - Get datasource instance configuration\n* [update_datasource_instance_configuration](docs/sdks/datasources/README.md#update_datasource_instance_configuration) - Update datasource instance configuration\n\n### [Governance](docs/sdks/governance/README.md)\n\n* [createfindingsexport](docs/sdks/governance/README.md#createfindingsexport) - Creates findings export\n* [listfindingsexports](docs/sdks/governance/README.md#listfindingsexports) - Lists findings exports\n* [downloadfindingsexport](docs/sdks/governance/README.md#downloadfindingsexport) - Downloads findings export\n* [deletefindingsexport](docs/sdks/governance/README.md#deletefindingsexport) - Deletes findings export\n\n### [Indexing.Authentication](docs/sdks/indexingauthentication/README.md)\n\n* [rotate_token](docs/sdks/indexingauthentication/README.md#rotate_token) - Rotate token\n\n### [Indexing.Datasource](docs/sdks/indexingdatasource/README.md)\n\n* [status](docs/sdks/indexingdatasource/README.md#status) - Beta: Get datasource status\n\n\n### [Indexing.Datasources](docs/sdks/indexingdatasources/README.md)\n\n* [add](docs/sdks/indexingdatasources/README.md#add) - Add or update datasource\n* [retrieve_config](docs/sdks/indexingdatasources/README.md#retrieve_config) - Get datasource config\n\n### [Indexing.Documents](docs/sdks/indexingdocuments/README.md)\n\n* [add_or_update](docs/sdks/indexingdocuments/README.md#add_or_update) - Index document\n* [index](docs/sdks/indexingdocuments/README.md#index) - Index documents\n* [bulk_index](docs/sdks/indexingdocuments/README.md#bulk_index) - Bulk index documents\n* [process_all](docs/sdks/indexingdocuments/README.md#process_all) - Schedules the processing of uploaded documents\n* [delete](docs/sdks/indexingdocuments/README.md#delete) - Delete document\n* [debug](docs/sdks/indexingdocuments/README.md#debug) - Beta: Get document information\n\n* [debug_many](docs/sdks/indexingdocuments/README.md#debug_many) - Beta: Get information of a batch of documents\n\n* [check_access](docs/sdks/indexingdocuments/README.md#check_access) - Check document access\n* [~~status~~](docs/sdks/indexingdocuments/README.md#status) - Get document upload and indexing status :warning: **Deprecated**\n* [~~count~~](docs/sdks/indexingdocuments/README.md#count) - Get document count :warning: **Deprecated**\n\n### [Indexing.People](docs/sdks/people/README.md)\n\n* [debug](docs/sdks/people/README.md#debug) - Beta: Get user information\n\n* [~~count~~](docs/sdks/people/README.md#count) - Get user count :warning: **Deprecated**\n* [index](docs/sdks/people/README.md#index) - Index employee\n* [~~bulk_index~~](docs/sdks/people/README.md#bulk_index) - Bulk index employees :warning: **Deprecated**\n* [process_all_employees_and_teams](docs/sdks/people/README.md#process_all_employees_and_teams) - Schedules the processing of uploaded employees and teams\n* [delete](docs/sdks/people/README.md#delete) - Delete employee\n* [index_team](docs/sdks/people/README.md#index_team) - Index team\n* [delete_team](docs/sdks/people/README.md#delete_team) - Delete team\n* [bulk_index_teams](docs/sdks/people/README.md#bulk_index_teams) - Bulk index teams\n\n### [Indexing.Permissions](docs/sdks/indexingpermissions/README.md)\n\n* [update_permissions](docs/sdks/indexingpermissions/README.md#update_permissions) - Update document permissions\n* [index_user](docs/sdks/indexingpermissions/README.md#index_user) - Index user\n* [bulk_index_users](docs/sdks/indexingpermissions/README.md#bulk_index_users) - Bulk index users\n* [index_group](docs/sdks/indexingpermissions/README.md#index_group) - Index group\n* [bulk_index_groups](docs/sdks/indexingpermissions/README.md#bulk_index_groups) - Bulk index groups\n* [index_membership](docs/sdks/indexingpermissions/README.md#index_membership) - Index membership\n* [bulk_index_memberships](docs/sdks/indexingpermissions/README.md#bulk_index_memberships) - Bulk index memberships for a group\n* [process_memberships](docs/sdks/indexingpermissions/README.md#process_memberships) - Schedules the processing of group memberships\n* [delete_user](docs/sdks/indexingpermissions/README.md#delete_user) - Delete user\n* [delete_group](docs/sdks/indexingpermissions/README.md#delete_group) - Delete group\n* [delete_membership](docs/sdks/indexingpermissions/README.md#delete_membership) - Delete membership\n* [authorize_beta_users](docs/sdks/indexingpermissions/README.md#authorize_beta_users) - Beta users\n\n### [Indexing.Shortcuts](docs/sdks/indexingshortcuts/README.md)\n\n* [bulk_index](docs/sdks/indexingshortcuts/README.md#bulk_index) - Bulk index external shortcuts\n* [upload](docs/sdks/indexingshortcuts/README.md#upload) - Upload shortcuts\n\n\u003c/details\u003e\n\u003c!-- End Available Resources and Operations [operations] --\u003e\n\n\u003c!-- Start File uploads [file-upload] --\u003e\n## File uploads\n\nCertain SDK methods accept file objects as part of a request body or multi-part request. It is possible and typically recommended to upload files as a stream rather than reading the entire contents into memory. This avoids excessive memory consumption and potentially crashing with out-of-memory errors when working with very large files. The following example demonstrates how to attach a file stream to a request.\n\n\u003e [!TIP]\n\u003e\n\u003e For endpoints that handle file uploads bytes arrays can also be used. However, using streams is recommended for large files.\n\u003e\n\n```python\nfrom glean.api_client import Glean\nimport os\n\n\nwith Glean(\n    api_token=os.getenv(\"GLEAN_API_TOKEN\", \"\"),\n) as glean:\n\n    res = glean.client.chat.upload_files(files=[])\n\n    # Handle response\n    print(res)\n\n```\n\u003c!-- End File uploads [file-upload] --\u003e\n\n\u003c!-- Start Retries [retries] --\u003e\n## Retries\n\nSome of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.\n\nTo change the default retry strategy for a single API call, simply provide a `RetryConfig` object to the call:\n```python\nfrom glean.api_client import Glean, models\nfrom glean.api_client.utils import BackoffStrategy, RetryConfig, parse_datetime\nimport os\n\n\nwith Glean(\n    api_token=os.getenv(\"GLEAN_API_TOKEN\", \"\"),\n) as glean:\n\n    glean.client.activity.report(events=[\n        {\n            \"action\": models.ActivityEventAction.HISTORICAL_VIEW,\n            \"timestamp\": parse_datetime(\"2000-01-23T04:56:07.000Z\"),\n            \"url\": \"https://example.com/\",\n        },\n        {\n            \"action\": models.ActivityEventAction.SEARCH,\n            \"params\": {\n                \"query\": \"query\",\n            },\n            \"timestamp\": parse_datetime(\"2000-01-23T04:56:07.000Z\"),\n            \"url\": \"https://example.com/search?q=query\",\n        },\n        {\n            \"action\": models.ActivityEventAction.VIEW,\n            \"params\": {\n                \"duration\": 20,\n                \"referrer\": \"https://example.com/document\",\n            },\n            \"timestamp\": parse_datetime(\"2000-01-23T04:56:07.000Z\"),\n            \"url\": \"https://example.com/\",\n        },\n    ],\n        RetryConfig(\"backoff\", BackoffStrategy(1, 50, 1.1, 100), False))\n\n    # Use the SDK ...\n\n```\n\nIf you'd like to override the default retry strategy for all operations that support retries, you can use the `retry_config` optional parameter when initializing the SDK:\n```python\nfrom glean.api_client import Glean, models\nfrom glean.api_client.utils import BackoffStrategy, RetryConfig, parse_datetime\nimport os\n\n\nwith Glean(\n    retry_config=RetryConfig(\"backoff\", BackoffStrategy(1, 50, 1.1, 100), False),\n    api_token=os.getenv(\"GLEAN_API_TOKEN\", \"\"),\n) as glean:\n\n    glean.client.activity.report(events=[\n        {\n            \"action\": models.ActivityEventAction.HISTORICAL_VIEW,\n            \"timestamp\": parse_datetime(\"2000-01-23T04:56:07.000Z\"),\n            \"url\": \"https://example.com/\",\n        },\n        {\n            \"action\": models.ActivityEventAction.SEARCH,\n            \"params\": {\n                \"query\": \"query\",\n            },\n            \"timestamp\": parse_datetime(\"2000-01-23T04:56:07.000Z\"),\n            \"url\": \"https://example.com/search?q=query\",\n        },\n        {\n            \"action\": models.ActivityEventAction.VIEW,\n            \"params\": {\n                \"duration\": 20,\n                \"referrer\": \"https://example.com/document\",\n            },\n            \"timestamp\": parse_datetime(\"2000-01-23T04:56:07.000Z\"),\n            \"url\": \"https://example.com/\",\n        },\n    ])\n\n    # Use the SDK ...\n\n```\n\u003c!-- End Retries [retries] --\u003e\n\n## Error Handling\n\nAll operations return a response object or raise an exception:\n\n| Status Code | Description             | Error Type             | Content Type     |\n| ----------- | ----------------------- | ---------------------- | ---------------- |\n| 400         | Invalid Request         | errors.GleanError      | \\*/\\*            |\n| 401         | Not Authorized          | errors.GleanError      | \\*/\\*            |\n| 403         | Permission Denied       | errors.GleanDataError  | application/json |\n| 408         | Request Timeout         | errors.GleanError      | \\*/\\*            |\n| 422         | Invalid Query           | errors.GleanDataError  | application/json |\n| 429         | Too Many Requests       | errors.GleanError      | \\*/\\*            |\n| 4XX         | Other Client Errors     | errors.GleanError      | \\*/\\*            |\n| 5XX         | Internal Server Errors  | errors.GleanError      | \\*/\\*            |\n\n\n### Example\n\n```python\nfrom glean.api_client import Glean, errors, models\nimport os\n\n\nwith Glean(\n    api_token=os.getenv(\"GLEAN_API_TOKEN\", \"\"),\n) as g_client:\n    try:\n        res = g_client.client.search.execute(search_request=models.SearchRequest(\n            tracking_token=\"trackingToken\",\n            page_size=10,\n            query=\"vacation policy\",\n            request_options=models.SearchRequestOptions(\n                facet_filters=[\n                    models.FacetFilter(\n                        field_name=\"type\",\n                        values=[\n                            models.FacetFilterValue(\n                                value=\"article\",\n                                relation_type=models.RelationType.EQUALS,\n                            ),\n                            models.FacetFilterValue(\n                                value=\"document\",\n                                relation_type=models.RelationType.EQUALS,\n                            ),\n                        ],\n                    ),\n                    models.FacetFilter(\n                        field_name=\"department\",\n                        values=[\n                            models.FacetFilterValue(\n                                value=\"engineering\",\n                                relation_type=models.RelationType.EQUALS,\n                            ),\n                        ],\n                    ),\n                ],\n                facet_bucket_size=246815,\n            ),\n        ))\n        \n        # Handle response\n        print(res)\n    except errors.GleanError as e:\n        print(e.message)\n        print(e.status_code)\n        print(e.raw_response)\n        print(e.body)\n     # If the server returned structured data\n    except errors.GleanDataError as e:\n        print(e.data)\n        print(e.data.errorMessage)\n```\n\nBy default, an API error will raise a errors.GleanError exception, which has the following properties:\n\n| Property             | Type             | Description           |\n|----------------------|------------------|-----------------------|\n| `error.status_code`  | *int*            | The HTTP status code  |\n| `error.message`      | *str*            | The error message     |\n| `error.raw_response` | *httpx.Response* | The raw HTTP response |\n| `error.body`         | *str*            | The response content  |\n\n\u003c!-- No Error Handling [errors] --\u003e\n\n\u003c!-- Start Server Selection [server] --\u003e\n## Server Selection\n\n### Server Variables\n\nThe default server `https://{instance}-be.glean.com` contains variables and is set to `https://instance-name-be.glean.com` by default. To override default values, the following parameters are available when initializing the SDK client instance:\n\n| Variable   | Parameter       | Default           | Description                                                                                            |\n| ---------- | --------------- | ----------------- | ------------------------------------------------------------------------------------------------------ |\n| `instance` | `instance: str` | `\"instance-name\"` | The instance name (typically the email domain without the TLD) that determines the deployment backend. |\n\n#### Example\n\n```python\nfrom glean.api_client import Glean, models\nfrom glean.api_client.utils import parse_datetime\nimport os\n\n\nwith Glean(\n    server_idx=0,\n    instance=\"instance-name\",\n    api_token=os.getenv(\"GLEAN_API_TOKEN\", \"\"),\n) as glean:\n\n    glean.client.activity.report(events=[\n        {\n            \"action\": models.ActivityEventAction.HISTORICAL_VIEW,\n            \"timestamp\": parse_datetime(\"2000-01-23T04:56:07.000Z\"),\n            \"url\": \"https://example.com/\",\n        },\n        {\n            \"action\": models.ActivityEventAction.SEARCH,\n            \"params\": {\n                \"query\": \"query\",\n            },\n            \"timestamp\": parse_datetime(\"2000-01-23T04:56:07.000Z\"),\n            \"url\": \"https://example.com/search?q=query\",\n        },\n        {\n            \"action\": models.ActivityEventAction.VIEW,\n            \"params\": {\n                \"duration\": 20,\n                \"referrer\": \"https://example.com/document\",\n            },\n            \"timestamp\": parse_datetime(\"2000-01-23T04:56:07.000Z\"),\n            \"url\": \"https://example.com/\",\n        },\n    ])\n\n    # Use the SDK ...\n\n```\n\n### Override Server URL Per-Client\n\nThe default server can be overridden globally by passing a URL to the `server_url: str` optional parameter when initializing the SDK client instance. For example:\n```python\nfrom glean.api_client import Glean, models\nfrom glean.api_client.utils import parse_datetime\nimport os\n\n\nwith Glean(\n    server_url=\"https://instance-name-be.glean.com\",\n    api_token=os.getenv(\"GLEAN_API_TOKEN\", \"\"),\n) as glean:\n\n    glean.client.activity.report(events=[\n        {\n            \"action\": models.ActivityEventAction.HISTORICAL_VIEW,\n            \"timestamp\": parse_datetime(\"2000-01-23T04:56:07.000Z\"),\n            \"url\": \"https://example.com/\",\n        },\n        {\n            \"action\": models.ActivityEventAction.SEARCH,\n            \"params\": {\n                \"query\": \"query\",\n            },\n            \"timestamp\": parse_datetime(\"2000-01-23T04:56:07.000Z\"),\n            \"url\": \"https://example.com/search?q=query\",\n        },\n        {\n            \"action\": models.ActivityEventAction.VIEW,\n            \"params\": {\n                \"duration\": 20,\n                \"referrer\": \"https://example.com/document\",\n            },\n            \"timestamp\": parse_datetime(\"2000-01-23T04:56:07.000Z\"),\n            \"url\": \"https://example.com/\",\n        },\n    ])\n\n    # Use the SDK ...\n\n```\n\u003c!-- End Server Selection [server] --\u003e\n\n\u003c!-- Start Custom HTTP Client [http-client] --\u003e\n## Custom HTTP Client\n\nThe Python SDK makes API calls using the [httpx](https://www.python-httpx.org/) HTTP library.  In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with your own HTTP client instance.\nDepending on whether you are using the sync or async version of the SDK, you can pass an instance of `HttpClient` or `AsyncHttpClient` respectively, which are Protocol's ensuring that the client has the necessary methods to make API calls.\nThis allows you to wrap the client with your own custom logic, such as adding custom headers, logging, or error handling, or you can just pass an instance of `httpx.Client` or `httpx.AsyncClient` directly.\n\nFor example, you could specify a header for every request that this sdk makes as follows:\n```python\nfrom glean.api_client import Glean\nimport httpx\n\nhttp_client = httpx.Client(headers={\"x-custom-header\": \"someValue\"})\ns = Glean(client=http_client)\n```\n\nor you could wrap the client with your own custom logic:\n```python\nfrom glean.api_client import Glean\nfrom glean.api_client.httpclient import AsyncHttpClient\nimport httpx\n\nclass CustomClient(AsyncHttpClient):\n    client: AsyncHttpClient\n\n    def __init__(self, client: AsyncHttpClient):\n        self.client = client\n\n    async def send(\n        self,\n        request: httpx.Request,\n        *,\n        stream: bool = False,\n        auth: Union[\n            httpx._types.AuthTypes, httpx._client.UseClientDefault, None\n        ] = httpx.USE_CLIENT_DEFAULT,\n        follow_redirects: Union[\n            bool, httpx._client.UseClientDefault\n        ] = httpx.USE_CLIENT_DEFAULT,\n    ) -\u003e httpx.Response:\n        request.headers[\"Client-Level-Header\"] = \"added by client\"\n\n        return await self.client.send(\n            request, stream=stream, auth=auth, follow_redirects=follow_redirects\n        )\n\n    def build_request(\n        self,\n        method: str,\n        url: httpx._types.URLTypes,\n        *,\n        content: Optional[httpx._types.RequestContent] = None,\n        data: Optional[httpx._types.RequestData] = None,\n        files: Optional[httpx._types.RequestFiles] = None,\n        json: Optional[Any] = None,\n        params: Optional[httpx._types.QueryParamTypes] = None,\n        headers: Optional[httpx._types.HeaderTypes] = None,\n        cookies: Optional[httpx._types.CookieTypes] = None,\n        timeout: Union[\n            httpx._types.TimeoutTypes, httpx._client.UseClientDefault\n        ] = httpx.USE_CLIENT_DEFAULT,\n        extensions: Optional[httpx._types.RequestExtensions] = None,\n    ) -\u003e httpx.Request:\n        return self.client.build_request(\n            method,\n            url,\n            content=content,\n            data=data,\n            files=files,\n            json=json,\n            params=params,\n            headers=headers,\n            cookies=cookies,\n            timeout=timeout,\n            extensions=extensions,\n        )\n\ns = Glean(async_client=CustomClient(httpx.AsyncClient()))\n```\n\u003c!-- End Custom HTTP Client [http-client] --\u003e\n\n\u003c!-- Start Resource Management [resource-management] --\u003e\n## Resource Management\n\nThe `Glean` class implements the context manager protocol and registers a finalizer function to close the underlying sync and async HTTPX clients it uses under the hood. This will close HTTP connections, release memory and free up other resources held by the SDK. In short-lived Python programs and notebooks that make a few SDK method calls, resource management may not be a concern. However, in longer-lived programs, it is beneficial to create a single SDK instance via a [context manager][context-manager] and reuse it across the application.\n\n[context-manager]: https://docs.python.org/3/reference/datamodel.html#context-managers\n\n```python\nfrom glean.api_client import Glean\nimport os\ndef main():\n\n    with Glean(\n        api_token=os.getenv(\"GLEAN_API_TOKEN\", \"\"),\n    ) as glean:\n        # Rest of application here...\n\n\n# Or when using async:\nasync def amain():\n\n    async with Glean(\n        api_token=os.getenv(\"GLEAN_API_TOKEN\", \"\"),\n    ) as glean:\n        # Rest of application here...\n```\n\u003c!-- End Resource Management [resource-management] --\u003e\n\n\u003c!-- Start Debugging [debug] --\u003e\n## Debugging\n\nYou can setup your SDK to emit debug logs for SDK requests and responses.\n\nYou can pass your own logger class directly into your SDK.\n```python\nfrom glean.api_client import Glean\nimport logging\n\nlogging.basicConfig(level=logging.DEBUG)\ns = Glean(debug_logger=logging.getLogger(\"glean.api_client\"))\n```\n\nYou can also enable a default debug logger by setting an environment variable `GLEAN_DEBUG` to true.\n\u003c!-- End Debugging [debug] --\u003e\n\n## Experimental Features and Deprecation Testing\n\nThe SDK provides options to test upcoming API changes before they become the default behavior. This is useful for:\n\n- **Testing experimental features** before they are generally available\n- **Preparing for deprecations** by excluding deprecated endpoints ahead of their removal\n\n### Configuration Options\n\nYou can configure these options either via environment variables or SDK constructor options:\n\n#### Using Environment Variables\n\n```python\nimport os\n\n# Set environment variables before initializing the SDK\nos.environ[\"X_GLEAN_EXCLUDE_DEPRECATED_AFTER\"] = \"2026-10-15\"\nos.environ[\"X_GLEAN_INCLUDE_EXPERIMENTAL\"] = \"true\"\n\nfrom glean.api_client import Glean\n\nglean = Glean(\n    api_token=os.environ.get(\"GLEAN_API_TOKEN\", \"\"),\n    server_url=\"https://mycompany-be.glean.com\",\n)\n```\n\n#### Using SDK Constructor Options\n\n```python\nimport os\n\nfrom glean.api_client import Glean\n\nglean = Glean(\n    api_token=os.environ.get(\"GLEAN_API_TOKEN\", \"\"),\n    server_url=\"https://mycompany-be.glean.com\",\n    exclude_deprecated_after=\"2026-10-15\",\n    include_experimental=True,\n)\n```\n\n### Option Reference\n\n| Option | Environment Variable | Type | Description |\n| ------ | -------------------- | ---- | ----------- |\n| `exclude_deprecated_after` | `X_GLEAN_EXCLUDE_DEPRECATED_AFTER` | `str` (date) | Exclude API endpoints that will be deprecated after this date (format: `YYYY-MM-DD`). Use this to test your integration against upcoming deprecations. |\n| `include_experimental` | `X_GLEAN_INCLUDE_EXPERIMENTAL` | `bool` | When `True`, enables experimental API features that are not yet generally available. Use this to preview and test new functionality. |\n\n\u003e [!NOTE]\n\u003e Environment variables take precedence over SDK constructor options when both are set.\n\n\u003e [!WARNING]\n\u003e Experimental features may change or be removed without notice. Do not rely on experimental features in production environments.\n\n\u003c!-- Placeholder for Future Speakeasy SDK Sections --\u003e\n\n# Development\n\n## Maturity\n\nThis SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage\nto a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally\nlooking for the latest version.\n\n## Contributions\n\nWhile we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. \nWe look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release. \n\n### SDK Created by [Speakeasy](https://www.speakeasy.com/?utm_source=glean\u0026utm_campaign=python)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgleanwork%2Fapi-client-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgleanwork%2Fapi-client-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgleanwork%2Fapi-client-python/lists"}