简体   繁体   中英

Call blockchain.info API with javascript or jQuery

Is it possible to call the blockchain.info API with javascript or jQuery?

I'm trying to get all the address info in json format with:

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

Or:

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

From what i've read, it should be possible, but i'm starting to doubt it now. I know I can use a PHP script, a proxy, or some kind of YQL hack, but that won't really do what I want.

Basically, i've been trying various different versions of this:

    <!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>

But so far, nothing's worked. Am I wasting my time here?

I don't recommend to get all details at once. That would be confusing because there's so much data on the JSON data. You can fetch every data from Blockchain's Query API's with AJAX. For example, for getting a balance of a wallet, you can do:

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

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM