# /v1/beacon/headers

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

GET https://eth-mainnetbeacon.g.alchemy.com/v2/docs-demo/eth/v1/beacon/headers

Retrieves block headers matching the given query.   By default, it will fetch the current head slot blocks.


Reference: https://www.alchemy.com/docs/chains/ethereum/ethereum-beacon-api-endpoints/ethereum-beacon-api-endpoints/v-1-beacon-headers

## Query Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| slot | string | No | Slot number. If provided, returns headers for this slot.  |
| parent_root | string | No | Parent root hash to filter block headers by.  |

## Code Examples

### cURL

```bash
curl --request GET \
  --url https://eth-mainnetbeacon.g.alchemy.com/v2/docs-demo/eth/v1/beacon/headers
```

### JavaScript

```javascript
const options = {method: 'GET'};

fetch('https://eth-mainnetbeacon.g.alchemy.com/v2/docs-demo/eth/v1/beacon/headers', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://eth-mainnetbeacon.g.alchemy.com/v2/docs-demo/eth/v1/beacon/headers"

response = requests.get(url)

print(response.text)
```

### Go

```go
package main

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

func main() {

	url := "https://eth-mainnetbeacon.g.alchemy.com/v2/docs-demo/eth/v1/beacon/headers"

	req, _ := http.NewRequest("GET", url, nil)

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

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

	fmt.Println(string(body))

}
```

### Java

```java
HttpResponse<String> response = Unirest.get("https://eth-mainnetbeacon.g.alchemy.com/v2/docs-demo/eth/v1/beacon/headers")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://eth-mainnetbeacon.g.alchemy.com/v2/docs-demo/eth/v1/beacon/headers");
var client = new RestClient(options);
var request = new RestRequest("");
var response = await client.GetAsync(request);

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

```


## Operation Specification

```yaml
path: /eth/v1/beacon/headers
method: GET
operation:
  summary: /v1/beacon/headers
  description: |
    Retrieves block headers matching the given query.   By default, it will fetch the current head slot blocks.
  tags:
    - Ethereum Beacon API Endpoints
  security:
    - apiKey: []
  parameters:
    - name: slot
      in: query
      required: false
      schema:
        type: string
        example: '12304896'
      description: |
        Slot number. If provided, returns headers for this slot.
    - name: parent_root
      in: query
      required: false
      schema:
        type: string
        format: hex
        example: '0x3590c9b1a918586a2dabde886abea7f26cfa3a11683be1ab73283e6af70733ba'
      description: |
        Parent root hash to filter block headers by.
  responses:
    '200':
      description: Successfully retrieved block headers.
      content:
        application/json:
          schema:
            type: object
            properties:
              execution_optimistic:
                type: boolean
                description: Whether the execution payload is optimistic.
              finalized:
                type: boolean
                description: Whether the block is finalized.
              data:
                type: array
                description: List of block headers.
                items:
                  type: object
                  properties:
                    root:
                      type: string
                      description: Root hash of the block.
                      example: '0x95656528b8dbed879305ffa67ed688f8e262b2dfa5f620e384056f49dec95267'
                    canonical:
                      type: boolean
                      description: Whether this header is canonical.
                      example: true
                    header:
                      type: object
                      properties:
                        message:
                          type: object
                          properties:
                            slot:
                              type: string
                              description: Slot number for this block.
                              example: '12304896'
                            proposer_index:
                              type: string
                              description: Index of the block proposer.
                              example: '1093008'
                            parent_root:
                              type: string
                              description: Parent block root hash.
                              example: '0x3590c9b1a918586a2dabde886abea7f26cfa3a11683be1ab73283e6af70733ba'
                            state_root:
                              type: string
                              description: State root after this block.
                              example: '0xf5bcaecf4eeaf601cdce952429a40fbe1b3cc24c25baba21f5eed360f6e636f2'
                            body_root:
                              type: string
                              description: Root of the block body.
                              example: '0xb2d5058e1f4bc888fa4d6a859a88c975bee5d853aec239a2e67ecf92c3b2d6c5'
                        signature:
                          type: string
                          description: Block signature.
                          example: '0x8c5a8efa6e472c358dd7024fae6f6569cd60af754591ddc78ef9e9db287aa68cb7d38c171b96ae11d1b033c1f4921151021bc1d1f4541a5528d15e926d0ca8385286ca49670adcd0e8f26ec231895dc32d7146db55360e0f1ed5ab7757e34258'
          examples:
            response:
              summary: Example response
              value:
                execution_optimistic: false
                finalized: false
                data:
                  - root: '0x95656528b8dbed879305ffa67ed688f8e262b2dfa5f620e384056f49dec95267'
                    canonical: true
                    header:
                      message:
                        slot: '12304896'
                        proposer_index: '1093008'
                        parent_root: '0x3590c9b1a918586a2dabde886abea7f26cfa3a11683be1ab73283e6af70733ba'
                        state_root: '0xf5bcaecf4eeaf601cdce952429a40fbe1b3cc24c25baba21f5eed360f6e636f2'
                        body_root: '0xb2d5058e1f4bc888fa4d6a859a88c975bee5d853aec239a2e67ecf92c3b2d6c5'
                      signature: '0x8c5a8efa6e472c358dd7024fae6f6569cd60af754591ddc78ef9e9db287aa68cb7d38c171b96ae11d1b033c1f4921151021bc1d1f4541a5528d15e926d0ca8385286ca49670adcd0e8f26ec231895dc32d7146db55360e0f1ed5ab7757e34258'
```
