# new TryYourSize()

> Creates a client for one secret or restricted key.

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

*Constructor* · `@tryyoursize/node`

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

```ts
constructor(apiKey: string, options: TryYourSizeOptions = {})
```

## Parameters

- **`apiKey`** (`string`, required): A secret key (`sk_test_…` / `sk_live_…`) or a restricted key (`rk_…`). Keep it in an environment variable.
- **`options`** (`TryYourSizeOptions`, optional, default `{}`)
  - **`apiVersion`** (`string | undefined`, optional): TYS-Version sent with every request (default: the version this SDK was built against).
  - **`maxRetries`** (`number | undefined`, optional): Retries of network errors, timeouts, 429, 5xx and 409 idempotency_key_in_use (default 2).
  - **`timeoutMs`** (`number | undefined`, optional): Per-attempt timeout in ms (default 30,000).
  - **`baseUrl`** (`string | undefined`, optional): API origin (default https://api.tryyoursize.com).
  - **`fetch`** (`typeof fetch | undefined`, optional): A fetch implementation (default: the global fetch of Node 18+).

## Errors

`TypeError` for a missing key, a publishable key, or no `fetch`.

## Example

**Node.js**

```ts

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

**Python**

```python

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