接口端点
URL: https://api.newcoin.top/api/usage/token
方法: GET
认证: Bearer Token (Authorization头)
示例请求头:
Authorization: Bearer sk-BRLP2O425IpO3TzIZcT8n9p7QiIp9PhYZS6Sk2WTS0EjtuIR
Content-Type: application/json
Python调用示例
import requests
# API端点
url = "https://api.newcoin.top/api/usage/token"
# Bearer Token
bearer_token = "sk-BRLP2O425IpO3TzIZcT8n9p7QiIp9PhYZS6Sk2WTS0EjtuIR"
# 设置请求头
headers = {
"Authorization": f"Bearer {bearer_token}"
}
# 发送GET请求
try:
response = requests.get(url, headers=headers)
# 打印状态码
print(f"状态码: {response.status_code}")
# 检查响应
if response.status_code == 200:
# 成功,打印响应内容
print("响应内容:")
print(response.json()) # 如果返回的是JSON
else:
# 失败,打印错误信息
print(f"请求失败: {response.status_code}")
print(f"响应内容: {response.text}")
except requests.exceptions.RequestException as e:
print(f"请求异常: {e}")
JavaScript调用示例
const token = "sk-BRLP2O425IpO3TzIZcT8n9p7QiIp9PhYZS6Sk2WTS0EjtuIR";
const url = "https://api.newcoin.top/api/usage/token";
fetch(url, {
method: 'GET',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
}
})
.then(response => {
if (!response.ok) {
throw new Error(`HTTP错误: ${response.status}`);
}
return response.json();
})
.then(data => {
console.log('API响应:', data);
// 处理数据...
})
.catch(error => {
console.error('请求失败:', error);
});