认证方式
所有API请求都需要在请求头中携带Token进行认证:
Authorization: Bearer YOUR_API_TOKEN
获取Token:发送POST请求到 /api/auth/login,传入用户名和密码。
{
"username": "your_username",
"password": "your_password"
}
// 响应
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expires_in": 86400
}
基础URL
https://api.aiyunying.com/v1
所有API端点都在此基础上拼接。
请求示例
cURL
curl -X GET "https://api.aiyunying.com/v1/agents" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json"
Python
import requests
url = "https://api.aiyunying.com/v1/agents"
headers = {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
}
response = requests.get(url, headers=headers)
print(response.json())
JavaScript
const response = await fetch('https://api.aiyunying.com/v1/agents', {
method: 'GET',
headers: {
'Authorization': 'Bearer YOUR_TOKEN',
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);