[用JavaScript或jQuery调用blockchain.info API

问题描述 投票:0回答:1

是否可以使用javascript或jQuery调用blockchain.info API?

我正在尝试使用json格式获取所有地址信息:

https://blockchain.info/address/1Nkmns4Pan2hknkQFfRCLnoKdR5VEP324J?format=json

或:

https://blockchain.info/address/1Nkmns4Pan2hknkQFfRCLnoKdR5VEP324J?format=json&cors=true

根据我的阅读,应该有可能,但是我现在开始怀疑它。我知道我可以使用PHP脚本,代理或某种YQL hack,但这并不能真正满足我的要求。

基本上,我一直在尝试各种不同的版本:

    <!DOCTYPE html>
    <html>
    <head>
    <title>Blockchain.info API</title>
    <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
        <script>
        $.getJSON( "https://blockchain.info/address/1Nkmns4Pan2hknkQFfRCLnoKdR5VEP324J?format=json&cors=true", function( data ) {
            $.each(txs.hash, function(key, value){
                $('#test').append(key+': '+value+'<br>');
            });
        });
        </script>
    </head>
    <body>
        <div id="test"></div>
    </body>
    </html>

但是到目前为止,没有任何效果。我在这里浪费时间吗?

javascript jquery bitcoin blockchain
1个回答
0
投票

我不建议一次获取所有详细信息。这会造成混乱,因为JSON数据上有太多数据。您可以使用AJAX从Blockchain的查询API中获取所有数据。例如,要获取钱夹余额,您可以执行以下操作:

  $.ajax({url: "https://api.blockchain.com/q/addressbalance/bitcoinaddress", success: function(result){
   $("#test").html(result);
  }});

希望这会有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.