返回API列表
竞品网站保存接口
用于保存竞品网站信息到系统。支持从 Traffic.cv 等数据源提取的网站数据。如果域名已存在,将自动更新现有记录;如果不存在,将创建新记录。
POST /api/admin/competitor-websites身份验证
所有API请求都需要在请求头中包含API Key进行身份验证。
请求头格式:
X-API-Key: your_api_key_here请求头
Content-Type: application/json X-API-Key: your_api_key_here 或 Authorization: Bearer your_api_key_here
请求参数
{
"name": "网站名称",
"domain": "example.com",
"description": "网站描述",
"monthlyVisits": "1000000",
"createdDate": "2020-01-01",
"pageCount": 1000,
"pagesPerVisit": 2.5,
"backlinks": 50000,
"publicRevenue": "100000",
"cpmRate": "5.5",
"globalRank": 1000,
"avgDuration": "00:03:30",
"bounceRate": "45.5",
"searchTrafficRatio": "60.5",
"notes": "备注信息",
"tags": "标签1,标签2"
}| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| domain | string | 是 | 网站域名(支持 example.com 或 https://example.com 格式) |
| name | string | 否 | 网站名称 |
| description | string | 否 | 网站描述 |
| monthlyVisits | string/number | 否 | 月访问量 |
| createdDate | string | 否 | 域名创建日期(格式:YYYY-MM-DD) |
| pageCount | number | 否 | 页面数量 |
| pagesPerVisit | number | 否 | 每次访问页面数 |
| backlinks | number | 否 | 外链数量 |
| publicRevenue | string/number | 否 | 公开收入 |
| cpmRate | string/number | 否 | CPM 费率 |
| globalRank | number | 否 | 全球排名 |
| avgDuration | string | 否 | 平均停留时间(格式:HH:MM:SS 或秒数) |
| bounceRate | string/number | 否 | 跳出率(百分比) |
| searchTrafficRatio | string/number | 否 | 搜索流量比例(百分比) |
| notes | string | 否 | 备注信息 |
| tags | string | 否 | 标签(多个标签用逗号分隔) |
响应示例
成功响应(创建新记录)
{
"success": true,
"data": {
"id": 1,
"name": "Example Website",
"domain": "example.com",
"description": "网站描述",
"monthly_visits": "1000000",
"created_date": "2020-01-01T00:00:00.000Z",
"page_count": 1000,
"pages_per_visit": 2.5,
"backlinks": 50000,
"global_rank": 1000,
"avg_duration": 210,
"bounce_rate": 45.5,
"search_traffic_ratio": 60.5,
"notes": "备注信息",
"tags": "标签1,标签2",
"created_at": "2024-01-01T00:00:00.000Z",
"updated_at": "2024-01-01T00:00:00.000Z"
},
"message": "竞品网站创建成功"
}成功响应(更新现有记录)
{
"success": true,
"data": {
"id": 1,
"name": "Updated Website Name",
"domain": "example.com",
...
},
"message": "网站数据已更新"
}错误响应
400 - 参数错误
{
"success": false,
"error": "域名为必填项"
}403 - 无权限
{
"success": false,
"error": "无权限访问"
}代码示例
cURL
curl -X POST https://youzikuaibao.com.cn/api/admin/competitor-websites \
-H "Content-Type: application/json" \
-H "X-API-Key: your_api_key_here" \
-d '{
"name": "Example Website",
"domain": "example.com",
"description": "网站描述",
"monthlyVisits": "1000000",
"globalRank": 1000,
"tags": "标签1,标签2"
}'JavaScript (fetch)
fetch('https://youzikuaibao.com.cn/api/admin/competitor-websites', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': 'your_api_key_here'
},
body: JSON.stringify({
name: 'Example Website',
domain: 'example.com',
description: '网站描述',
monthlyVisits: '1000000',
createdDate: '2020-01-01',
pagesPerVisit: 2.5,
globalRank: 1000,
avgDuration: '00:03:30',
bounceRate: '45.5',
searchTrafficRatio: '60.5',
notes: 'Traffic.cv 数据提取',
tags: '标签1,标签2'
})
})
.then(response => response.json())
.then(data => {
if (data.success) {
console.log(data.message);
console.log('网站ID:', data.data.id);
} else {
console.error('错误:', data.error);
}
})
.catch(error => console.error('Error:', error));Python
import requests
url = 'https://youzikuaibao.com.cn/api/admin/competitor-websites'
headers = {
'Content-Type': 'application/json',
'X-API-Key': 'your_api_key_here'
}
data = {
'name': 'Example Website',
'domain': 'example.com',
'description': '网站描述',
'monthlyVisits': '1000000',
'globalRank': 1000,
'tags': '标签1,标签2'
}
response = requests.post(url, json=data, headers=headers)
result = response.json()
if result.get('success'):
print(result.get('message'))
print('网站ID:', result['data']['id'])
else:
print('错误:', result.get('error'))💡 使用说明
- 域名(domain)是唯一必填字段,其他字段均为可选
- 如果域名已存在,系统会自动更新现有记录,不会创建重复记录
- 支持两种认证方式:X-API-Key 请求头或 Authorization Bearer Token
- monthlyVisits 支持字符串格式(如 "1,000,000")或数字格式
- avgDuration 支持 "HH:MM:SS" 格式或秒数(数字)
- 此接口特别适用于 Traffic.cv 浏览器插件的数据保存
