---
title: getBlocks
description: >-
  Returns confirmed block slots in the inclusive range starting at startSlot and
  ending at endSlot, if provided.
url: /docs/rpc/http/getblocks
type: reference
hideTableOfContents: true
---

Returns confirmed block slots in the inclusive range starting at `startSlot` and
ending at `endSlot`, if provided.

<Callout type="info" title="Source">
  [`get_blocks`](https://github.com/anza-xyz/agave/blob/v3.1.8/rpc/src/rpc.rs#L1404)
</Callout>

<APIMethod>

```jsonc !!request curl
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getBlocks",
  "params": [
    // !hover start slot
    377268280,
    // !hover end slot
    377268285,
    // !hover(1:3) config
    {
      // !hover commitment
      "commitment": "finalized"
    }
  ]
}
```

```ts !!request title="Kit"
import { createSolanaRpc } from "@solana/kit";

const rpc_url = "https://api.devnet.solana.com";
const rpc = createSolanaRpc(rpc_url);

// !hover start slot
let startSlot = BigInt(377268280);
// !hover end slot
let endSlot = BigInt(377268285);
let blocks = await rpc.getBlocks(startSlot, endSlot).send();

console.log("Blocks produced:", blocks);
```

```ts !!request title="web3.js"
import { Connection, clusterApiUrl } from "@solana/web3.js";

const connection = new Connection(clusterApiUrl("devnet"), "confirmed");

// !hover start slot
let startSlot = 377268280;
// !hover end slot
let endSlot = 377268285;
let blocks = await connection.getBlocks(startSlot, endSlot);

console.log("Blocks produced:", blocks);
```

```rs !!request title="Rust"
use anyhow::Result;
use solana_client::nonblocking::rpc_client::RpcClient;
use solana_commitment_config::CommitmentConfig;

#[tokio::main]
async fn main() -> Result<()> {
    let client = RpcClient::new_with_commitment(
        String::from("https://api.devnet.solana.com"),
        CommitmentConfig::confirmed(),
    );

    // !hover start slot
    let start_slot = 377268280;
    // !hover end slot
    let end_slot = 377268285;
    let blocks = client.get_blocks(start_slot, Some(end_slot)).await?;

    println!("Blocks produced: {:#?}", blocks);

    Ok(())
}
```

### !params

#### !! start slot

!type u64  
!required

Start slot

#### !! end slot

!type u64 | object  
!optional

Inclusive end slot. For backwards compatibility, this parameter position may
also be used for a configuration object.

- If this parameter is a number, it is the inclusive end slot and must be no
  more than 500,000 slots higher than `start slot`.
- If this parameter is an object, it has the same shape as `config` and the
  request omits `end slot`.

When this parameter is an object, it contains:

| Field            | Type     | Description                                                                                                    |
| ---------------- | -------- | -------------------------------------------------------------------------------------------------------------- |
| `commitment`     | `string` | Commitment level used to select which slot the node reads from for this request. `processed` is not supported. |
| `minContextSlot` | `number` | Minimum slot at which the request may be evaluated.                                                            |

#### !! config

!type object  
!optional

Configuration object. This parameter is only used when `end slot` is provided as
a number.

##### !! commitment

!type string  
!values confirmed finalized  
!default finalized

Solana RPC uses the following commitment levels:

| Value       | Description                                                                                                                                                                                                                                                                |
| ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `processed` | Return data from the highest slot this node has processed on the fork it currently considers best. This is the newest view, but it can still change if the cluster switches forks.                                                                                         |
| `confirmed` | Return data from the highest slot that at least two-thirds of active stake has directly voted to confirm. This is more stable than `processed`, but it is still a weaker guarantee than `finalized`.                                                                       |
| `finalized` | Return data from the highest slot that the cluster recognizes as finalized. In practice, this means the slot has reached maximum vote lockout in validators' vote towers and is recognized by at least two-thirds of active stake. This is the strongest commitment level. |

This method does not accept `processed`.

##### !! minContextSlot

!type number

The minimum slot that the request can be evaluated at.

```json title="Example"
{ "minContextSlot": 341197000 }
```

### !!result

```jsonc !response
{
  "jsonrpc": "2.0",
  // !hover result
  "result": [5, 6, 7, 8, 9, 10],
  "id": 1
}
```

!type array

An array of u64 integers listing confirmed blocks between `start_slot` and
either `end_slot` - if provided, or the highest slot available at the requested
commitment, inclusive. Max range allowed is 500,000 slots. If `end_slot` is
lower than `start_slot`, the result is an empty array.

</APIMethod>
