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

# Helius 速率限制

> Helius 各种计划和产品的速率限制完整指南。

## 什么是速率限制？

速率限制控制每秒可以进行的请求数量。当超过速率限制时，您将收到一个HTTP 429响应。关于当遇到429或其他临时故障时该怎么做的指导，请参见下文的[重试和错误处理](#retries-and-error-handling)。

## 标准速率限制

您的计划有两个标准速率限制组：一个用于 RPC 请求，另一个用于 DAS API 请求。以下是每个 Helius 计划的基本速率限制：

<table>
  <thead align="left">
    <tr>
      <th width="200">计划</th>
      <th width="260">RPC 速率限制</th>
      <th width="260">DAS 和增强 API</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td><strong>免费</strong></td>
      <td>10 请求/秒</td>
      <td>2 请求/秒</td>
    </tr>

    <tr>
      <td><strong>开发者</strong></td>
      <td>50 请求/秒</td>
      <td>10 请求/秒</td>
    </tr>

    <tr>
      <td><strong>商业</strong></td>
      <td>200 请求/秒</td>
      <td>50 请求/秒</td>
    </tr>

    <tr>
      <td><strong>专业</strong></td>
      <td>500 请求/秒</td>
      <td>100 请求/秒</td>
    </tr>

    <tr>
      <td><strong>企业</strong></td>
      <td>自定义</td>
      <td>自定义</td>
    </tr>
  </tbody>
</table>

### 增加速率限制

专业计划的团队可以每月支付 100 美元购买额外的 100 RPS。

如果您需要在发布前进行自定义速率限制，请[联系我们的销售团队](https://www.helius.dev/contact)。如果您使用的是开发者或商业层，请升级您的计划以增加速率限制。

## 特殊速率限制

由于计算要求，一些端点和专门的 Helius 产品有特殊的速率限制。

### 发送交易

<table>
  <thead align="left">
    <tr>
      <th width="200">端点</th>
      <th width="100">免费</th>
      <th width="100">开发者</th>
      <th width="100">商业</th>
      <th width="100">专业</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td><code>Sender</code></td>
      <td>50/秒</td>
      <td>50/秒</td>
      <td>50/秒</td>
      <td>50/秒</td>
    </tr>

    <tr>
      <td><code>sendTransaction</code></td>
      <td>1/秒</td>
      <td>5/秒</td>
      <td>50/秒</td>
      <td>100/秒</td>
    </tr>

    <tr>
      <td><code>sendBundle</code></td>
      <td>—</td>
      <td>—</td>
      <td>5/秒</td>
      <td>5/秒</td>
    </tr>

    <tr>
      <td><code>simulateBundle</code></td>
      <td>10/秒</td>
      <td>50/秒</td>
      <td>200/秒</td>
      <td>500/秒</td>
    </tr>
  </tbody>
</table>

如果您使用的是专业计划并需要增加您的 `sendTransaction` 速率限制，请[联系我们的销售团队](https://www.helius.dev/contact)。

专业计划用户还可以[申请](https://www.helius.dev/contact)增加速率限制和自定义 Sender 配置以支持更高吞吐量的交易应用。

### 复杂的 RPC 调用

<table>
  <thead align="left">
    <tr>
      <th width="200">端点</th>
      <th width="100">免费</th>
      <th width="100">开发者</th>
      <th width="100">商业</th>
      <th width="100">专业</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td><code>getProgramAccounts</code></td>
      <td>5/秒</td>
      <td>25/秒</td>
      <td>50/秒</td>
      <td>75/秒</td>
    </tr>
  </tbody>
</table>

### 历史数据

在对历史数据方法进行批量请求时，适用以下限制：

<table>
  <thead align="left">
    <tr>
      <th style={{width: '300px'}}>方法</th>
      <th style={{width: '300px'}}>最大批量大小</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td><code>getTransaction</code></td>
      <td>每个请求最多100个项目</td>
    </tr>

    <tr>
      <td><code>getTransactionsForAddress</code></td>
      <td>不允许批量请求</td>
    </tr>

    <tr>
      <td><code>getTransfersByAddress</code></td>
      <td>不允许批量请求</td>
    </tr>

    <tr>
      <td>所有其他历史方法</td>
      <td>每个请求10个项目</td>
    </tr>
  </tbody>
</table>

<Warning>
  超出批量限制将导致错误响应。对于 `getTransactionsForAddress` 和 `getTransfersByAddress`，每个地址必须在一个单独的请求中查询。
</Warning>

### LaserStream

<table>
  <thead align="left">
    <tr>
      <th width="200">资源</th>
      <th width="50">免费</th>
      <th width="100">开发者</th>
      <th width="100">商业</th>
      <th width="150">专业</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>网络</td>
      <td>—</td>
      <td>Devnet</td>
      <td>Devnet, Mainnet</td>
      <td>Devnet, Mainnet</td>
    </tr>

    <tr>
      <td>最大公钥数</td>
      <td>—</td>
      <td>10M</td>
      <td>10M</td>
      <td>10M</td>
    </tr>

    <tr>
      <td>活动连接数</td>
      <td>—</td>
      <td>—</td>
      <td>10</td>
      <td>100</td>
    </tr>
  </tbody>
</table>

### Wallet API

[Wallet API](/zh/api-reference/wallet-api)遵循与DAS和增强型API相同的速率限制。所有端点共享这些限制：

<table>
  <thead align="left">
    <tr>
      <th width="200">端点</th>
      <th width="100">免费</th>
      <th width="100">开发者</th>
      <th width="100">商业</th>
      <th width="100">专业</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>所有Wallet API端点</td>
      <td>2/秒</td>
      <td>10/秒</td>
      <td>50/秒</td>
      <td>100/秒</td>
    </tr>
  </tbody>
</table>

### LaserStream WebSocket

<table>
  <thead align="left">
    <tr>
      <th width="200">资源</th>
      <th width="100">免费</th>
      <th width="100">开发者</th>
      <th width="100">企业</th>
      <th width="100">专业</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>并发连接</td>
      <td>5</td>
      <td>150</td>
      <td>250</td>
      <td>1,000</td>
    </tr>

    <tr>
      <td>每个连接的订阅数</td>
      <td>1,000</td>
      <td>1,000</td>
      <td>1,000</td>
      <td>1,000</td>
    </tr>

    <tr>
      <td>WebSocket 类型</td>
      <td>标准</td>
      <td>标准，增强</td>
      <td>标准，增强</td>
      <td>标准，增强</td>
    </tr>
  </tbody>
</table>

### WebSockets

<table>
  <thead align="left">
    <tr>
      <th width="200">资源</th>
      <th width="100">免费</th>
      <th width="100">开发者</th>
      <th width="100">商业</th>
      <th width="100">专业</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>并发连接数</td>
      <td>5</td>
      <td>150</td>
      <td>250</td>
      <td>1,000</td>
    </tr>

    <tr>
      <td>每个连接的订阅数</td>
      <td>1,000</td>
      <td>1,000</td>
      <td>1,000</td>
      <td>1,000</td>
    </tr>

    <tr>
      <td>WebSocket 类型</td>
      <td>标准</td>
      <td>标准, 增强型</td>
      <td>标准, 增强型</td>
      <td>标准, 增强型</td>
    </tr>
  </tbody>
</table>

### Webhooks

<table>
  <thead align="left">
    <tr>
      <th width="200">资源</th>
      <th width="100">免费</th>
      <th width="100">开发者</th>
      <th width="100">企业</th>
      <th width="100">专业版</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>最大 Webhooks 数量</td>
      <td>5</td>
      <td>50</td>
      <td>50</td>
      <td>50</td>
    </tr>

    <tr>
      <td>每个 Webhook 的地址数</td>
      <td>100k</td>
      <td>100k</td>
      <td>100k</td>
      <td>100k</td>
    </tr>
  </tbody>
</table>

### ZK 压缩

<table>
  <thead align="left">
    <tr>
      <th width="200">服务</th>
      <th width="100">免费</th>
      <th width="100">开发者</th>
      <th width="100">企业</th>
      <th width="100">专业版</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>Photon APIs</td>
      <td>2/秒</td>
      <td>10/秒</td>
      <td>50/秒</td>
      <td>100/秒</td>
    </tr>

    <tr>
      <td><code>getValidityProof</code></td>
      <td>1/秒</td>
      <td>5/秒</td>
      <td>10/秒</td>
      <td>20/秒</td>
    </tr>
  </tbody>
</table>

## 重试和错误处理

当应用程序收到 `429 Too Many Requests`、`503 Service Unavailable` 或临时 `5xx` 响应时，请稍候并重试——不要立即重试。立即重试会增加请求数量，导致速率限制恢复变慢而非更快。

### 推荐策略

* 在第一次重试前等待约**1秒**。
* 每次重试时**加倍等待**，最长不超过**30秒**。
* 每次等待添加\*\*±25%\*\* 的小范围随机变化，以防多个应用程序同时重试。
* 在**5次尝试**后放弃，将错误返回给调用代码。

### 哪些错误需要重试

| 状态                         | 重试？ | 原因                 |
| -------------------------- | --- | ------------------ |
| `400`, `401`, `403`, `404` | 否   | 客户端错误——重试不会改变结果。   |
| `408`                      | 是   | 请求超时。              |
| `409`                      | 否   | 冲突——在调用方解决。        |
| `422`                      | 否   | 验证错误。              |
| `429`                      | 是   | 超出速率限制——等待并使用回退重试。 |
| `500`, `502`               | 是   | 临时服务器错误。           |
| `503`                      | 是   | 服务不可用——等待并使用回退重试。  |
| `504`                      | 是   | 网关超时。              |
| 网络错误                       | 是   | 连接重置、DNS故障或套接字超时。  |

### 示例

<CodeGroup>
  ```ts TypeScript theme={"system"}
  const RETRYABLE = new Set([408, 429, 500, 502, 503, 504]);

  export async function callWithRetry<T>(
    request: () => Promise<Response>,
    maxAttempts = 5,
  ): Promise<T> {
    let delay = 1000;
    for (let attempt = 1; attempt <= maxAttempts; attempt++) {
      const res = await request();
      if (res.ok) return (await res.json()) as T;

      if (!RETRYABLE.has(res.status) || attempt === maxAttempts) {
        throw new Error(`${res.status} after ${attempt} attempt(s): ${await res.text()}`);
      }

      const jitterMs = delay * (0.75 + Math.random() * 0.5);
      await new Promise((r) => setTimeout(r, jitterMs));
      delay = Math.min(delay * 2, 30_000);
    }
    throw new Error("unreachable");
  }
  ```

  ```python Python theme={"system"}
  import random
  import time

  RETRYABLE = {408, 429, 500, 502, 503, 504}

  def call_with_retry(request, max_attempts: int = 5):
      delay = 1.0
      for attempt in range(1, max_attempts + 1):
          response = request()
          if response.ok:
              return response.json()

          if response.status_code not in RETRYABLE or attempt == max_attempts:
              response.raise_for_status()

          time.sleep(delay * random.uniform(0.75, 1.25))
          delay = min(delay * 2, 30.0)
  ```

  ```bash Shell theme={"system"}
  call_with_retry() {
    local attempt=1 delay=1 body status
    while [ "$attempt" -le 5 ]; do
      response=$(curl -sS -w "\n%{http_code}" "$@")
      body=$(printf '%s\n' "$response" | sed '$d')
      status=$(printf '%s\n' "$response" | tail -n1)
      case "$status" in
        2*) printf '%s\n' "$body"; return 0 ;;
        408|429|500|502|503|504) ;;  # fall through and retry
        *) printf '%s\n' "$body" >&2; return 1 ;;
      esac
      # ~delay seconds with 25% jitter
      sleep "$(awk -v d="$delay" 'BEGIN { srand(); print d * (0.75 + rand() * 0.5) }')"
      delay=$(( delay * 2 > 30 ? 30 : delay * 2 ))
      attempt=$(( attempt + 1 ))
    done
    return 1
  }
  ```
</CodeGroup>

### 错误响应格式

所有 Helius API 在出错时返回结构化的 JSON 体。JSON-RPC 端点（Solana RPC、DAS、Sender、Priority Fee、ZK Compression）返回标准的 JSON-RPC 2.0 包：

```json theme={"system"}
{
  "jsonrpc": "2.0",
  "error": { "code": -32005, "message": "Too many requests" },
  "id": "1"
}
```

REST 端点（Wallet API、Admin API）返回：

```json theme={"system"}
{
  "error": "RATE_LIMIT_EXCEEDED",
  "code": 429,
  "details": "Too many requests. Retry after 2 seconds."
}
```
