> ## Documentation Index
> Fetch the complete documentation index at: https://www.helius.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# accountSubscribe

> 指定されたアカウントの公開鍵のラマポートやデータが変更されたときに通知を受け取るためにアカウントを購読します。

## エンドポイント

メインネットとデブネットで以下のURLでWebSocketが利用可能です。

* **Mainnet** `wss://mainnet.helius-rpc.com/?api-key=<api-key>`
* **Devnet** `wss://devnet.helius-rpc.com/?api-key=<api-key>`

<Note>WebSocketは10分間の非アクティビティタイマーがあります。接続を維持するために、ヘルスチェックを実装し、毎分ピンを送信することを強くお勧めします。</Note>

## 認証

<ParamField query="api-key" type="string" required>
  Helius APIキーです。[ダッシュボード](https://dashboard.helius.dev/api-keys)で無料で入手できます。
</ParamField>

## ボディ

<ParamField body="params" type="array" required>
  <Expandable title="properties" defaultOpen>
    <ParamField body="pubkey" type="string" required>
      アカウントのPubkey（base-58エンコードされた文字列）。
    </ParamField>

    <ParamField body="encoding" type="string">
      アカウントデータのエンコード形式。`base58`、`base64`、`base64+zstd`、または`jsonParsed`を指定できます。

      * `base58`は遅いです
      * `jsonParsed`のエンコードは、より人間が読める明示的なアカウント状態データを返すためにプログラム固有の状態パーサーの使用を試みます
      * `jsonParsed`が要求され、パーサーが見つからなかった場合、フィールドはバイナリエンコードにフォールバックし、データフィールドが文字列型のときに検出可能です。
    </ParamField>

    <ParamField body="commitment" type="string">
      サブスクリプションのコミットメントレベルです。`finalized`、`confirmed`、または`processed`を指定できます。
    </ParamField>
  </Expandable>
</ParamField>

## レスポンス

<ResponseField name="result" type="integer">
  購読ID（購読解除に必要）
</ResponseField>

<RequestExample>
  ```json Request theme={"system"}
  {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "accountSubscribe",
    "params": [
      "CM78CPUeXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNH12",
      {
        "encoding": "jsonParsed",
        "commitment": "finalized"
      }
    ]
  }
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={"system"}
  {
    "jsonrpc": "2.0",
    "result": 23784,
    "id": 1
  }
  ```

  ```json Message (base58) theme={"system"}
  {
    "jsonrpc": "2.0",
    "method": "accountNotification",
    "params": {
      "result": {
        "context": {
          "slot": 5199307
        },
        "value": {
          "data": [
            "11116bv5nS2h3y12kD1yUKeMZvGcKLSjQgX6BeV7u1FrjeJcKfsHPXHRDEHrBesJhZyqnnq9qJeUuF7WHxiuLuL5twc38w2TXNLxnDbjmuR",
            "base58"
          ],
          "executable": false,
          "lamports": 33594,
          "owner": "11111111111111111111111111111111",
          "rentEpoch": 635,
          "space": 80
        }
      },
      "subscription": 23784
    }
  }
  ```

  ```json Message (jsonParsed) theme={"system"}
  {
    "jsonrpc": "2.0",
    "method": "accountNotification",
    "params": {
      "result": {
        "context": {
          "slot": 5199307
        },
        "value": {
          "data": {
            "program": "nonce",
            "parsed": {
              "type": "initialized",
              "info": {
                "authority": "Bbqg1M4YVVfbhEzwA9SpC9FhsaG83YMTYoR4a8oTDLX",
                "blockhash": "LUaQTmM7WbMRiATdMMHaRGakPtCkc2GHtH57STKXs6k",
                "feeCalculator": {
                  "lamportsPerSignature": 5000
                }
              }
            }
          },
          "executable": false,
          "lamports": 33594,
          "owner": "11111111111111111111111111111111",
          "rentEpoch": 635,
          "space": 80
        }
      },
      "subscription": 23784
    }
  }
  ```
</ResponseExample>
