# TryYourSize()

> Creates a client for one secret or restricted key.

Source: https://docs.tryyoursize.com/reference/python/client/

*Constructor* · `tryyoursize`

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

```python
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
```

## Parameters

- **`api_key`** (`str`, required): A secret key (`sk_test_…` / `sk_live_…`) or a restricted key (`rk_…`).
- **`api_version`** (`Optional[str]`, optional, default `None`): The `TYS-Version` to send (default: the version this release is built against, `API_VERSION`).
- **`base_url`** (`str`, optional, default `DEFAULT_BASE_URL`): API origin; change only for local development.
- **`max_retries`** (`int`, optional, default `2`): Retries of network errors, timeouts, 429, 5xx and `409 idempotency_key_in_use`.
- **`timeout`** (`float`, optional, default `30.0`): Per-attempt timeout in seconds.
- **`transport`** (`Optional[Transport]`, optional, default `None`): Replaces the HTTP call (tests).
- **`sleep`** (`Optional[Callable[[float], None]]`, optional, default `None`): Replaces the wait between retries (tests).

## Errors

`TryYourSizeError` for a missing key or a publishable key.

## Example

**Python**

```python

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

**Node.js**

```ts

const tys = new TryYourSize(process.env.TRYYOURSIZE_SECRET_KEY!, {
  maxRetries: 2,      // network errors, timeouts, 429, 5xx
  timeoutMs: 30_000,
});
```
