receive/block_notificatoin - 监听新区块通知
使用receive/block_notificatoin
调用监听新区块通知。
API调用
POST v2/receive/block_notificatoin
表单参数:
- callback:回调URL,注意要先将该URL进行url编码处理
- key:blockchain.info的v2支付api密钥,点击这里申请密钥:https://api.blockchain.info/v2/apikey/request/
- onNotification:请求通知行为,KEEP或DELETE
- confs:发送通知前区块需要的最小确认数,可选,默认值:1
- height:发送通知的区块高度,可选,默认值:当前区块高度+1
API返回值
返回新创建的监听请求,主要字段如下:
- id:监听请求id
- height:通知发送区块高度
- callback:回调URL
- confs:通知前区块需要达到的最小确认数
- onNotification:通知处理行为
示例代码
使用curl调用receive/block_notificatoin
的示例代码如下:
curl -H "Content-Type: text/plain" --data '{"key":"[your-key-here]","height":500000,"callback":"https://mysite.com/block?request_id=1234","onNotification":"DELETE"}' https://api.blockchain.info/v2/receive/block_notification
返回值:
{
"id" : 64,
"height" : 500000,
"callback" : "https://mysite.com/block?request_id=1234",
"confs" : 1,
"onNotification" : "DELETE"
}
响应中的id可用来删除请求,例如:
curl -X DELETE "https://api.blockchain.info/v2/receive/block_notificatoin/70?key=[your-key-here]"
将得到如下响应:
{ "deleted": true }