> For the complete documentation index, see [llms.txt](https://predictbase.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://predictbase.gitbook.io/docs/developer/get-api-key.md).

# Get API Key

### 🔑 Step 1: Get an API Key

To interact with PredictBase programmatically, you need an **API key**.\
Your API key is **wallet-bound** and authorizes actions on your behalf.

You can obtain an API key in **two ways**:

***

#### Option A: Get an API Key via PredictBase App (Recommended)

1. Visit [**https://predictbase.app**](https://predictbase.app)
2. Connect your wallet
3. Navigate to your profile in the top-right corner and click **Developer API Key**.
4. Generate an API key

<figure><img src="/files/roDEwbOps8ce94eTNl0U" alt=""><figcaption></figcaption></figure>

⚠️ Your API key is shown **only once**. Store it securely.

***

#### Option B: Get an API Key via API Endpoints

This method is useful for automated setups and bots.

**1️⃣ Request a nonce**

```http
GET /get-nonce?wallet=0xYourWalletAddress
```

**Full URL**

```
https://api.predictbase.app/get-nonce?wallet=0xYourWalletAddress
```

Response:

```json
{
  "message": "Sign this message to authorize PredictBase API access..."
}
```

**2️⃣ Sign the message with your wallet**

After requesting a nonce from the PredictBase API, you must **sign the returned message** using your wallet. This proves wallet ownership and authorizes API key creation.

**Example (using `viem`):**

```ts
const signature = await walletClient.signMessage({
  account: "0xYourWalletAddress",
  message, // message returned from /get-nonce
});
```

The resulting `signature` is then sent to the `create-api-key` endpoint.

**3️⃣ Create the API key**

```http
POST /create-api-key
```

**Full URL**

```
https://api.predictbase.app/create-api-key
```

Body:

```json
{
  "wallet": "0xYourWalletAddress",
  "signature": "0xSignedMessage",
  "message": "Signed message containing nonce"
}
```

Response:

```json
{
  "apiKey": "YOUR_API_KEY"
}
```

Use this API key in all requests via the `x-api-key` header.
