REST API 参考
Base URL: https://api.sybilslayer.com/api/v1
所有请求需在 Header 中携带认证令牌(除 /system/health 外):
Authorization: Bearer <token>System
GET /system/health
健康检查(无需认证)。
Response:
{ "status": "ok", "timestamp": "2026-02-11T10:00:00.000Z" }GET /system/countries
获取可用国家/地区列表及资源统计。
Response:
{
"countries": [
{
"code": "JP",
"fingerprints": 150,
"proxies_available": 45
}
],
"proxies_available": 320
}GET /system/version
获取各客户端版本信息(Desktop、Chrome)。
Response:
{
"versions": {
"client": {
"version": "1.0.46",
"download_url": "...",
"release_notes": "...",
"released_at": "..."
},
"chrome": {
"version": "1.0.28",
"download_url": "..."
}
}
}Auth
POST /auth/login
用户名密码登录。
Request Body:
{
"username": "alice",
"password": "secret123"
}Response:
{
"token": "64位hex",
"user": {
"id": 1,
"username": "alice",
"email": "[email protected]",
"status": "active"
},
"quota": {
"total": 100,
"used": 5,
"remaining": 95
}
}User
GET /user/profile
获取当前用户信息和配额。
Response:
{
"user": {
"id": 1,
"username": "alice",
"email": "[email protected]",
"status": "active"
},
"quota": {
"total": 100,
"used": 5,
"remaining": 95
},
"stats": {
"environments": 5,
"tokens": 2
}
}Environment
POST /env/create
创建新的浏览器环境。
Request Body:
{
"country": "JP",
"name": "my-environment",
"platform": "windows",
"note": "测试环境"
}| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
country | string | 是 | 国家代码 (JP, US, KR 等) |
name | string | 否 | 环境名称 |
platform | string | 否 | 平台类型 |
note | string | 否 | 备注 |
Response:
{
"env_id": "env_abc123",
"country": "JP",
"proxy": "socks5://user:pass@ip:port",
"quota_remaining": 94,
"profile": { "profileId": "...", "envId": "...", "base": { ... } }
}GET /env/list
分页获取环境列表。
Query Parameters: page (default: 1), limit (default: 20)
Response:
{
"environments": [
{
"env_id": "env_abc123",
"name": "my-env",
"country": "JP",
"proxy": "...",
"note": "测试环境",
"status": "active",
"created_at": "..."
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 50,
"pages": 3
}
}GET /env/:env_id
获取单个环境详情(包含完整 profile)。
PATCH /env/:env_id
更新环境备注或名称。
Request Body:
{
"note": "新备注",
"name": "新名称"
}| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
note | string | 否 | 环境备注 |
name | string | 否 | 环境名称 |
至少传一个字段。
Response:
{
"env_id": "env_abc123",
"updated": ["note", "name"]
}DELETE /env/:env_id
删除指定环境。
Response:
{ "message": "Environment deleted" }POST /env/:env_id/refresh-proxy
刷新环境代理。
Request Body (可选):
{ "reason": "proxy_failed" }Response:
{
"env_id": "env_abc123",
"country": "JP",
"proxy": "socks5://new-proxy:port"
}POST /env/:env_id/report-proxy-dead
上报代理失效。
Request Body:
{
"consecutive_failures": 3,
"reason": "timeout"
}POST /env/admin/proxy/release-stale
释放过期的 MySQL 代理绑定(需管理员权限)。默认 dry_run=true,仅预览不执行。
Request Body:
{
"countries": ["JP", "US"],
"max_age_minutes": 180,
"only_online": true,
"dry_run": true
}| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
countries | string[] | 否 | 国家代码列表(不传则全部) |
max_age_minutes | number | 否 | 绑定最大存活分钟数(默认 180) |
only_online | boolean | 否 | 仅释放在线代理的绑定(默认 true) |
dry_run | boolean | 否 | 仅预览不执行(默认 true) |
Response (dry_run=true):
{
"trace_id": "proxy-abc12345",
"dry_run": true,
"max_age_minutes": 180,
"only_online": true,
"countries": ["JP", "US"],
"matched": 25,
"preview": [
{ "country": "JP", "locked_count": 15 },
{ "country": "US", "locked_count": 10 }
],
"threshold_utc": "2026-03-13T07:00:00"
}Response (dry_run=false):
{
"trace_id": "proxy-abc12345",
"dry_run": false,
"max_age_minutes": 180,
"only_online": true,
"countries": ["JP", "US"],
"matched": 25,
"released": 25,
"preview": [
{ "country": "JP", "locked_count": 15 },
{ "country": "US", "locked_count": 10 }
],
"threshold_utc": "2026-03-13T07:00:00"
}POST /env/admin/proxy/migrate-bindings
将旧 proxy_servers.env_id 迁移到 proxy_bindings 表(分批执行,需管理员权限)。默认 dry_run=true。
Request Body:
{
"dry_run": true,
"offset": 0,
"batch_size": 200
}| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
dry_run | boolean | 否 | 仅预览不执行(默认 true) |
offset | number | 否 | 分页偏移量(默认 0) |
batch_size | number | 否 | 每批数量(1-500,默认 200) |
Response (dry_run=true):
{
"trace_id": "proxy-abc12345",
"dry_run": true,
"total": 846,
"offset": 0,
"batch_size": 200,
"to_insert": 195,
"skipped": 5,
"has_more": true
}Response (dry_run=false):
{
"trace_id": "proxy-abc12345",
"dry_run": false,
"total": 846,
"offset": 0,
"batch_size": 200,
"inserted": 195,
"skipped": 5,
"has_more": true,
"next_offset": 200
}Download
GET /download/client
下载 Desktop 客户端(自动检测最新版本)。
GET /download/chrome
下载 Chrome 内核(自动检测最新版本)。
GET /download/chrome/info
获取 Chrome 内核版本信息(不下载)。
Admin
WARNING
以下接口需要管理员权限的 Token。
GET /admin/users
分页获取用户列表。
Query Parameters: page, limit
POST /admin/users
创建新用户。
Request Body:
{
"username": "alice",
"email": "[email protected]",
"password": "optional-password",
"quota_total": 20
}PUT /admin/users/:id
更新用户信息(配额、密码、状态、邮箱)。至少传一个字段。
Request Body:
{
"quota_total": 50,
"password": "new-password",
"status": "active",
"email": "[email protected]"
}| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
quota_total | number | 否 | 配额总量(>= 0) |
password | string | 否 | 新密码 |
status | string | 否 | active 或 suspended |
email | string | 否 | 新邮箱 |
Response:
{
"id": 1,
"username": "alice",
"email": "[email protected]",
"quota_total": 50,
"quota_used": 5,
"status": "active"
}DELETE /admin/users/:id
删除用户及其关联数据(Token、环境、日志等级联删除)。
Response:
{
"id": 1,
"username": "alice",
"deleted": true
}POST /admin/users/batch-generate
批量生成测试账户(用于迁移/运维)。
Request Body:
{
"high_quota_count": 2,
"high_quota_value": 200,
"normal_count": 10,
"normal_quota_value": 2,
"username_prefix": "test",
"email_domain": "example.com",
"password": "optional-shared-password"
}| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
high_quota_count | number | 否 | 高配额用户数量(默认 2) |
high_quota_value | number | 否 | 高配额值(默认 200) |
normal_count | number | 否 | 普通用户数量(10-20,默认 10) |
normal_quota_value | number | 否 | 普通配额值(默认 2) |
username_prefix | string | 否 | 用户名前缀 |
email_domain | string | 否 | 邮箱域名 |
password | string | 否 | 共享密码(不传则无密码) |
Response:
{
"trace_id": "admin-batch-users-abc12345",
"requested": {
"high_quota_count": 2,
"high_quota_value": 200,
"normal_count": 10,
"normal_quota_value": 2
},
"summary": {
"requested": 12,
"created": 12,
"failed": 0
},
"users": [
{
"id": 101,
"username": "test_87654321_1",
"email": "[email protected]",
"quota_total": 200,
"quota_used": 0,
"status": "active",
"has_password": true,
"tier": "high"
}
],
"failures": []
}GET /admin/users/uuid-ip-map
导出环境 UUID 与代理 IP 的映射表,支持 JSON 和 CSV 格式。
Query Parameters:
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
format | string | 否 | json(默认)或 csv |
include_inactive | string | 否 | 是否包含非活跃环境(true/false,默认 false) |
limit | number | 否 | 最大条数(默认 5000,上限 20000) |
Response (format=json):
{
"trace_id": "admin-uuid-ip-abc12345",
"total": 100,
"mapped": 95,
"unresolved": 5,
"items": [
{
"env_id": "env_abc123",
"uuid": "abc123",
"ip": "1.2.3.4",
"user_id": 1,
"username": "alice",
"email": "[email protected]",
"country": "JP",
"status": "active",
"proxy": "socks5://user:[email protected]:1080",
"updated_at": "2026-03-01T00:00:00.000Z"
}
]
}Response (format=csv): 返回 CSV 文件下载(Content-Disposition: attachment)。
GET /admin/tokens
分页获取 Token 列表。
POST /admin/tokens
创建新 Token。
Request Body:
{
"user_id": 1,
"name": "ci-key",
"expires_in_days": 90
}DELETE /admin/tokens/:id
撤销指定 Token。
GET /admin/proxies
获取代理列表。
Query Parameters: country, status, limit
GET /admin/proxies/stats
获取代理统计信息(总量、可用、按国家分组、补货建议)。
POST /admin/proxies/recheck
批量重新检查代理健康状态。
Request Body:
{
"country": "JP",
"limit": 50
}POST /admin/proxies/import-csv
CSV 格式批量导入代理。
Request Body:
{
"csv": "JP,socks5://1.2.3.4:1080\nUS,http://5.6.7.8:8080",
"default_country": "US"
}POST /admin/proxies/import
JSON 格式批量导入代理。
Request Body:
{
"items": [
{ "country": "JP", "proxy_url": "socks5://1.2.3.4:1080" }
]
}POST /admin/templates/import
批量导入指纹模板。
POST /admin/fingerprints/import
批量导入指纹数据。
GET /admin/fingerprints/stats
获取指纹统计信息。
GET /admin/country-matrix
获取国家就绪矩阵(模板 + 代理可用性)。
Response:
{
"min_templates_per_country": 100,
"templates_total": 5000,
"proxies_total": 150,
"countries": [
{
"code": "JP",
"fingerprints": 500,
"proxies_available": 45,
"ok_templates": true,
"ok_proxies": true,
"ok": true
}
]
}