TryYourSize()
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) -> NoneParameters
Section titled “Parameters”api_keystrRequiredA secret key (sk_test_… / sk_live_…) or a restricted key (rk_…).
api_versionOptional[str]Optional= NoneThe TYS-Version to send (default: the version this release is built against, API_VERSION).
base_urlstrOptional= DEFAULT_BASE_URLAPI origin; change only for local development.
max_retriesintOptional= 2Retries of network errors, timeouts, 429, 5xx and 409 idempotency_key_in_use.
timeoutfloatOptional= 30.0Per-attempt timeout in seconds.
transportOptional[Transport]Optional= NoneReplaces the HTTP call (tests).
sleepOptional[Callable[[float], None]]Optional= NoneReplaces the wait between retries (tests).
Errors
Section titled “Errors”TryYourSizeError for a missing key or a publishable key.
Example
Section titled “Example”import osimport tryyoursize
tys = tryyoursize.TryYourSize(os.environ["TRYYOURSIZE_SECRET_KEY"], max_retries=2, timeout=30.0)import TryYourSize from "@tryyoursize/node";
const tys = new TryYourSize(process.env.TRYYOURSIZE_SECRET_KEY!, { maxRetries: 2, // network errors, timeouts, 429, 5xx timeoutMs: 30_000,});Was this page helpful?
Thank you. We read every answer.