Clarity API SDK for Python
A Python SDK for connecting to the CTI API server, with structured logging included.
Installation
pip install clarity-api-sdk-python
Logging
Logging support is built with structlog.
Set the root logger by setting the environment variable LOG_LEVEL. Otherwise, the default root logging is set to INFO.
"""Example"""
import logging
from cti.logger import initialize_logger, get_logger, ExternalLoggerConfig
initialize_logger(
external_logger_configurations=[
ExternalLoggerConfig(name="urllib3"),
ExternalLoggerConfig(name="httpcore"),
ExternalLoggerConfig(name="httpx"),
ExternalLoggerConfig(name="httpx_auth"),
ExternalLoggerConfig(name="httpx_retries"),
],
handlers=[logging.FileHandler("app.log")]
)
logger_a = get_logger("logger_a")
logger_b = get_logger("logger_b", "WARNING")
# root_logger = logging.getLogger()
# root_logger.setLevel("DEBUG")
logger_a.info("This is info message from logger_a")
logger_a.critical("This is critical message from logger_a")
# Dynamically change the log level of logger_a to WARNING
print("\nChanging logger_a level to WARNING...\n")
logging.getLogger("logger_a").setLevel(logging.WARNING)
logger_a.info("This info message from logger_a should NOT be visible.")
logger_a.warning("This is a new warning message from logger_a.")
logger_b.info("This info message from logger_b should NOT be visible.")
logger_b.warning("This is warning message from logger_b")
# the value will be redacted
logger_b.info("password", extra={"aws_access_key_id", "AKIAIOSFODNN7EXAMPLE"})
Model
Pydantic models.
API
Singleton async client
import asyncio
from cti.api.session import initialize_async_client, close_async_client
async def main():
await initialize_async_client()
# ... your application logic ...
await close_async_client()
if __name__ == "__main__":
asyncio.run(main())
# In other modules
from cti.api.session import get_async_client
async def fetch_data():
client = get_async_client()
response = await client.get(...)
return response.json()
Metadata
Release files for clarity-api-sdk-python 0.4.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| clarity_api_sdk_python-0.4.4.tar.gz | 65.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| clarity_api_sdk_python-0.4.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 137.0 kB
Release files / clarity_api_sdk_python-0.4.4.tar.gz
| Download URL | clarity_api_sdk_python-0.4.4.tar.gz |
|---|---|
| Size | 65.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b76456e3b6bdc74e9be0cf989c4793e7f9b12082d9101e065906dcf1abd735a1
|
|
BLAKE2b-256 checksum How to use checksums |
c9c82c13d82f9383a006c422f784196bfb16aed859b3a356cff32f617cce8cb1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 15, 2026.
Transparency logRelease files / clarity_api_sdk_python-0.4.4-py3-none-any.whl
| Download URL | clarity_api_sdk_python-0.4.4-py3-none-any.whl |
|---|---|
| Size | 71.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ced5d3025de78240d41f566aa4e72a50a5733d39ef371e50dd52c61f03647bd5
|
|
BLAKE2b-256 checksum How to use checksums |
9c7d001ab5bc9320389ecb0681095915049e5321bb711ad611644c68b34b3776
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 15, 2026.
Transparency log