I need to get the block hash of the block containing specified transaction. I have been parsing blockexplorer for this data, but it seems to be having some difficulties lately, so I'm looking for alternatives. Blockchain.info json api doesn't seem to have this information. Are there any other alternatives? Thanks in advance.
Blockchain.info's API is written to be compatible with the BlockExplorer API.
What approach are you taking on BlockExplorer?
The API does give transactions for each block:
-
http://blockchain.info/rawblock/183164Though how to figure out which block has a transaction, I'm not sure.
yes, this is exactly what I need to do. I have a transaction hash and I need the block hash containing the transaction (so I can download that block later using bitcoinj, but that library has no way of downloading a transaction from given transaction hash). I am currently parsing the
http://blockexplorer.com/tx/txhash page for "Appeared in block #" which in turn has a link containing it's hash. But since blockexplorer is stuck on block #182973 this approach is now useless (and it hasn't been working most of the time as of late anyway). I could use the same approach with blockchain (and I will if there are no better alternatives), but that would mean querying it twice per transaction since the block hash is not on the same page as block number.
A workaround would be somehow importing the raw transaction data from blockchain json api into the bitcoinj Transaction object, but that's quite a bit more difficult than parsing for a block hash...