# Referral

> Your account's invite link: each person who joins NoClick through it, and starts using it, adds `reward_usd` to your balance. A user of your account has none of its own.

## Referral

```typescript
class Referral
```

Your account's invite link and what it has earned.

| Attribute | Type | Description |
| --- | --- | --- |
| `code` | `string` |  |
| `url` | `string` |  |
| `shareText` | `string` | What a friend reads, then the link. |
| `rewardUsd` | `number` | What each friend who starts using NoClick adds to your balance. |
| `joined` | `number` | How many joined through it. |
| `earned` | `number` | How many of them earned the reward, and what it came to. |
| `earnedUsd` | `number` |  |
| `joinedThrough` | `{ name: string | null; channel: string } | null` | Whose link your account joined through, if it did. |
| `canApplyUntil` | `Date | null` | Until when your account can still apply an invite code (a day after it joined, once); null once it can't. |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

### Referral.get

```typescript
static get(options?: { client?: NoClick }): Promise<Referral>
```

Your account's invite link, how many joined and earned through it, and whose link your account joined through.

Parameters:

- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: The link (`url`), the line to send it with (`share_text`) and what it has earned.

### Referral.apply

```typescript
static apply(code: string, options?: { client?: NoClick }): Promise<Referral>
```

Apply a friend's invite `code` (or their join link) to your account, as the person they invited: only within a
day of your account's creation, and once. An unknown code throws `NotFound`; a second one `Conflict`.

    await Referral.apply("ana-k3x9");

Parameters:

- `code` (`string`, required)
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: Your account's invite link, now naming whose link it joined through.
