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

# getBlocksWithLimit

> 返回从给定插槽开始的已确认区块列表。

## 请求参数

<ParamField body="start_slot" type="number">
  开始从中检索连续区块列表的 Solana 插槽编号。
</ParamField>

<ParamField body="limit" type="number">
  要返回的最大连续区块数（每次请求最多 500,000 个区块）。
</ParamField>

<ParamField body="commitment" type="string">
  查询区块的最终级别 - 可以是已确认（乐观确认）或已完成（完全确认）。

  * `confirmed`
  * `finalized`
</ParamField>


## OpenAPI

````yaml zh/openapi/rpc-http/getBlocksWithLimit.yaml POST /
openapi: 3.1.0
info:
  title: Solana RPC API
  version: 1.0.0
  description: 区块链历史API，用于在指定范围内检索连续的Solana区块槽，具有可自定义的限制控制以优化数据量和查询性能。
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
servers:
  - url: https://mainnet.helius-rpc.com
    description: 主网RPC端点
  - url: https://devnet.helius-rpc.com
    description: 开发网RPC端点
security: []
paths:
  /:
    post:
      tags:
        - RPC
      summary: getBlocksWithLimit
      description: >-
        从特定的插槽开始检索一系列连续的Solana区块，并具有可自定义的限制。此区块链历史API返回请求范围内的已确认区块插槽编号数组，允许通过历史区块进行高效分页。受控的限制参数有助于在扫描区块链的大部分时管理响应大小和性能。对于区块链浏览器、历史数据分析工具、扫描交易历史的审计系统、索引服务、数据分析平台以及需要高效处理连续区块而不超出内存或网络限制的应用程序来说是必不可少的。每次请求最多可检索500,000个区块。
      operationId: getBlocksWithLimit
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - jsonrpc
                - id
                - method
                - params
              properties:
                jsonrpc:
                  type: string
                  description: JSON-RPC协议版本。
                  enum:
                    - '2.0'
                  example: '2.0'
                  default: '2.0'
                id:
                  type: string
                  description: 请求的唯一标识符。
                  example: '1'
                  default: '1'
                method:
                  type: string
                  description: 要调用的RPC方法名称。
                  enum:
                    - getBlocksWithLimit
                  example: getBlocksWithLimit
                  default: getBlocksWithLimit
                params:
                  type: array
                  description: 方法的请求参数。
                  default:
                    - 5
                    - 3
                  items:
                    type: object
                    properties:
                      start_slot:
                        type: integer
                        description: 开始检索连续区块列表的起始Solana插槽编号。
                        example: 5
                      limit:
                        type: integer
                        description: 要返回的最大连续区块数（每次请求最多500,000个区块）。
                        example: 3
                      commitment:
                        type: string
                        description: 查询区块的最终性级别 - 可以是已确认（乐观确认）或已完成（完全确认）。
                        enum:
                          - confirmed
                          - finalized
                        example: finalized
      responses:
        '200':
          description: 成功检索到已确认的区块。
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    type: string
                    description: JSON-RPC 协议版本。
                    enum:
                      - '2.0'
                    example: '2.0'
                  id:
                    type: string
                    description: 与请求匹配的标识符。
                    example: '1'
                  result:
                    type: array
                    description: 从请求的插槽开始按升序排列的已确认 Solana 区块插槽编号列表。
                    items:
                      type: integer
                    example:
                      - 5
                      - 6
                      - 7
        '400':
          description: 错误请求 - 请求参数无效或请求格式错误。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32602
                  message: Invalid params
                id: '1'
        '401':
          description: 未授权 - API 密钥无效或缺失。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32001
                  message: Unauthorized
                id: '1'
        '429':
          description: 请求过多 - 超出速率限制。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32005
                  message: 请求过多
                id: '1'
        '500':
          description: 内部服务器错误 - 服务器发生错误。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32603
                  message: 内部错误
                id: '1'
        '503':
          description: 服务不可用 - 服务暂时不可用。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32002
                  message: 服务不可用
                id: '1'
        '504':
          description: 网关超时 - 请求超时。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                jsonrpc: '2.0'
                error:
                  code: -32003
                  message: 网关超时
                id: '1'
      security:
        - ApiKeyQuery: []
components:
  schemas:
    ErrorResponse:
      type: object
      properties:
        jsonrpc:
          type: string
          description: JSON-RPC协议版本。
          enum:
            - '2.0'
          example: '2.0'
        error:
          type: object
          properties:
            code:
              type: integer
              description: 错误代码。
              example: -32602
            message:
              type: string
              description: 错误信息。
            data:
              type: object
              description: 关于错误的附加数据。
  securitySchemes:
    ApiKeyQuery:
      type: apiKey
      in: query
      name: api-key
      description: 您的Helius API密钥。您可以在[仪表板](https://dashboard.helius.dev/api-keys)中免费获取一个。

````