Skip to content

TryYourSize()

Constructortryyoursize

Creates a client for one secret or restricted key. Create it once and reuse it.

def __init__(api_key: str, *, api_version: Optional[str] = None, base_url: str = DEFAULT_BASE_URL, max_retries: int = 2, timeout: float = 30.0, transport: Optional[Transport] = None, sleep: Optional[Callable[[float], None]] = None) -> None
api_keystrRequired

A secret key (sk_test_… / sk_live_…) or a restricted key (rk_…).

api_versionOptional[str]Optional= None

The TYS-Version to send (default: the version this release is built against, API_VERSION).

base_urlstrOptional= DEFAULT_BASE_URL

API origin; change only for local development.

max_retriesintOptional= 2

Retries of network errors, timeouts, 429, 5xx and 409 idempotency_key_in_use.

timeoutfloatOptional= 30.0

Per-attempt timeout in seconds.

transportOptional[Transport]Optional= None

Replaces the HTTP call (tests).

sleepOptional[Callable[[float], None]]Optional= None

Replaces the wait between retries (tests).

TryYourSizeError for a missing key or a publishable key.

import os
import tryyoursize
tys = tryyoursize.TryYourSize(os.environ["TRYYOURSIZE_SECRET_KEY"], max_retries=2, timeout=30.0)

Was this page helpful?