Bitcoind block chain structure
the BLK files are not an API. You shouldn't directly read those files.
What you should do is requesting the headers/block via the JSON RPC interface (or the REST interface).

You can get the genesis block hash via:

bitcoin-cli getblockhash 0


Then you can get a block (without transactions):

bitcoin-cli getblock &lt;hash&gt;


Then get the next block by looking at the nextblockhash item in the block JSON response, etc.

Also, consider using the REST interface. There you can get binary responses which are much faster (no JSON encoding/decoding overhead).