10

I know that all Bitcoin API methods are listed on the wiki: https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list. However, some of the methods are very poorly documented.

F.e. the lockunspent method is only documented as taking the parameters <unlock?> [array-of-objects]. No clue about what type of objects. And there are more examples like this.

Is there a good API reference that specifies what parameters are expected and what result they give back?

This would so much lower the bar for new developers!

4
  • 5
    I hate to say this, but the source code is probably the ultimate reference. Commented May 2, 2013 at 21:15
  • 3
    Unfortunately more developers lend their time towards making new exchanges or arbitrage bots than actually making Bitcoin more useful. Those who put together Bitcoin.it did a wonderful job but there needs to be an updated spec sheet with examples as you outline in your question.
    – bvpx
    Commented Oct 22, 2013 at 17:52
  • The 'help' RPC was improved a lot in 0.9.0 (you can currently download rc3). Parameter names, types and examples are now included.
    – laanwj
    Commented Mar 17, 2014 at 16:12
  • @wumpus see my answer; rpc reference definitely improved Commented Sep 28, 2014 at 11:34

4 Answers 4

3

Here is a complete API reference that has a pending pull request for bitcoin.org

http://bitcoindev.us.to/en/developer-reference#bitcoin-core-apis

More information: https://bitcointalk.org/index.php?topic=511876.0

2

Apparently, a full API reference just got published on the Bitcoin website:

https://bitcoin.org/en/developer-reference#remote-procedure-calls-rpcs

1

I've used macros and pulled the full RPC documentation from Bitcoin Core 0.9.2.1 (rough formatting, help appreciated!)

Full code won't fit here (80000 chars>30000 limit), but here's the help commands I entered and copied the returned data from:

help addmultisigaddress
help addnode 
help backupwallet 
help createmultisig 
help createrawtransaction 
help decoderawtransaction 
help decodescript 
help dumpprivkey 
help dumpwallet 
help getaccount 
help getaccountaddress 
help getaddednodeinfo 
help getaddressesbyaccount 
help getbalance 
help getbestblockhash
help getblock 
help getblockchaininfo
help getblockcount
help getblockhash 
help getblocktemplate 
help getconnectioncount
help getdifficulty
help getgenerate
help gethashespersec
help getinfo
help getmininginfo
help getnettotals
help getnetworkhashps 
help getnetworkinfo
help getnewaddress 
help getpeerinfo
help getrawchangeaddress
help getrawmempool 
help getrawtransaction 
help getreceivedbyaccount 
help getreceivedbyaddress 
help gettransaction 
help gettxout 
help gettxoutsetinfo
help getunconfirmedbalance
help getwalletinfo
help getwork 
help help 
help importprivkey 
help importwallet 
help keypoolrefill 
help listaccounts 
help listaddressgroupings
help listlockunspent
help listreceivedbyaccount 
help listreceivedbyaddress 
help listsinceblock 
help listtransactions 
help listunspent 
help lockunspent 
help move 
help ping
help sendfrom 
help sendmany 
help sendrawtransaction 
help sendtoaddress 
help setaccount 
help setgenerate 
help settxfee 
help signmessage 
help signrawtransaction 
help stop
help submitblock 
help validateaddress 
help verifychain 
help verifymessage 
help walletlock
help walletpassphrase 
help walletpassphrasechange

And a few egs:

addmultisigaddress nrequired ["key",...] ( "account" )

Add a nrequired-to-sign multisignature address to the wallet.
Each key is a Bitcoin address or hex-encoded public key.
If 'account' is specified, assign address to that account.

Arguments:
1. nrequired (numeric, required) The number of required signatures out of the n keys or addresses.
2. "keysobject" (string, required) A json array of bitcoin addresses or hex-encoded public keys
[
"address" (string) bitcoin address or hex-encoded public key
...,
]
3. "account" (string, optional) An account to assign the addresses to.

Result:
"bitcoinaddress" (string) A bitcoin address associated with the keys.

Examples:

Add a multisig address from 2 addresses
> bitcoin-cli addmultisigaddress 2 "[\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\",\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\"]"

As json rpc call
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "addmultisigaddress", "params": [2, "[\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\",\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\"]"] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/



addnode "node" "add|remove|onetry"

Attempts add or remove a node from the addnode list.
Or try a connection to a node once.

Arguments:
1. "node" (string, required) The node (see getpeerinfo for nodes)
2. "command" (string, required) 'add' to add a node to the list, 'remove' to remove a node from the list, 'onetry' to try a connection to the node once

Examples:
> bitcoin-cli addnode "192.168.0.6:8333" "onetry"
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "addnode", "params": ["192.168.0.6:8333", "onetry"] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/


backupwallet "destination"

Safely copies wallet.dat to destination, which can be a directory or a path with filename.

Arguments:
1. "destination" (string) The destination directory or file

Examples:
> bitcoin-cli backupwallet "backup.dat"
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "backupwallet", "params": ["backup.dat"] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/

PS. C++/QT formatting at Pastebin file so formatting may need changing and there's still time stamps I didn't edit out.

-1

One of the recent additions to the API is:

bitcoind getnetworkhashps

This is not documented in the wiki to which your question links.

While the source code is indeed the ultimate reference, in practice, bitcoind help is the shortest path to most answers.

Here is the entry for lockunspent:

root@blockchainer-test:~# bitcoind help lockunspent
lockunspent unlock [{"txid":"txid","vout":n},...]

Updates list of temporarily unspendable outputs.
Temporarily lock (lock=true) or unlock (lock=false) specified transaction outputs.
A locked transaction output will not be chosen by automatic coin selection, when spending bitcoins.
Locks are stored in memory only. Nodes start with zero locked outputs, and the locked output list
is always cleared (by virtue of process exit) when a node stops or fails.
Also see the listunspent call

Arguments:
1. unlock            (boolean, required) Whether to unlock (true) or lock (false) the specified transactions
2. "transactions"  (string, required) A json array of objects. Each object the txid (string) vout (numeric)
     [           (json array of json objects)
       {
         "txid":"id",    (string) The transaction id
         "vout": n         (numeric) The output number
       }
       ,...
     ]

Result:
true|false    (boolean) Whether the command was successful or not

Examples:

List the unspent transactions
> bitcoin-cli listunspent

Lock an unspent transaction
> bitcoin-cli lockunspent false "[{\"txid\":\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\",\"vout\":1}]"

List the locked transactions
> bitcoin-cli listlockunspent

Unlock the transaction again
> bitcoin-cli lockunspent true "[{\"txid\":\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\",\"vout\":1}]"

As a json rpc call
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "lockunspent", "params": [false, "[{\"txid\":\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\",\"vout\":1}]"] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/

Below is a list of all methods you can call on bitcoind, for reference:

root@blockchainer-test:~# bitcoind help
addmultisigaddress nrequired ["key",...] ( "account" )
addnode "node" "add|remove|onetry"
backupwallet "destination"
createmultisig nrequired ["key",...]
createrawtransaction [{"txid":"id","vout":n},...] {"address":amount,...}
decoderawtransaction "hexstring"
decodescript "hex"
dumpprivkey "bitcoinaddress"
dumpwallet "filename"
encryptwallet "passphrase"
getaccount "bitcoinaddress"
getaccountaddress "account"
getaddednodeinfo dns ( "node" )
getaddressesbyaccount "account"
getbalance ( "account" minconf )
getbestblockhash
getblock "hash" ( verbose )
getblockchaininfo
getblockcount
getblockhash index
getblocktemplate ( "jsonrequestobject" )
getconnectioncount
getdifficulty
getgenerate
gethashespersec
getinfo
getmininginfo
getnettotals
getnetworkhashps ( blocks height )
getnetworkinfo
getnewaddress ( "account" )
getpeerinfo
getrawchangeaddress
getrawmempool ( verbose )
getrawtransaction "txid" ( verbose )
getreceivedbyaccount "account" ( minconf )
getreceivedbyaddress "bitcoinaddress" ( minconf )
gettransaction "txid"
gettxout "txid" n ( includemempool )
gettxoutsetinfo
getunconfirmedbalance
getwalletinfo
getwork ( "data" )
help ( "command" )
importprivkey "bitcoinprivkey" ( "label" rescan )
importwallet "filename"
keypoolrefill ( newsize )
listaccounts ( minconf )
listaddressgroupings
listlockunspent
listreceivedbyaccount ( minconf includeempty )
listreceivedbyaddress ( minconf includeempty )
listsinceblock ( "blockhash" target-confirmations )
listtransactions ( "account" count from )
listunspent ( minconf maxconf  ["address",...] )
lockunspent unlock [{"txid":"txid","vout":n},...]
move "fromaccount" "toaccount" amount ( minconf "comment" )
ping
sendfrom "fromaccount" "tobitcoinaddress" amount ( minconf "comment" "comment-to" )
sendmany "fromaccount" {"address":amount,...} ( minconf "comment" )
sendrawtransaction "hexstring" ( allowhighfees )
sendtoaddress "bitcoinaddress" amount ( "comment" "comment-to" )
setaccount "bitcoinaddress" "account"
setgenerate generate ( genproclimit )
settxfee amount
signmessage "bitcoinaddress" "message"
signrawtransaction "hexstring" ( [{"txid":"id","vout":n,"scriptPubKey":"hex","redeemScript":"hex"},...] ["privatekey1",...] sighashtype )
stop
submitblock "hexdata" ( "jsonparametersobject" )
validateaddress "bitcoinaddress"
verifychain ( checklevel numblocks )
verifymessage "bitcoinaddress" "signature" "message"
2
  • I was more looking to an official reference that is maintained by the devs and that also contains formatting information of parameters and return values. Commented May 10, 2014 at 14:13
  • Also, most people use bitcoind through RPC and some may not have an instance available to use the help command on. There should be an online reference somewhere IMO. Commented May 10, 2014 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.