# getIdentity

The `getIdentity` RPC method returns the **public key (identity)** of the Solana RPC node you are connected to. Each node in the Solana network has a unique cryptographic keypair, and the public key serves as its **node identifier**.

***

#### ✅ Common Use Cases

* **Identify the RPC Node**\
  Retrieve the unique public key of the node serving your request—useful in distributed systems or when using multiple providers.
* **Cross-reference with Cluster Nodes**\
  Combine with `getClusterNodes` to match the identity to other metadata (e.g., gossip, TPU, version) from the full cluster view.
* **Logging and Debugging**\
  Track which RPC node handled a given request—ideal for diagnostics in multi-node environments.
* **Protocol-Level Verification (Advanced)**\
  Some advanced tooling may require node identity verification, though this is uncommon in general dApp workflows.

***

#### 🛠 Request Parameters

This method **does not take any parameters**.

***

#### 📦 Response Structure

The `result` field contains:

```json
{
  "jsonrpc": "2.0",
  "result": {
    "identity": "8Lx6...xKMN"
  },
  "id": 1
}
```

| Field      | Type     | Description                                                  |
| ---------- | -------- | ------------------------------------------------------------ |
| `identity` | *string* | Base-58 encoded public key of the node you are connected to. |

***

#### 💡 Example: Get RPC Node Identity

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getIdentity"
}
```

***

**Code Examples**

{% tabs %}
{% tab title="Nodejs" %}

```javascript
const fetch = require('node-fetch');

async function getIdentity(rpcUrl) {
  try {
    const response = await fetch(rpcUrl, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        jsonrpc: '2.0',
        id: 1,
        method: 'getIdentity'
      }),
    });

    const data = await response.json();
    
    // Print the exact full response
    console.log('Full RPC Response:');
    console.log(JSON.stringify(data, null, 2));
    
    return data;
  } catch (error) {
    console.error('Error getting health:', error.message);
    return null;
  }
}

// Example usage
const RPC_URL = 'https://rpc.coinvera.io/?x-api-key=your-coinvera-x-api-key';

getIdentity(RPC_URL);
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

def get_identity(rpc_url):
    try:
        response = requests.post(
            rpc_url,
            headers={
                'Content-Type': 'application/json',
            },
            json={
                'jsonrpc': '2.0',
                'id': 1,
                'method': 'getIdentity'
            }
        )
        
        data = response.json()
        
        # Print the exact full response
        print('Full RPC Response:')
        print(json.dumps(data, indent=2))
        
        return data
        
    except Exception as error:
        print(f'Error getting health: {error}')
        return None

# Example usage
RPC_URL = 'https://rpc.coinvera.io/?x-api-key=your-coinvera-x-api-key'
get_identity(RPC_URL)
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "jsonrpc": "2.0",
  "result": {
    "identity": "56vSo3VUVsCqiKow9J2ZY7RWnHg5qrBDEbrvbd1VMzRa"
  },
  "id": 1
}
```

***

#### 🧠 Developer Tips

* **Node-Specific Identity**\
  The returned identity is **unique to the specific RPC node** queried. Connecting to another RPC server (even within the same cluster or provider) may return a different identity.
* **Not Related to Wallets**\
  This identity is **not a user wallet or validator address**—it strictly identifies the node process itself.
* **Key Stability**\
  A node’s identity is generally stable, but may change if the operator regenerates or replaces the node’s keypair.
* **Use for Traceability**\
  Consider including the node’s identity in debug logs or telemetry to trace request origins in distributed setups.


---

# 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.coinvera.io/integration/solana/rpc/getidentity.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.
