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

# HTTP RPC API

> 使用 JSON-RPC 2.0 与 Solana 节点交互

## 概述

OrbitFlare RPC 节点接受使用 JSON-RPC 2.0 规范的 HTTP 请求。此 API 允许您与 Solana 区块链交互，用于查询数据和提交交易。

## 请求格式

要发起 JSON-RPC 请求，请发送具有以下规格的 HTTP POST 请求：

* 端点：`https://fra.rpc.orbitflare.com?api_key=YOUR_LICENSE_KEY`
* 请求头：`Content-Type: application/json`
* 请求体：包含以下字段的 JSON 对象：

| 字段        | 类型            | 描述        |
| --------- | ------------- | --------- |
| `jsonrpc` | string        | 必须为 "2.0" |
| `id`      | string/number | 唯一请求标识符   |
| `method`  | string        | RPC 方法名称  |
| `params`  | array         | 方法参数数组    |

### 请求示例

```bash theme={null}
curl https://fra.rpc.orbitflare.com?api_key=YOUR_LICENSE_KEY -X POST -H "Content-Type: application/json" -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getBalance",
  "params": [
    "83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri"
  ]
}'
```

### 响应格式

响应将是包含以下内容的 JSON 对象：

| 字段        | 类型            | 描述        |
| --------- | ------------- | --------- |
| `jsonrpc` | string        | 始终为 "2.0" |
| `id`      | string/number | 与请求标识符匹配  |
| `result`  | varies        | 方法的结果数据   |
| `error`   | object        | 错误详情（如适用） |

## 确认级别

许多方法接受 `commitment` 参数来指定数据的确认程度：

* `processed`：最新区块（最快，未确认）
* `confirmed`：由超级多数确认（速度和最终性之间的平衡）
* `finalized`：由超级多数最终确认（最慢，完全确认）

带确认级别的示例：

```bash theme={null}
curl https://fra.rpc.orbitflare.com?api_key=YOUR_LICENSE_KEY -X POST -H "Content-Type: application/json" -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getBalance",
  "params": [
    "83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri",
    {"commitment": "finalized"}
  ]
}'
```

## 批量请求

您可以通过提供请求对象数组在单次 HTTP 调用中发送多个请求：

```bash theme={null}
curl https://fra.rpc.orbitflare.com?api_key=YOUR_LICENSE_KEY -X POST -H "Content-Type: application/json" -d '[
  {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getBalance",
    "params": ["83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri"]
  },
  {
    "jsonrpc": "2.0",
    "id": 2,
    "method": "getBlockHeight",
    "params": []
  }
]'
```

## 常见类型

| 类型        | 描述                        |
| --------- | ------------------------- |
| Pubkey    | Base-58 编码的公钥字符串          |
| Hash      | Base-58 编码的 SHA-256 哈希字符串 |
| Signature | Base-58 编码的 Ed25519 签名    |
| Slot      | 整数区块高度/slot 编号            |

## 健康检查

您可以通过 GET 请求检查节点健康状态：

```bash theme={null}
curl "https://fra.rpc.orbitflare.com/health?api_key=YOUR_LICENSE_KEY"
```

可能的响应：

* `ok`：节点健康且数据最新
* `behind { slots: number }`：节点落后 N 个 slot
* `error`：节点不健康

## 可用方法

<CardGroup>
  <Card title="账户和程序" icon="user">
    * getAccountInfo
    * getMultipleAccounts
    * getProgramAccounts
    * getMinimumBalanceForRentExemption
  </Card>

  <Card title="区块和 Slot" icon="cube">
    * getBlock
    * getBlocks
    * getBlockHeight
    * getSlot
    * getSlotLeader
  </Card>

  <Card title="交易" icon="arrow-right-arrow-left">
    * getTransaction
    * getSignatureStatuses
    * getSignaturesForAddress
    * sendTransaction
    * simulateTransaction
  </Card>

  <Card title="代币" icon="coins">
    * getTokenAccountBalance
    * getTokenAccountsByDelegate
    * getTokenAccountsByOwner
    * getTokenSupply
  </Card>
</CardGroup>

## 速率限制

速率限制因订阅套餐而异。有关每个套餐的精确 RPS 和 TPS 值，请参阅[身份验证与限制](/cn/authentication#rate-limits-by-plan)页面。

## 最佳实践

1. **使用适当的确认级别**
   * 界面更新使用 `processed`
   * 大多数操作使用 `confirmed`
   * 关键操作使用 `finalized`

2. **优化请求**
   * 尽可能使用批量请求
   * 实施适当的缓存
   * 选择合适的轮询间隔

3. **处理错误**
   * 实施适当的错误处理
   * 使用指数退避进行重试
   * 监控请求失败

## 另请参阅

<CardGroup cols={3}>
  <Card title="身份验证与限制" icon="key" href="/cn/authentication">
    API 密钥设置、端点格式、速率限制和连接限制。
  </Card>

  <Card title="错误代码" icon="triangle-exclamation" href="/cn/rpc/error-codes">
    HTTP 状态码、JSON-RPC 错误及其处理方式。
  </Card>

  <Card title="WebSocket API" icon="plug" href="/cn/rpc/websocket">
    账户、Slot、日志等的实时订阅。
  </Card>
</CardGroup>

## 支持

如需有关我们 RPC 服务的技术支持或问题咨询：

* 加入我们的 [Discord 社区](https://discord.gg/orbitflare)
* 查看我们的[状态页面](https://status.orbitflare.com)
* 联系我们的支持团队
