API 用户指南
总体说明
·
所有API请求为HTTP GET 请求,返回数据为JSON格式,为了防止API被滥用或恶意使用,要求每个API使用者都要申请一个API Key,每个API Key唯一标识一个API使用者,如果只是想试验一下API,我们也提供了测试API,在这种情况下,API调用会被限制在每分钟50次。
·
默认的API请求查询的是BTC的信息,如果想查询LTC的信息,需要加个ltc=true的参数。
 
·
Js跨域请求json对象的时候,url的后缀最后带一个 callback=? 的参数作为成功的回调函数,例如Jquery $.getJSON():

var url = "http://open.qukuai.com/block/00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048?key=2ejf4jgfNoya8Y3GnQf68e4J23HherpUh1&callback=?";  
$.getJSON(url, {} , function(data) {    
	console.log(data)    
}); 
						
测试接入
·
任何人都可以使用测试Key 2ejf4jgfNoya8Y3GnQf68e4J23HherpUh1 进行调用
·
正式接入
·
发邮件至hi@qukuai.com ,标题”申请API接入”,正文说明接入应用/网站名,调用频率范围等信息,工作人员会在两天内审核并回复API KEY,然后即可正式接入
API列表集成
Block
·
用途:通过区块hash获取区块内容
·
格式:http://open.qukuai.com/block/$block_hash?key=$key
·
参数: $block_has=>区块hash    $key=>访问api的身份ID
·
·
返回内容:

{
    "nonce": 2573394689,
    "hash": "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048",
    "version": 1,
    "merkle_root": "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098",
    "previous_block_hash": "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
    "height": 1,
    "difficulty": "1.00000000",
    "confirmations": 293965,
    "time": 1231469665,
    "next_block_hash": "000000006a625f06636b8bb6ac7b960a8d03705d1ace08b1a19da3fdcc99ddbd",
    "transaction_hashes": [
        "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098"
    ]
}
							
·
用途:通过区块高度获取区块内容
·
格式:http://open.qukuai.com/block/height/$block_index?key=$key
·
参数: $block_index=>区块高度    $key=>访问api的身份ID
·
·
返回内容:

{
    "nonce": 2573394689,
    "hash": "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048",
    "version": 1,
    "merkle_root": "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098",
    "previous_block_hash": "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
    "height": 1,
    "difficulty": "1.00000000",
    "confirmations": 293965,
    "time": 1231469665,
    "next_block_hash": "000000006a625f06636b8bb6ac7b960a8d03705d1ace08b1a19da3fdcc99ddbd",
    "transaction_hashes": [
        "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098"
    ]
}
							
·
用途:获取最新区块的内容
·
格式:http://open.qukuai.com/blocklast?key=$key
·
参数:$key=>访问api的身份ID
·
·
返回内容:

{
    "nonce": 3150928650,
    "previous_block_hash": "000000000000000013d188e44fbd618796278ff5e90bd1ceb3e4e7c7e037aced",
    "hash": "00000000000000001911bc11331276aa95889738d1ca89b84c7abd4eaceaf3b5",
    "minerpool": "KnCMiner",
    "height": 322485,
    "difficulty": "29829733124.04041672",
    "version": 2,
    "transaction_hashes": [
        "e95932c5902207f5d6ffdc0e4a7d29d2aca08b3a67aa8de38113077c2e6f06a1",
        "05eb042ddc196f8644d0528db126d4469bd72e9a4056e101dde03c24eea21905",
        "4a57118743c8964014cdd413e3d5536709db791f0ae0b5956314a601955603b1",
    ],
    "confirmations": 1,
    "time": 1411641385,
    "merkle_root": "62a94fb5bf256a1064dc87a991f12488ff9299af8cd6d744b36ec3f5abbbb128"
}
							
Address
·
用途:获取地址的账户信息
·
格式:http://open.qukuai.com/address/$bitcoin_address?key=$key
·
参数: $bitcoin_address=>地址    $key=>访问api的身份ID
·
·
返回内容:

{
    "received": 5000030000,
    "rank": 23526,
    "confirmations": 4,
    "address": "1FvzCLoTPGANNjWoUo6jUGuAG3wg1w4YjR",
    "rankper": "0.67",
    "balance": 5000030000
}
							
·
用途:获取地址的交易信息,最多获取最近的50条交易
·
格式:http://open.qukuai.com/address/transactions/$bitcoin_address?key=$key&limit=$limit
·
参数: $bitcoin_address=>地址    $key=>访问api的身份ID    $limit=>数量
·
·
返回内容:

[
    {
        "block_hash": "0000000082b5015589a3fdf2d4baff403e6f0be035a5d9742c1cae6295464449",
        "outputs": [
            {
                "address": [
                    "1FvzCLoTPGANNjWoUo6jUGuAG3wg1w4YjR"
                ],
                "value": 5000000000
            }
        ],
        "transaction_hash": "999e1c837c76a1b7fbb7e57baf87b309960f5ffefbf2a9b95dd890602272f644",
        "value": 5000000000,
        "coinbase": "04ffff001d010e",
        "confirmations": 322483,
        "block_time": "2009-01-09 11:02:53",
        "block_height": 3
    },
    {
        "block_hash": "0000000000000000208fa6e52e23f9474ba7fbbcbe7478e23b8a70c967aa0327",
        "inputs": [
            {
                "transaction_hash": "0538e865cf206db100febb72a71c21a473a82486814691ed7ab0a863083969c1",
                "value": 772000,
                "address": [
                    "16r8J9bmThZCSN2qeKza6btdMk4bb8rnEh"
                ]
            }
        ],
        "transaction_hash": "e368fa9f7f23a3f38dcf8f263e5a669863cb25ded33f53064e6484b9128e2082",
        "value": 762000,
        "confirmations": 2795,
        "block_time": "2014-09-08 19:02:53",
        "block_height": 319691,
        "outputs": [
            {
                "address": [
                    "1FvzCLoTPGANNjWoUo6jUGuAG3wg1w4YjR"
                ],
                "value": 10000
            },
            {
                "address": [
                    "16r8J9bmThZCSN2qeKza6btdMk4bb8rnEh"
                ],
                "value": 752000
            }
        ]
    }
]
							
·
用途:获取地址的未花费输出信息
·
格式:http://open.qukuai.com/address/unspents/$bitcoin_address?key=$key
·
参数: $bitcoin_address=>地址    $key=>访问api的身份ID
·
·
返回内容:

[
    {
        "block_hash": "00000000000000120f3556a089a0e4cdf28e8fb189423b5e73b064f7c2205b3f",
        "inputs": [
            {
                "transaction_hash": "00697e39c92953a8fab357fe1ca22d15908876e0fdd75056f044a16066f01149",
                "value": 1511489,
                "address": [
                    "1AuC3Wb7rr5Q7dTyq7vZj1ckr4nWr5P3Wj"
                ]
            }
        ],
        "transaction_hash": "7b8800a009f96ffc39cb3dbedfcf0b8c45c3f95877c318de72b89b357f5a8f1e",
        "value": 1461489,
        "confirmations": 68349,
        "block_time": "2013-08-25 17:06:22",
        "block_height": 254137,
        "outputs": [
            {
                "address": [
                    "1FvzCLoTPGANNjWoUo6jUGuAG3wg1w4YjR"
                ],
                "value": 10000
            }
        ]
    },
    {
        "block_hash": "0000000082b5015589a3fdf2d4baff403e6f0be035a5d9742c1cae6295464449",
        "outputs": [
            {
                "address": [
                    "1FvzCLoTPGANNjWoUo6jUGuAG3wg1w4YjR"
                ],
                "value": 5000000000
            }
        ],
        "transaction_hash": "999e1c837c76a1b7fbb7e57baf87b309960f5ffefbf2a9b95dd890602272f644",
        "value": 5000000000,
        "coinbase": "04ffff001d010e",
        "confirmations": 322483,
        "block_time": "2009-01-09 11:02:53",
        "block_height": 3
    }
]
							
·
用途:获取top100的地址列表
·
格式:http://open.qukuai.com/topaddress?key=$key
·
参数:$key=>访问api的身份ID
·
·
返回内容:

{
    "total": 264571667644711,
    "address_list": [
        {
            "balance": 14849760845690,
            "time": "2014-09-24 04:10:16",
            "address": "1BPqtqBKoUjEq8STWmJxhPqtsf3BKp5UyE"
        },
        {
            "balance": 999999991000,
            "time": "2014-09-07 08:31:10",
            "address": "1HsHPTnxMUJeudSUXvmBq4NTTaPUVtugwE"
        }
    ]
}
							
Transaction
·
用途:通过交易ID获取一个交易内容
·
格式:http://open.qukuai.com/transaction/$tx_id?key=$key
·
参数:$tx_id=>交易id     $key=>访问api的身份ID
·
·
返回内容:

{
    "block_hash": "00000000000000120f3556a089a0e4cdf28e8fb189423b5e73b064f7c2205b3f",
    "inputs": [
        {
            "transaction_hash": "00697e39c92953a8fab357fe1ca22d15908876e0fdd75056f044a16066f01149",
            "value": 1511489,
            "address": [
                "1AuC3Wb7rr5Q7dTyq7vZj1ckr4nWr5P3Wj"
            ]
        }
    ],
    "transaction_hash": "7b8800a009f96ffc39cb3dbedfcf0b8c45c3f95877c318de72b89b357f5a8f1e",
    "value": 1461489,
    "confirmations": 68349,
    "block_time": "2013-08-25 17:06:22",
    "block_height": 254137,
    "outputs": [
        {
            "address": [
                "16Tt2hxvEGhsW1h4Py5nZKjZuzL2Qd7FXw"
            ],
            "value": 1451489
        },
        {
            "address": [
                "1FvzCLoTPGANNjWoUo6jUGuAG3wg1w4YjR"
            ],
            "value": 10000
        }
    ]
}
							
Info
·
用途:获取难度
·
格式:http://open.qukuai.com/difficulty?key=$key
·
参数:$key=>访问api的身份ID
·
·
返回内容:

{
    "difficulty": "29829733124.04041672",
    "time": 1411641385
}							
						
·
用途:获取算力
·
格式:http://open.qukuai.com/hashps?key=$key
·
参数:$key=>访问api的身份ID
·
·
返回内容:

{
    "hashps": 246387954616032400,
    "time": 1411906417.83663
}
							
·
用途:获取当前高度
·
格式:http://open.qukuai.com/height?key=$key
·
参数:$key=>访问api的身份ID
·
·
返回内容:

{
    "time": 1411906471.746854,
    "block_height": 322485
}
							
·
用途:获取比特币总数量
·
格式:http://open.qukuai.com/total?key=$key
·
参数:$key=>访问api的身份ID
·
·
返回内容:

{
    "total": 13312150,
    "time": 1411906526.259116
}
							
异常请求情况:
404,返回json数据:{"error":404}
缺少参数,返回json数据:{"missing parameter":1003}
没有权限,返回json数据:{"no permission":1001}
请求频率限制,返回json数据:{"frequency limit",1002}