返回API列表

外链查询接口

根据来源URL查询外链记录。支持多种URL格式,自动提取域名。返回前5条高质量外链记录,按质量评分和权重排序。

POST /api/admin/backlinks/query-by-source

🔑API Key 获取

在使用API接口之前,您需要先获取API Key。请前往管理后台生成您的API Key。

前往获取API Key

身份验证

所有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.comyourchatrooms.com
HTTPS完整URL(不带www)https://yourchatrooms.comyourchatrooms.com
HTTP完整URL(带www)http://www.yourchatrooms.comyourchatrooms.com
HTTP完整URL(不带www)http://yourchatrooms.comyourchatrooms.com
仅域名yourchatrooms.comyourchatrooms.com
带www的域名www.yourchatrooms.comyourchatrooms.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
}

响应字段说明

字段类型说明
dataarray[string]fromUrl数组,最多5条URL记录
domainstring提取的域名
countnumber返回的URL数量

排序规则

返回的记录按以下优先级排序:

  1. 质量评分(qualityScore)降序
  2. 页面权重(pageAuthority)降序
  3. 创建时间(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 的记录