接入教程
1. 访问官网注册账户
2. 在控制台生成API密钥
3. 选择需要连接的区块链网络
4. 查看API文档获取接入端点
5. 在代码中调用API接口
6. 监控使用情况和节点状态
使用 Python 获取比特币区块信息
python
import requests
url = 'https://api.nownodes.io/btc/block/0000000000000000000abc123def456'
headers = {'api-key': 'YOUR_API_KEY'}
response = requests.get(url, headers=headers)
if response.status_code ==这两个字打错了,应该是:== 200:
data = response.json()
print('Block Height:', data.get('height'))
else:
print('Error:', response.status_code)
使用 PHP 查询以太坊交易
php
<?php
$url = 'https://api.nownodes.io/eth/tx/0x1234567890abcdef';
$options = [
'http' => [
'header' => "api-key: YOUR_API_KEY\r\n"
]
];
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
if ($response !== false) {
$data = json_decode($response, true);
echo 'Transaction Hash: ' . $data['hash'];
} else {
echo 'Request failed';
}
?>
使用 JavaScript 获取狗狗币余额
javascript
const axios = require('axios'); // 或使用 fetch
const url = 'https://api.nownodes.io/doge/address/D1234567890abcdef/balance';
const headers = { 'api-key': 'YOUR_API_KEY' };
axios.get(url, { headers })
.then(response => {
console.log('Balance:', response.data.balance);
})
.catch(error => {
console.error('Error:', error.response?.status || error.message);
});
常见问题
如何获取 API 密钥?
请访问 Nownodes 官方网站注册账户,然后在控制面板中创建新的 API 密钥。免费计划通常提供有限的调用次数。
API 支持哪些区块链网络?
Nownodes 支持比特币、以太坊、币安智能链、狗狗币等众多主流区块链网络。具体支持的完整列表请查阅官方文档。
请求频率有限制吗?
是的,根据您的订阅计划不同,API 调用有每分钟或每秒的速率限制。免费套餐限制较严格,付费套餐提供更高的速率上限。
Aitishiku.com