BlockDog API 查询 EOS actions - 区块链数据开发实战

简介:BlockDog 方块狗是公鹿钱包团队推出的网站。他们借用这个网站提供公共 API 服务以方便 EOS 开发者进行 EOS 相关开发。本文整理使用 BlockDog API 查询 EOS actions。

BlockDog 方块狗是公鹿钱包团队推出的网站。他们借用这个网站提供公共 API 服务以方便 EOS 开发者进行 EOS 相关开发。

本文整理使用 BlockDog API 查询 EOS actions。

BlockDog API 官方文档:https://open-api.eos.blockdog.com/

使用 BlockDog API 需要申请 apikey://www.blockdog.com/openApi

免费版 apikey 支持 HTTPS API 调用频次≤3次/秒,WebSocket API 订阅合约/账户调用峰值≤3次。

BlockDog API 查询 EOS actions:

请求参数:

code: 动作执行的合约名, 如果related=true, 查询结果则包含执行的合约名为code或者转账转入/转出为code

related: 是否为相关查询, 默认为 false, 如果为 true 查询结果包含执行的合约名为code或者转账转入/转出为code

name: 合约动作名;

account_name: 发起者 EOS 账号;

status: 交易状态;

start_block_num: 开始区块高度(包括);

end_block_num: 结束区块高度(不包括);

start_block_time: 开始区块时间(包括), 格式为2018-01-01T00:00:00;

end_block_time: 结束区块时间(不包括), 格式为2018-01-01T00:00:00;

sort: 按时间排序(1, DESC 2, ASC) 默认1;

size: 返回记录数, 默认20, 最大100;

page: 页码,默认1, (page-1) * size + size 必须小于 10000.

示例:

直接查询指定合约账户 actions 并设置返回 size 为2:

Node.js 示例:

let request = require("request");

let options = { method: 'POST',
    url: 'https://open-api.eos.blockdog.com/v1/third/get_actions',
    headers:
        { 'content-type': 'application/json',
            apikey: '5b4added-e80c-41fb-b5a9-16269d2de79b',
            accept: 'application/json;charset=UTF-8' },
    body: '{"code":"eosio.token","size":2}' };

request(options, function (error, response, body) {
    if (error) throw new Error(error);

    console.log(body);
});

返回的 JSON 示例:

{
    "total": 968548506,
    "list": [{
        "blockTime": "2019-04-21T03:25:22.500",
        "blockNum": 54063452,
        "account": "eosio.token",
        "name": "transfer",
        "id": "ad61e8fe0bbafc6af1fbb17254ba15a1aa531de1d07e04df513757deee413318",
        "globalSequence": "6341168327",
        "recvSequence": "",
        "status": "executed",
        "data": {
            "quantity": "0.1719 EOS",
            "memo": "bet id:14415544 player: eosjordan winner! - trustdice.win",
            "from": "trustdicewin",
            "to": "txtprotocol1"
        }
    }, {
        "blockTime": "2019-04-21T03:25:22.000",
        "blockNum": 54063451,
        "account": "eosio.token",
        "name": "transfer",
        "id": "bfcaf350a56300ac5d05a2219fa13b5714c544373a9c590f9ebe97e096328f36",
        "globalSequence": "6341168245",
        "recvSequence": "",
        "status": "executed",
        "data": {
            "quantity": "0.0980 EOS",
            "memo": "Crash pool: id 362619, bettor reixr4zjeuud",
            "from": "endlesscrash",
            "to": "endlessbank1"
        }
    }]
}

查询指定合约指定合约动作 actions 并设置返回 size 为2:

Node.js 示例:

let request = require("request");

let options = { method: 'POST',
    url: 'https://open-api.eos.blockdog.com/v1/third/get_actions',
    headers:
        { 'content-type': 'application/json',
            apikey: '5b4added-e80c-41fb-b5a9-16269d2de79b',
            accept: 'application/json;charset=UTF-8' },
    body: '{"code":"eosio","name":"setcode","size":2}' };

request(options, function (error, response, body) {
    if (error) throw new Error(error);

    console.log(body);
});

返回的 JSON 示例:

{
    "total": 37985,
    "list": [{
        "blockTime": "2019-04-21T05:16:45.000",
        "blockNum": 54076814,
        "account": "eosio",
        "name": "setcode",
        "id": "7ad3ca0f4589ee808a10f67c0c525ad3df8d6b780ad0927bea796b8e51dc72cf",
        "globalSequence": "6342722693",
        "recvSequence": "",
        "status": "executed",
        "data": {
            "vmversion": "0",
            "vmtype": "0",
            "account": "eospokefund1"
        }
    }, {
        "blockTime": "2019-04-21T04:26:58.000",
        "blockNum": 54070841,
        "account": "eosio",
        "name": "setcode",
        "id": "76903eee7ddd421212e4b3cb9007987eeb64e361d6418b89e211b62c98bb8262",
        "globalSequence": "6342046342",
        "recvSequence": "",
        "status": "executed",
        "data": {
            "vmversion": "0",
            "vmtype": "0",
            "account": "eospokefund1"
        }
    }]
}

BlockDog API 服务思维导图:

BlockDog API.png

我们有一个区块链知识星球,做区块链前沿资料的归纳整理以方便大家检索查询使用,也是国内顶尖区块链技术社区,欢迎感兴趣的朋友加入。如果你对上面内容有疑问,也可以加入知识星球提问我:

区块链社群 知识星球

你可能感兴趣的:(BlockDog API 查询 EOS actions - 区块链数据开发实战)