Python SDK

Install and start using the Python SDK.

Intro

The Clearwake console API SDK provides access to the Clearwake console API REST APIs.

The API that the Clearwake console (/console) calls. It lets a client run the buyer agent against its signed mandate, run one dispute case through the merchant agent, approve a held action, reconcile an uncertain refund, read the ledger and both signed receipt logs, and start a fresh run.

Every state-changing call needs the session cookie and the CSRF header from GET /console/api/session. The server accepts requests only from its own origin; a client outside the browser sets Origin to the server's own origin.

Source of truth: clearwake/server.py (routes) and clearwake/console.py (bodies and shapes). The data in a local run is local run data (label); the PayPal sandbox calls that sit behind the merchant agent are listed in the Postman collection postman/clearwake-paypal.postman_collection.json.

Try it live: the console at https://clearwake-console.onrender.com/console calls every operation below. The hosted service runs on a free plan and may need a few seconds to wake after a quiet hour; GET /healthz answers when it is awake.

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 ../clearwake-console-api — a bare folder name is looked up on PyPI instead, and resolves to whatever project holds that name there:

Terminal
pip install <path-to-sdk>
Terminal
uv add <path-to-sdk>
Terminal
poetry add <path-to-sdk>

Quick Start

Synchronous client

Construct ClearwakeConsoleApiClient with keyword arguments, and call close() when you are done. Every argument is optional.

Python
from clearwake_console_api import ClearwakeConsoleApiClient

client = ClearwakeConsoleApiClient(console_session="YOUR_API_KEY", csrf_token="YOUR_API_KEY", environment="production")

client.close()

Alternatively, scope it — with ClearwakeConsoleApiClient(...) as client: closes the pool on exit.

Asynchronous client

AsyncClearwakeConsoleApiClient mirrors ClearwakeConsoleApiClient 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.

Python
from asyncio import run

from clearwake_console_api import AsyncClearwakeConsoleApiClient


async def main() -> None:
    client = AsyncClearwakeConsoleApiClient(
        console_session="YOUR_API_KEY", csrf_token="YOUR_API_KEY", environment="production"
    )
    await client.aclose()


run(main())

Alternatively, scope it — async with AsyncClearwakeConsoleApiClient(...) as client: closes the pool on exit.

On this page