0

I am building blockchain explorer. I have my own blockchain. In that, i want to search details of a given address from blockchain. There is no direct API to get detail of an address, could anybody help how to this ? Thanks in Advance.

John
  • 61
  • 6

2 Answers2

0

Two options:

option 1:

blockchain.info has an open API (REST + JSON)

https://blockchain.info/it/api/blockchain_api

here how:

https://blockchain.info/it/rawaddr/$bitcoin_address

bear in mind that you can only acquire info from an address that actually moved at least once some bitcoin on the network. If you just create a new wallet and do not transact then the public address is non existent on the blockchain (i.e. there's no difference between a newly generated address and a non existent address). That's the "shameful" approach as you are building a blockchain explorer using another blockchain explorer, see option 2 for the correct approach:

option 2:

Run a bitcoin node on your own and query your stuff on it. You may not be able to run a node on a normal hosting, probably you need something more like an Amazon AWS instance or host on your own server

Gianluca Ghettini
  • 11,129
  • 19
  • 93
  • 159
  • I have created my own blockchain, i want to get address detail from that blockchain. – John Aug 18 '17 at 09:46
  • if you created your own blockchain then you should know everything about it, don't you? – Gianluca Ghettini Aug 18 '17 at 09:47
  • We have taken peercoin source code for making that. And all APIs are same as peercoin standard APIs. But there is no API to get detail corresponding to a given address. – John Aug 18 '17 at 09:49
  • it's a fork of bitcoin so it uses the same mechanism: https://github.com/peercoin/peercoin – Gianluca Ghettini Aug 18 '17 at 09:52
  • There is no API to get all detail about given address. I don't know how the search functionality working for address in bitcoin/peercoin blockchain exporer ? I mean what is the logic behind that to find detail of given address , as there is no direct API. – John Aug 18 '17 at 10:11
  • study bitcoin first, how to get info from an existing address. then you can move to peercoin. I recommend "Mastering Bitcoin" from Andreas Antonopulous – Gianluca Ghettini Aug 18 '17 at 10:28
  • There is no information/solution in that book which i want to know about. I think you didn't understand my question. I am not creating a explorer using another explorer. I just want to know how to get address details from blockchain, i mean through which api or logic behind this ? – John Aug 21 '17 at 07:54
0

I see from comments you are using peercoin (https://github.com/peercoin/peercoin). If it's a fork of Bitcoin, then the following holds:

In basic Bitcoin full-node setup, it's impossible to query random address. You can add some addresses to track, but think of it as of "yours".

There are modifications to the bitcoin-core, that have a addressindex option. The one I am aware of is bitcore: https://github.com/bitpay/bitcore-node.

Here's how to run your own blockchain explorer for Bitcoin using bitcore's insight: https://github.com/bitpay/insight-api

npm install -g bitcore@latest
bitcore create mynode
cd mynode
bitcore install insight-api
bitcore install insight-ui
bitcore start

This will launch full node in the needed mode (addressindex=1 enabled, etc) and a webservice with API and UI, similar to: https://insight.bitpay.com/.

Config file will be located at mynode/bitcore-node.json

Bitcore's docs and not well maintained, some are outdated. Try the code, but don't give up if it fails. For more information, refer to the source code.

P.S. I am not sure how to convert this to run with your blockchain, but if it's similar to bitcoin, it should be possible. I think it's closest you can get without writing your own explorer.

caffeinum
  • 401
  • 5
  • 13