跳至主要內容

NFT 订阅

tokenview大约 6 分钟

NFT 订阅

NFT 订阅提供链上 NFT 铸造、NFT交易、NFT 买入、NFT 卖出和 NFT 销毁等通知信息,实时跟踪 NFT 市场趋势。

支持的订阅方式:
订阅账户、Token、Collection、Event。

推送的消息格式:
Tokenview 后台系统会把Json 格式的交易消息 POST 到您设置的 Webhook URL。您的服务器收到通知后,响应码需是200,并且应答body里必须返回非空文本信息,比如 ok。如发送失败,会自动重试 3 次。

余额变化推送的消息为 json 文本, 格式如下
{
  "address": "0x61817a240633211eda35ead95222b1cfab0ff143", // 被监控地址hash
  "amount": "1", // NFT余额转移数量
  "height": "16118078", // 交易被打包的区块高度
  "network": "ETH", // 交易发生在哪条链上
  "nftid": "5", // NFT id
  "time": "1670236955", // 交易发生时间UTC
  "tokenAddress": "0x5c891d76584b46bc7f1e700169a76569bb77d2db", // token的地址
  "txType": "Receive", // 交易类型
  "txid": "0x0e171fd0d64733f42f7eec5d20f89eebb818d0bdd93703eb4946c2095ecba356", // 交易hash
  "type": "rc1155" // token地址类型
}

订阅的步骤:

  • 设置webhook url
  • 按照订阅方式添加相应的订阅对象
  • 接收推送的消息

Webhook 签名 & 安全

为了确保您的 Webhook 安全,您可以使用您唯一的 Webhook 签名密钥生成 HMAC SHA-256 哈希码来验证它们是否来自 Tokenview。

如何获取 signing key

导航至 services 后台的项目设置open in new window页面。 单击“获取”:将显示签名密钥并可以复制以供使用。 获取SignKey

验证收到的签名

每个出站请求的header中都包含经过哈希处理的身份验证签名(X-Tokenview-Signature)。它是通过将您的签名密钥和请求正文连接在一起来计算的。 然后使用 HMAC SHA256 哈希算法生成一个哈希值。
为了验证签名来自 Tokenview,您需要生成 HMAC SHA256 哈希并将其与收到的签名进行比较。

请求头示例
Content-Type: application/json;charset=UTF-8
X-Tokenview-Signature: your-hashed-signature

签名验证示例(python)
import hmac
import hashlib
# abcde是要加密的内容,即webhook消息的body
data=bytes('abcde','utf-8')
key=bytes('signkey string','utf-8')
# digest为signature,即X-Tokenview-Signature的值
digest=hmac.new(key,data,digestmod=hashlib.sha256).hexdigest()
print(digest) 

设置 webhook URL

POST https://services.tokenview.io/vipapi/nftmonitor/setwebhookurl?apikey={apikey}'

参数

Request

curl -X POST -H 'content-type:text/plain' -d '{your_webhook_url}' 'https://services.tokenview.io/vipapi/nftmonitor/setwebhookurl?apikey={apikey}'

Response

{
    "code": 1,
    "msg": "success",
    "data": null
}

查询 webhook URL

GET https://services.tokenview.io/vipapi/nftmonitor/getwebhookurl?apikey={apikey}

参数

Request

curl --location https://services.tokenview.io/vipapi/nftmonitor/getwebhookurl?apikey={apikey}

Response

{
    "code": 1,
    "msg": "success",
    "data": "https://9aa90255-9cde-453e-83a6-2916cd2c3725.mock.pstmn.io/webhook"
}

增加一个订阅地址

GET https://services.tokenview.io/vipapi/nftmonitor/address/add/{公链简称小写}/{地址}?apikey={apikey}

参数

ETH链:请务必将地址HASH或交易HASH中的大写字母转化为小写字母。

Request

curl --location https://services.tokenview.io/vipapi/nftmonitor/address/add/eth/0x21c0afc5d6110323f04b369788e78fb60bfa02b8?apikey={apikey}

Response

{
    "code": 1,
    "msg": "success",
    "data": null
}

查询已经订阅的地址列表

GET https://services.tokenview.io/vipapi/nftmonitor/address/list/{公链简称小写}?page={页码}&apikey={apikey}

参数

备注:

需指定公链简称小写和页码。

Request

curl --location https://services.tokenview.io/vipapi/nftmonitor/address/list/eth?page=1&apikey={apikey}

Response

{
    "code": 1,
    "msg": "success",
    "data": {
        "page": 1,
        "size": 3,
        "total": 3,
        "list": [
            "0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c",
            "0xab5c66752a9e8167967685f1450532fb96d5d24f",
            "0xea674fdde714fd979de3edf0f56aa9716b898ec8"
        ]
    }
}

删除一个订阅地址

GET https://services.tokenview.io/vipapi/nftmonitor/address/remove/{公链简称小写}/{地址hash}?apikey={apikey}

参数

备注:

ETH链:请务必将地址HASH或交易HASH中的大写字母转化为小写字母。

Request

curl --location https://services.tokenview.io/vipapi/nftmonitor/address/remove/eth/0x21c0afc5d6110323f04b369788e78fb60bfa02b8?apikey={apikey}

Response

{
    "code": 1,
    "msg": "success",
    "data": null
}

增加一个订阅Token

GET https://services.tokenview.io/vipapi/nftmonitor/address/add/{公链简称小写}/{Collection-TokenID}?apikey={apikey}

参数

Request

curl --location https://services.tokenview.io/vipapi/nftmonitor/address/add/eth/0x7fda36c8daedcc55b73e964c2831d6161ef60a75-9459?apikey={apikey}

Response

{
    "code": 1,
    "msg": "success",
    "data": null
}

查询已经订阅的Token列表

GET https://services.tokenview.io/vipapi/nftmonitor/address/list/{公链简称小写}?page={页码}&apikey={apikey}

参数

备注:

需指定公链简称小写和页码。

Request

curl --location https://services.tokenview.io/vipapi/nftmonitor/address/list/eth?page=1&apikey={apikey}

Response

{
    "code": 1,
    "msg": "success",
    "data": {
        "page": 1,
        "size": 2,
        "total": 2,
        "list": [
            "0x7fda36c8daedcc55b73e964c2831d6161ef60a75-9459",
            "0xebf39b3ee65a7fb265918af8f94010083d14fd37-309"
        ]
    }
}

删除一个订阅Token

GET https://services.tokenview.io/vipapi/nftmonitor/address/remove/{公链简称小写}/{Collection-TokenID}?apikey={apikey}

参数

备注:

ETH链:请务必将地址HASH或交易HASH中的大写字母转化为小写字母。

Request

curl --location https://services.tokenview.io/vipapi/nftmonitor/address/remove/eth/0x7fda36c8daedcc55b73e964c2831d6161ef60a75-9459?apikey={apikey}

Response

{
    "code": 1,
    "msg": "success",
    "data": null
}

增加一个订阅Collection

GET https://services.tokenview.io/vipapi/nftmonitor/address/add/{公链简称小写}/{Collection}?apikey={apikey}

参数

Request

curl --location https://services.tokenview.io/vipapi/nftmonitor/address/add/eth/0xc6dca8e9c9eb5a7eb68b04a69e63352d5d98695c?apikey={apikey}

Response

{
    "code": 1,
    "msg": "success",
    "data": null
}

查询已经订阅的Collection列表

GET https://services.tokenview.io/vipapi/nftmonitor/address/list/{公链简称小写}?page={页码}&apikey={apikey}

参数

备注:

需指定公链简称小写和页码。

Request

curl --location https://services.tokenview.io/vipapi/nftmonitor/address/list/eth?page=1&apikey={apikey}

Response

{
    "code": 1,
    "msg": "success",
    "data": {
        "page": 1,
        "size": 4,
        "total": 4,
        "list": [
            "0x253ef258563e146f685e60219da56a6b75178e19",
            "0x5878940a0fd83a9c9a0f7624f874590688c970f1",
            "0xc6dca8e9c9eb5a7eb68b04a69e63352d5d98695c",
            "0xf19bbc0dd171256c0c0eacf27adceab0f86b36d8"
        ]
    }
}

删除一个订阅Collection

GET https://services.tokenview.io/vipapi/nftmonitor/address/remove/{公链简称小写}/{Collection}?apikey={apikey}

参数

{公链简称小写}:eth
{Collection}:链上NFT合约地址
{apikey}: 可在Tokenview API 后台管理系统获取激活状态的 APIKEY: https://services.tokenview.ioopen in new window

备注:

需指定公链简称小写

Request

curl --location https://services.tokenview.io/vipapi/nftmonitor/address/remove/eth/0xc6dca8e9c9eb5a7eb68b04a69e63352d5d98695c?apikey={apikey}

Response

{
    "code": 1,
    "msg": "success",
    "data": null
}

查询 webhook 调用历史

GET https://services.tokenview.io/vipapi/nftmonitor/webhookhistory/{公链简称小写}?page={页码}apikey={apikey}

参数

备注:

  • 需指定公链简称小写和页码。
  • 返回指定公链所有的调用记录,不能指定查询单个地址调用记录。
  • 每页返回固定100条调用记录。

Request

curl --location https://services.tokenview.io/vipapi/nftmonitor/webhookhistory/eth?page=1&apikey={apikey}

Response

{
  "code": 1,
  "msg": "success",
  "data": {
    "page": 1,
    "size": 2,
    "total": 2,
    "list": [
      {
        "coin": "ETH",
        "height": 16118080,
        "time": 1670236979,
        "txid": "0x86614fbd734f5bb06fc6bf0dfeee279ff01a7c6e0cfe2523786b4499c7f914f2",
        "address": "0x61817a240633211eda35ead95222b1cfab0ff143",
        "tryTimes": 0,
        "url": "http://51.62.146.153:3010/nftmonitor",
        "statusCode": 200,
        "request": "{\"address\":\"0x61817a240633211eda35ead95222b1cfab0ff143\",\"amount\":\"1\",\"height\":\"16118080\",\"network\":\"ETH\",\"nftid\":\"5\",\"time\":\"1670236979\",\"tokenAddress\":\"0x5c891d76584b46bc7f1e700169a76569bb77d2db\",\"tokenSymbol\":\"OKXFC\",\"txType\":\"Receive\",\"txid\":\"0x86614fbd734f5bb06fc6bf0dfeee279ff01a7c6e0cfe2523786b4499c7f914f2\",\"type\":\"rc1155\"}",
        "response": "ok"
      },
      {
        "coin": "ETH",
        "height": 16118078,
        "time": 1670236955,
        "txid": "0x0e171fd0d64733f42f7eec5d20f89eebb818d0bdd93703eb4946c2095ecba356",
        "address": "0x61817a240633211eda35ead95222b1cfab0ff143",
        "tryTimes": 0,
        "url": "http://51.62.146.153:3010/nftmonitor",
        "statusCode": 200,
        "request": "{\"address\":\"0x61817a240633211eda35ead95222b1cfab0ff143\",\"amount\":\"1\",\"height\":\"16118078\",\"network\":\"ETH\",\"nftid\":\"5\",\"time\":\"1670236955\",\"tokenAddress\":\"0x5c891d76584b46bc7f1e700169a76569bb77d2db\",\"txType\":\"Receive\",\"txid\":\"0x0e171fd0d64733f42f7eec5d20f89eebb818d0bdd93703eb4946c2095ecba356\",\"type\":\"rc1155\"}",
        "response": "ok"
      }
    ]
  }
}

应答字段说明

{
  "address": "0x61817a240633211eda35ead95222b1cfab0ff143", // 被监控地址hash
  "amount": "1", // NFT余额转移数量
  "height": "16118078", // 交易被打包的区块高度
  "network": "ETH", // 交易发生在哪条链上
  "nftid": "5", // NFT id
  "time": "1670236955", // 交易发生时间UTC
  "tokenAddress": "0x5c891d76584b46bc7f1e700169a76569bb77d2db", // token的地址
  "txType": "Receive", // 交易类型
  "txid": "0x0e171fd0d64733f42f7eec5d20f89eebb818d0bdd93703eb4946c2095ecba356", // 交易hash
  "type": "rc1155" // token地址类型
}

上次编辑于: