# getblockchaininfo

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

POST https://bitcoin-mainnet.g.alchemy.com/v2/{apiKey}

Returns an object containing state details related to blockchain processing, network, and storage information.


Reference: https://www.alchemy.com/docs/chains/bitcoin/bitcoin-api-endpoints/getblockchaininfo

## Result

**result** (object): Blockchain status information.

## Example

### Response

```json
{
  "jsonrpc": "2.0",
  "result": {
    "chain": "main",
    "blocks": 894713,
    "headers": 894713,
    "bestblockhash": "00000000000000000000eb0ae1714d3ec43cfaac74769f3bcde489daf116e4ca",
    "bits": "170248b6",
    "target": "0000000000000000000248b60000000000000000000000000000000000000000",
    "difficulty": 123234387977050.9,
    "time": 1746083867,
    "mediantime": 1746081100,
    "verificationprogress": 0.9999993374725104,
    "initialblockdownload": false,
    "chainwork": "0000000000000000000000000000000000000000bfce6962cc3162143b67a1d4",
    "size_on_disk": 745999541195,
    "pruned": false,
    "warnings": []
  },
  "id": 1
}
```

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getblockchaininfo"
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({jsonrpc: '2.0', id: 1, method: 'getblockchaininfo'})
};

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

### Python

```python
import requests

url = "https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo"

payload = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getblockchaininfo"
}
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://bitcoin-mainnet.g.alchemy.com/v2/docs-demo"

	payload := strings.NewReader("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"getblockchaininfo\"\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://bitcoin-mainnet.g.alchemy.com/v2/docs-demo")
  .header("Content-Type", "application/json")
  .body("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"getblockchaininfo\"\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddJsonBody("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"getblockchaininfo\"\n}", false);
var response = await client.PostAsync(request);

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

```


## OpenRPC Method Specification

```yaml
name: getblockchaininfo
summary: Retrieve general information about the blockchain.
description: |
  Returns an object containing state details related to blockchain processing, network, and storage information.
params: []
result:
  name: result
  description: Blockchain status information.
  schema:
    title: Bitcoin Blockchain Info
    type: object
    required:
      - chain
      - blocks
      - headers
      - bestblockhash
      - difficulty
      - time
      - mediantime
      - verificationprogress
      - initialblockdownload
      - chainwork
      - size_on_disk
      - pruned
    properties:
      chain:
        type: string
        description: Current network name (main, test, regtest).
      blocks:
        type: integer
        description: The current number of blocks.
      headers:
        type: integer
        description: The current number of headers.
      bestblockhash:
        type: string
        description: The hash of the best block.
      bits:
        type: string
        description: The nBits field of the best block header.
      target:
        type: string
        description: The target corresponding to current difficulty.
      difficulty:
        type: number
        format: double
        description: The current difficulty.
      time:
        type: integer
        description: Timestamp of the best block.
      mediantime:
        type: integer
        description: Median time of the blockchain.
      verificationprogress:
        type: number
        format: double
        description: Estimate of verification progress (0.0–1.0).
      initialblockdownload:
        type: boolean
        description: Whether the node is in IBD (initial block download).
      chainwork:
        type: string
        description: Expected number of hashes required to produce the chain.
      size_on_disk:
        type: integer
        description: Estimated size of the blockchain stored on disk in bytes.
      pruned:
        type: boolean
        description: If the blockchain is pruned.
      warnings:
        type: array
        description: Any network or blockchain warnings.
        items:
          type: string
examples:
  - name: getblockchaininfo example
    params: []
    result:
      name: result
      value:
        chain: main
        blocks: 894713
        headers: 894713
        bestblockhash: 00000000000000000000eb0ae1714d3ec43cfaac74769f3bcde489daf116e4ca
        bits: 170248b6
        target: 0000000000000000000248b60000000000000000000000000000000000000000
        difficulty: 123234387977050.9
        time: 1746083867
        mediantime: 1746081100
        verificationprogress: 0.9999993374725104
        initialblockdownload: false
        chainwork: 0000000000000000000000000000000000000000bfce6962cc3162143b67a1d4
        size_on_disk: 745999541195
        pruned: false
        warnings: []
```
