<p>There's a boolean parameter to that RPC call that'll return it as a hex string representing the binary contents of the block.</p>

<blockquote>
  <p>If verbosity is 0, returns a string that is serialized, hex-encoded data for block 'hash'</p>
</blockquote>

<p><code>getblock 'hash' 0</code> should return what you want.</p>

CC BY-SA 3.0
2017-09-27T07:25:02.523Z
2017-09-27T07:25:02.523Z
alcio
<p>I can use <code>getblock</code> json rpc method to get parsed block details, however I need the actual raw data.</p>
<p>Is there any way to get raw block data using Bitcoin Core?</p>

CC BY-SA 3.0
2017-09-23T14:27:29.617Z
You can read it directly from the blk*.dat files...
Nate Eldredge
CC BY-SA 3.0
2017-09-23T18:02:33.547Z
So to implement such method as getrawblock I need to create my own index with filename and offset for each block, right?
Andrey Lobarev
CC BY-SA 3.0
2017-09-24T02:26:16.240Z
In principle you can use the existing leveldb database in the `blocks/index` directory to locate the block data within the blk*.dat file by its hash.  See https://en.bitcoin.it/wiki/Bitcoin_Core_0.11_(ch_2):_Data_Storage or https://bitcoin.stackexchange.com/questions/28168/what-are-the-keys-used-in-the-blockchain-leveldb-ie-what-are-the-keyvalue-pair for the data format.
Nate Eldredge
<bitcoin-core><block><raw-data>
How to get raw block data?
Andrey Lobarev
# How to get raw block data?

(Asked by: username_0 on 2017-09-23)

I can use `getblock` json rpc method to get parsed block details, however I need the actual raw data.

Is there any way to get raw block data using Bitcoin Core?

**Tags:** bitcoin-core, block, raw-data

> **Comments:**
> **username_1**: You can read it directly from the blk*.dat files...  
> **username_0**: So to implement such method as getrawblock I need to create my own index with filename and offset for each block, right?  
> **username_1**: In principle you can use the existing leveldb database in the `blocks/index` directory to locate the block data within the blk*.dat file by its hash.  See https://en.bitcoin.it/wiki/Bitcoin_Core_0.11_(ch_2):_Data_Storage or https://bitcoin.stackexchange.com/questions/28168/what-are-the-keys-used-in-the-blockchain-leveldb-ie-what-are-the-keyvalue-pair for the data format.  

---

## 1 answers

### Answer by username_2 on 2017-09-27. Score: 9 | Accepted answer

There's a boolean parameter to that RPC call that'll return it as a hex string representing the binary contents of the block.

> If verbosity is 0, returns a string that is serialized, hex-encoded data for block 'hash'

`getblock 'hash' 0` should return what you want.


---

