返回API列表
外链查询接口
根据来源URL查询外链记录。支持多种URL格式,自动提取域名。返回前5条高质量外链记录,按质量评分和权重排序。
POST /api/admin/backlinks/query-by-source身份验证
所有API请求都需要在请求头中包含API Key进行身份验证。
请求头格式:
X-API-Key: your_api_key_here接口特点
- 智能域名提取:自动从URL中提取域名,支持多种格式
- 兼容性强:无论是完整URL、带协议、带www,还是仅域名,都能正确查询
- 高质量优先:按质量评分和页面权重排序,优先返回最优质的外链
- 限制返回:最多返回5条记录,避免数据过多
请求头
Content-Type: application/json X-API-Key: your_api_key_here
请求参数
{
"sourceUrl": "https://www.yourchatrooms.com"
}sourceUrlstring (必填) - 来源URL,支持多种格式
支持的URL格式
接口会自动提取域名,以下所有格式都会查询相同的结果:
| 输入格式 | 示例 | 提取的域名 |
|---|---|---|
| HTTPS完整URL(带www) | https://www.yourchatrooms.com | yourchatrooms.com |
| HTTPS完整URL(不带www) | https://yourchatrooms.com | yourchatrooms.com |
| HTTP完整URL(带www) | http://www.yourchatrooms.com | yourchatrooms.com |
| HTTP完整URL(不带www) | http://yourchatrooms.com | yourchatrooms.com |
| 仅域名 | yourchatrooms.com | yourchatrooms.com |
| 带www的域名 | www.yourchatrooms.com | yourchatrooms.com |
响应示例
{
"success": true,
"data": [
"https://www.yourchatrooms.com/blog/post-1",
"https://www.yourchatrooms.com/articles/article-2",
"https://yourchatrooms.com/page-3",
"https://www.yourchatrooms.com/category/seo",
"https://yourchatrooms.com/guides/guide-5"
],
"domain": "yourchatrooms.com",
"count": 5
}响应字段说明
| 字段 | 类型 | 说明 |
|---|---|---|
| data | array[string] | fromUrl数组,最多5条URL记录 |
| domain | string | 提取的域名 |
| count | number | 返回的URL数量 |
排序规则
返回的记录按以下优先级排序:
- 质量评分(qualityScore)降序
- 页面权重(pageAuthority)降序
- 创建时间(createdAt)降序
错误响应
403 - 无权限
{
"success": false,
"error": "无权限访问"
}400 - 参数错误
{
"success": false,
"error": "sourceUrl参数不能为空"
}500 - 服务器错误
{
"success": false,
"error": "查询外链失败",
"message": "错误详情"
}代码示例
cURL
curl -X POST https://youzikuaibao.com.cn/api/admin/backlinks/query-by-source \
-H "Content-Type: application/json" \
-H "X-API-Key: your_api_key_here" \
-d '{"sourceUrl": "https://www.yourchatrooms.com"}'Python
import requests
url = "https://youzikuaibao.com.cn/api/admin/backlinks/query-by-source"
headers = {
"Content-Type": "application/json",
"X-API-Key": "your_api_key_here"
}
data = {
"sourceUrl": "https://www.yourchatrooms.com"
}
response = requests.post(url, json=data, headers=headers)
result = response.json()
if result['success']:
print(f"找到 {result['count']} 条记录,域名: {result['domain']}")
for url in result['data']:
print(f"- {url}")
else:
print(f"错误: {result['error']}")JavaScript (fetch)
fetch('https://youzikuaibao.com.cn/api/admin/backlinks/query-by-source', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': 'your_api_key_here'
},
body: JSON.stringify({
sourceUrl: 'https://www.yourchatrooms.com'
})
})
.then(response => response.json())
.then(result => {
if (result.success) {
console.log(`找到 ${result.count} 条记录,域名: ${result.domain}`);
result.data.forEach(url => {
console.log(`- ${url}`);
});
} else {
console.error('错误:', result.error);
}
})
.catch(error => console.error('请求失败:', error));注意事项
- 权限要求:该接口需要管理员权限,请确保请求包含有效的API Key
- 返回限制:最多返回5条记录,如果需要更多数据,请使用其他API接口
- 域名匹配:使用模糊匹配(LIKE %domain%),会匹配包含该域名的所有URL
- 已删除记录:不会返回 is_deleted = true 的记录
