# Get blocks by range

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

POST https://tron-mainnet.g.alchemy.com/v2/docs-demo/wallet/getblockbylimitnext

Retrieves blocks between the specified range of block numbers.

Reference: https://www.alchemy.com/docs/chains/tron/tron-http-api-endpoints/tron-http-api-endpoints/get-blocks-by-range

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://tron-mainnet.g.alchemy.com/v2/docs-demo/wallet/getblockbylimitnext \
  --header 'Content-Type: application/json' \
  --data '{
  "startNum": 1,
  "endNum": 5
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({startNum: 1, endNum: 5})
};

fetch('https://tron-mainnet.g.alchemy.com/v2/docs-demo/wallet/getblockbylimitnext', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://tron-mainnet.g.alchemy.com/v2/docs-demo/wallet/getblockbylimitnext"

payload = {
    "startNum": 1,
    "endNum": 5
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

### Go

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://tron-mainnet.g.alchemy.com/v2/docs-demo/wallet/getblockbylimitnext"

	payload := strings.NewReader("{\n  \"startNum\": 1,\n  \"endNum\": 5\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
```

### Java

```java
HttpResponse<String> response = Unirest.post("https://tron-mainnet.g.alchemy.com/v2/docs-demo/wallet/getblockbylimitnext")
  .header("Content-Type", "application/json")
  .body("{\n  \"startNum\": 1,\n  \"endNum\": 5\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://tron-mainnet.g.alchemy.com/v2/docs-demo/wallet/getblockbylimitnext");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddJsonBody("{\n  \"startNum\": 1,\n  \"endNum\": 5\n}", false);
var response = await client.PostAsync(request);

Console.WriteLine("{0}", response.Content);

```


## Operation Specification

```yaml
path: /wallet/getblockbylimitnext
method: POST
operation:
  summary: Get blocks by range
  description: Retrieves blocks between the specified range of block numbers.
  tags:
    - Tron HTTP API Endpoints
  requestBody:
    required: true
    content:
      application/json:
        schema:
          type: object
          properties:
            startNum:
              type: integer
              description: Starting block number (inclusive).
              example: 1
            endNum:
              type: integer
              description: Ending block number (exclusive).
              example: 5
          required:
            - startNum
            - endNum
  responses:
    '200':
      description: Successfully retrieved blocks.
      content:
        application/json:
          examples:
            response:
              value:
                block:
                  - blockID: 00000000000000010ff5414c5cfbe9eae982e8cef7eb2399a39118e1206c8247
                    block_header:
                      raw_data:
                        number: 1
                        txTrieRoot: 000...
                        witness_address: 415095d4f4...
                        parentHash: 000...
                        timestamp: 1529891469000
                      witness_signature: 4544a600...
                  - blockID: 0000000000000002018d6e36...
                    block_header:
                      raw_data:
                        number: 2
                        txTrieRoot: 000...
                        witness_address: 41df3bd4...
                        parentHash: 000...
                        timestamp: 1529891481000
                      witness_signature: 97686769...
```
