---
title: getBlocksWithLimit
description: >-
  Returns up to limit confirmed block slots, starting at startSlot.
url: /docs/rpc/http/getblockswithlimit
type: reference
hideTableOfContents: true
---

Returns up to `limit` confirmed block slots, starting at `startSlot`.

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

<APIMethod>

```jsonc !!request curl
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getBlocksWithLimit",
  "params": [
    // !hover start slot
    5,
    // !hover limit
    3,
    // !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 limit
let limit = 5;
let blocks = await rpc.getBlocksWithLimit(startSlot, limit).send();

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 limit
    let limit = 5;

    let blocks = client.get_blocks_with_limit(start_slot, limit).await?;

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

    Ok(())
}
```

### !params

#### !! start slot

!type u64  
!required

Start slot

#### !! limit

!type usize  
!required

Maximum number of blocks to return. Must not exceed `500000`.

#### !! config

!type object  
!optional

Configuration object

##### !! 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],
  "id": 1
}
```

!type array

An array of u64 integers listing confirmed blocks starting at `start_slot` for
up to `limit` blocks. If `limit` is `0`, the result is an empty array.

</APIMethod>
