Api Doc

Api Base Host

https://api.chainbot.io/api/v1

Channel

查询channel

GET /notify/channels

Parameters

  • current_page int, 当前查询页,从 1 开始计数

  • per_page : int, 每页返回数量

Response

{
    "code": 0,
    "msg": "success",
    "data": {
        "data": [
            {
                "id": 1367,
                "user_id": 2137,
                "name": "Pushover",
                "platform": "Pushover",
                "token": "token",
                "channel": "channel",
                "channel_type": "",
                "is_default": 0,
                "priority": 1,
                "others": null
            },
            {
                "id": 1075,
                "user_id": 2137,
                "name": "Webhook",
                "platform": "Webhook",
                "token": "",
                "channel": "http://webhook.io/url",
                "channel_type": "",
                "is_default": 1,
                "priority": 0,
                "others": null
            }
        ],
        "current_page": 1,
        "per_page": "999",
        "total": 2
    }
}

添加 channel

POST /notify/channels

Parameters

{
    "name": "web",
    "platform": "Webhook",
    "token": "",
    "channel_type": "",
    "channel": "http://webhook.com/url",
    "priority": 0,
    "others": {
        "retryExpire": "0",
        "retryInterval": "0"
    }
}

Response

{
  "code": 0,
  "msg": "success",
  "data": {
    "id": 2879,   // channel id, 在订阅 bot 时需要用到
    "user_id": 2137,
    "name": "Webhook",
    "platform": "Webhook",
    "token": "",
    "channel": "http://sda.dfa",
    "channel_type": "",
    "is_default": 0,
    "priority": 0,
    "others": {}
  }
}

删除 channel

DELETE /notify/channels/{channel_id}

Parameters

  • channel_id

Response

{
    "code": 0,
    "msg": "success",
    "data": {}
}

Bot

创建 bot

POST /bots

Parameters

Address Bot Example

{
    "info": {
        "type": "Wallet",  // address bot 固定为 Wallet
        "name": "address bot",
        "tags": [
            "tag1"  // 标签,统计展示用
        ],
        "status": "Public",   // 可选 Public/Private, 只有 vip 用户允许创建 Private bot 
        "notify_template": "[{$subscription.name}]\nFrom: {$tx.from}\nTo: {$tx.to}\nMethod: {$tx.method}\nStatus: {$tx.status}\nExplore: {$chain.explore}/tx/{$tx.hash}\nTime: {$block.time}",
        "description": "desc"
    },
    "driver": {
        "chains": [
            {
                "chain_id": "1",
                "type": "Ethereum"
            }
        ],
        "addresses": [
            "0x114910771af9ca656af840dff83e8264ecf986ca"
        ],
        "strategies": [
            {
                "func": "eth_transfer",  // 监控 eth 转账
                "params": {
                    "direction": "out",  //可选值 both/out/in
                    "minimum_amount": "100000000000000000000",  //eth金额,单位 wei
                    "minimum_usd": 1   //eth 换算成 usd 金额
                }
            },
            {
                "func": "token_transfer",  // 监控 erc 20 转账
                "params": {
                    "direction": "both",  //可选值 both/out/in
                    "minimum_usd": 6
                }
            },
            {
                "func": "nft_transfer",   // 监控 nft 转账
                "params": {
                    "direction": "both"
                }
            },
            {
                "func": "contract_deploy",  // 监控合约部署
                "params": {}
            },
            {
                "func": "contract_call", // 监控合约调用
                "params": {}
            }
        ]
    }
}

Response

{
  "code": 0,
  "msg": "success",
  "data": {
    "id": "461170869663212058",  // bot id, 创建完成后用来订阅
    "info": {
      "type": "Wallet",
      "name": "address bot",
      "tags": [
        "tag1"
      ],
      "description": "desc",
      "notify_template": "[{$subscription.name}]\nFrom: {$tx.from}\nTo: {$tx.to}\nMethod: {$tx.method}\nStatus: {$tx.status}\nExplore: {$chain.explore}/tx/{$tx.hash}\nTime: {$block.time}",
      "status": "Public"
    },
    "driver": {
      "addresses": [
        "0x114910771af9ca656af840dff83e8264ecf986ca"
      ],
      "chains": [
        {
          "chain_id": "1",
          "type": "Ethereum"
        }
      ],
      "strategies": [
        {
          "func": "eth_transfer",
          "params": {
            "direction": "both",
            "minimum_amount": "0",
            "minimum_usd": 0
          }
        },
        {
          "func": "token_transfer",
          "params": {
            "direction": "both",
            "minimum_usd": 0
          }
        }
      ]
    },
    "subscribe_num": 0,
    "fork_num": 0,
    "view_times": 0,
    "triggered_times": 0,
    "last_trigger_time": 0,
    "readme": "",
    "created_at": "2024-05-09T17:40:29.336Z",
    "user": {},
    "notifies": null,
    "forked_bot": null,
    "original_bot": null,
    "sub_users": null
  }
}

删除 bot

DELETE /bots/{bot_id}

Parameters

  • bot_id

Response

{
    "code": 0,
    "msg": "success",
    "data": {}
}

更新 bot

PUT /bots/{bot_id}

Parameters

Address Bot Example

{
    "info": {
        "type": "Wallet",
        "name": "test address",
        "tags": [],
        "status": "Private",
        "notify_template": "[{$subscription.name}]\nFrom: {$tx.from}\nTo: {$tx.to}\nMethod: {$tx.method}\nStatus: {$tx.status}\nExplore: {$chain.explore}/tx/{$tx.hash}\nTime: {$block.time}\nCreated By chainbot.io",
        "description": ""
    },
    "driver": {
        "chains": [
            {
                "chain_id": "1",
                "type": "Ethereum"
            }
        ],
        "addresses": [
            "0x114910771af9ca656af840dff83e8264ecf986ca"
        ],
        "strategies": [
            {
                "func": "eth_transfer",
                "params": {
                    "direction": "both",
                    "minimum_amount": "0",
                    "minimum_usd": 1
                }
            },
            {
                "func": "token_transfer",
                "params": {
                    "direction": "both",
                    "minimum_usd": 1
                }
            },
            {
                "func": "contract_deploy",
                "params": {}
            }
        ]
    }
}

Response

{
    "code": 0,
    "msg": "success",
    "data": {
        "id": "464062092614790430",
        "info": {
            "type": "Wallet",
            "name": "test address",
            "notify_template": "[{$subscription.name}]\nFrom: {$tx.from}\nTo: {$tx.to}\nMethod: {$tx.method}\nStatus: {$tx.status}\nExplore: {$chain.explore}/tx/{$tx.hash}\nTime: {$block.time}\nCreated By chainbot.io",
            "status": "Private"
        },
        "driver": {
            "addresses": [
                "0x114910771af9ca656af840dff83e8264ecf986ca"
            ],
            "chains": [
                {
                    "chain_id": "1",
                    "type": "Ethereum"
                }
            ],
            "strategies": [
                {
                    "func": "eth_transfer",
                    "params": {
                        "direction": "both",
                        "minimum_amount": "0",
                        "minimum_usd": 1
                    }
                },
                {
                    "func": "token_transfer",
                    "params": {
                        "direction": "both",
                        "minimum_usd": 1
                    }
                },
                {
                    "func": "contract_deploy",
                    "params": {}
                }
            ]
        },
        "subscribe_num": null,
        "fork_num": null,
        "view_times": 0,
        "triggered_times": 0,
        "last_trigger_time": 0,
        "readme": "",
        "created_at": null,
        "user": {},
        "notifies": null,
        "forked_bot": null,
        "original_bot": null,
        "sub_users": null
    }
}

Subscribe

订阅 bot

POST /subscriptions

Parameters

{
  "bot_id": "461170869663212058",  // 需要订阅的 bot id
  "info": {
    "name": "address bot",   // 订阅名称
    "status": "Enabled",  // 固定为Enabled
    "actions": [
      {
        "type": "Notify",  // 固定为 Notify
        "params": {
          "channel_ids": [
            2877    // channel id
          ]
        }
      }
    ],
    "notify": {
      "frequency": "5m", // 推送频率, 可选值Always OnlyOnce 5m 10m 30m 1h 4h 12h 24h
      "template": ""
    }
  },
  "driver": {}  // 已废弃,固定传{}就可以
}

Response

{
    "code": 0,
    "msg": "success",
    "data": {
        "id": "464064078080863518",  //
        "info": {
            "name": "safa",
            "status": "Enabled",
            "actions": [],
            "notify": {
                "frequency": "Always",
                "template": "[{$subscription.name}]\nFrom: {$tx.from}\nTo: {$tx.to}\nMethod: {$tx.method}\nStatus: {$tx.status}\nExplore: {$chain.explore}/tx/{$tx.hash}\nTime: {$block.time}\nCreated By chainbot.io"
            }
        },
        "user_id": 2137,
        "bot_id": "464063535924735262",
        "trigger_times": 0,
        "last_trigger_time": 0,
        "trigger_last_update_at": 1716138672,
        "created_at": "2024-05-19T17:11:12.64Z"
    }
}

取消订阅 bot

DELETE /subscriptions/{subscription_id}

Parameters

  • subscription_id

Response

{
    "code": 0,
    "msg": "success",
    "data": {}
}

最后更新于