Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: newguy05 on August 29, 2013, 12:37:12 AM



Title: java api to find bitcoin difficulty?
Post by: newguy05 on August 29, 2013, 12:37:12 AM
Hi have a newbie question, how do i use java to find the current bitcoin network difficulty and past difficulties etc..?  I looked at bitcoinj but that's mostly for wallet sending/receiving i believe.  I dont need wallet or security, just want a way to get stats about the network using java.

Can someone point me in the right direction on the api/packages that's available or how to do that.  thanks


Title: Re: java api to find bitcoin difficulty?
Post by: tgerring on August 29, 2013, 05:49:16 AM
Your best bet is probably to use a service such at blockchain.info (https://blockchain.info/api) to gather stats. You'll have to make an HTTP request and parse the result with some JSON module.

If you do ever want to interact with the mainline client directly, it's easily as simple, because bitcoind support a JSON-RPC interface. The wiki even has Java-specific information (https://en.bitcoin.it/wiki/API_reference_(JSON-RPC)#Java).


Title: Re: java api to find bitcoin difficulty?
Post by: newguy05 on August 29, 2013, 01:39:34 PM
Your best bet is probably to use a service such at blockchain.info (https://blockchain.info/api) to gather stats. You'll have to make an HTTP request and parse the result with some JSON module.

If you do ever want to interact with the mainline client directly, it's easily as simple, because bitcoind support a JSON-RPC interface. The wiki even has Java-specific information (https://en.bitcoin.it/wiki/API_reference_(JSON-RPC)#Java).

hi thanks for the response, yes i am looking for a direct connection to the p2p network not via a third party. For example how does blockchain.info get its stats?  I can code the api myself in java but just confused as to how to go about getting stats on the network, dont want to have a dependency on a third party website (third party api jar files are ok but i cant find any).

for example

public static long getCurrentDifficulty()
{
//what are some of the high level steps i have to do?
}


Title: Re: java api to find bitcoin difficulty?
Post by: tgerring on August 29, 2013, 01:52:09 PM
You may not be able to grab every stat (such as historical network difficulty) with just bitcoind.

Here's a full list of bitcoind API calls (https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_Calls_list)