# 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.


---

# 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://predictbase.gitbook.io/docs/developer/get-api-key.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.
