TryYourSize()
Esta página aún no está disponible en tu idioma.
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_keystrObligatorioA secret key (sk_test_… / sk_live_…) or a restricted key (rk_…).
api_versionOptional[str]Opcional= NoneThe TYS-Version to send (default: the version this release is built against, API_VERSION).
base_urlstrOpcional= DEFAULT_BASE_URLAPI origin; change only for local development.
max_retriesintOpcional= 2Retries of network errors, timeouts, 429, 5xx and 409 idempotency_key_in_use.
timeoutfloatOpcional= 30.0Per-attempt timeout in seconds.
transportOptional[Transport]Opcional= NoneReplaces the HTTP call (tests).
sleepOptional[Callable[[float], None]]Opcional= 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,});¿Te ha resultado útil esta página?
Gracias. Leemos todas las respuestas.