# Javascript

{% stepper %}
{% step %}

### Install the SDK

Using npm:

```bash
npm install @clustersxyz/sdk viem
```

Or yarn:

```bash
yarn add @clustersxyz/sdk viem
```

{% endstep %}

{% step %}

### Get an optional API Key

You can get an API Key by visiting <https://clusters.xyz/developer>
{% endstep %}

{% step %}

### Create your Clusters client

**Import**

```typescript
import { Clusters } from "@clustersxyz/sdk"

// 3 different examples
const clusters = new Clusters();

// with testnet enabled
const clusters = new Clusters({ isTestnet: true }) 

// with api key
const clusters = new Clusters({ apiKey: "abc123" });
```

{% endstep %}
{% endstepper %}

***

## Helper functions & variables

<table data-header-hidden><thead><tr><th width="250"></th><th></th></tr></thead><tbody><tr><td><code>validNameRegex</code></td><td>The regex for a valid cluster name</td></tr><tr><td><code>getImageUrl(name)</code></td><td>Get's the profile pfp url of a specific cluster name</td></tr><tr><td><code>getProfileUrl(name)</code></td><td>Get's the profile url of a cluster name</td></tr><tr><td><code>normalizeName(name)</code></td><td>Will clean up the name for onchain submission</td></tr><tr><td><code>isNameValid(name)</code></td><td>Checks if the name is a valid name and will be accepted on chain</td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.clusters.xyz/getting-started/javascript.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
