API 文档
通过本地设备 API(端口 5200)与远程服务器 API 集成 NodeCoreX。远程请求需要基于账号、密码、机器码和时间戳生成的 SHA-256 签名。
本地设备 API
基础 URL: http://localhost:5200
GET
http://localhost:5200/nodes/count 获取节点数量
获取当前节点上运行的广告节点总数。
成功(HTTP 200):
{
"success": true,
"count": 4
} 错误(非 200):
{
"success": false,
"message": "Service unavailable"
} GET
http://localhost:5200/nodes/list 获取节点索引列表
获取全部节点索引列表,以便后续按索引执行操作。
成功(HTTP 200):
{
"success": true,
"nodeIndexes": [
0,
1,
2,
3
]
} 错误(非 200):
{
"success": false,
"message": "Failed to list nodes"
} GET
http://localhost:5200/nodes/status 获取节点状态
获取每个节点的运行状态(运行中、已停止、错误等)。
成功(HTTP 200):
{
"success": true,
"statuses": [
{
"index": 0,
"status": "running",
"uptime": 3600
},
{
"index": 1,
"status": "stopped",
"uptime": 0
},
{
"index": 2,
"status": "error",
"message": "Proxy timeout"
}
]
} 错误(非 200):
{
"success": false,
"message": "Unable to read node status"
} POST
http://localhost:5200/nodes/{nodeIndex}/start 启动节点
启动指定节点索引对应的广告播放节点。
参数:
-
nodeIndex(path) — 节点索引(从 0 开始)
成功(HTTP 200):
{
"success": true,
"message": "Node started",
"index": 0
} 错误(非 200):
{
"success": false,
"message": "Invalid node index or already running"
} POST
http://localhost:5200/nodes/{nodeIndex}/stop 停止节点
停止指定节点索引对应的广告播放节点。
参数:
-
nodeIndex(path) — 节点索引(从 0 开始)
成功(HTTP 200):
{
"success": true,
"message": "Node stopped",
"index": 0
} 错误(非 200):
{
"success": false,
"message": "Invalid node index or already stopped"
} POST
http://localhost:5200/nodes/{nodeIndex}/proxy 为节点设置代理
为指定节点索引配置代理连接(主机、端口、认证等)。
参数:
-
nodeIndex(path) — 节点索引 -
ip(body) — 代理地址 -
port(body) — 代理端口 -
username(body) — 代理用户名(可选) -
password(body) — 代理密码(可选)
请求体示例:
{
"ip": "127.0.0.1",
"port": 7890,
"username": null,
"password": null
} 成功(HTTP 200):
{
"success": true,
"message": "Proxy updated",
"index": 0
} 错误(非 200):
{
"success": false,
"message": "Invalid proxy or connection failed"
} GET
http://localhost:5200/device/info 获取节点信息
获取节点基础信息,例如节点码、型号和版本。
成功(HTTP 200):
{
"success": true,
"machineCode": "PM-XXXX-YYYY",
"model": "Standard",
"version": "1.0.0",
"firmware": "1.2.3"
} 错误(非 200):
{
"success": false,
"message": "Node info unavailable"
} GET
http://localhost:5200/device/health 节点健康检查
检查本地服务是否正在运行;可用于心跳上报。
成功(HTTP 200):
{
"success": true,
"healthy": true,
"uptime": 3600,
"nodesActive": 4
} 错误(非 200):
{
"success": false,
"healthy": false,
"message": "Service unhealthy"
} 远程服务器 API
基础 URL:您的平台 API 主机(环境相关端点请查看应用控制台)。
GET
/api/device/ads 获取广告任务列表
获取广告来源站点、广告类型、广告 ID、播放链接及相关内容。
参数:
-
sign(query) 必填 — 签名;见下方签名算法 -
machineCode(query) 必填 — 硬件节点码 -
timestamp(query) 必填 — 请求时间戳(秒)
成功(HTTP 200):
{
"success": true,
"data": {
"ads": [
{
"id": "ad-001",
"adType": "Video",
"source": "example.com",
"sourceUrl": "https://example.com/campaign/1",
"playUrl": "https://cdn.example.com/ad-001",
"duration": 30,
"rewardPerView": 0.001
}
]
}
} 错误(非 200):
{
"success": false,
"message": "Invalid sign or expired timestamp",
"code": "AUTH_FAILED"
} GET
/api/device/earnings 按节点或节点获取收益
根据节点码和可选的节点索引获取收益明细或汇总。
参数:
-
sign(query) 必填 — 签名 -
machineCode(query) 必填 — 节点码 -
timestamp(query) 必填 — 时间戳 -
nodeIndex(query) — 节点索引;若查询节点整体收益可省略 -
startDate(query) — 开始日期 YYYY-MM-DD -
endDate(query) — 结束日期 YYYY-MM-DD
成功(HTTP 200):
{
"success": true,
"data": {
"totalPoints": 1200,
"currency": "points",
"details": [
{
"date": "2025-03-01",
"nodeIndex": 0,
"points": 300,
"adCount": 120
},
{
"date": "2025-03-01",
"nodeIndex": 1,
"points": 280,
"adCount": 115
}
]
}
} 错误(非 200):
{
"success": false,
"message": "Node not found or access denied",
"code": "FORBIDDEN"
} POST
/api/device/heartbeat 节点心跳
定期上报节点在线状态和节点运行状态。
参数:
-
sign(query) 必填 — 签名 -
machineCode(query) 必填 — 节点码 -
timestamp(query) 必填 — 时间戳
请求体示例:
{
"nodeStatuses": [
{
"index": 0,
"status": "running",
"uptime": 3600
},
{
"index": 1,
"status": "running",
"uptime": 3600
},
{
"index": 2,
"status": "stopped",
"uptime": 0
}
],
"deviceHealthy": true
} 成功(HTTP 200):
{
"success": true,
"message": "Heartbeat received",
"nextReportIn": 60
} 错误(非 200):
{
"success": false,
"message": "Invalid sign or machineCode",
"code": "AUTH_FAILED"
} GET
/api/device/config 获取节点配置
获取节点运行配置(例如任务间隔、区域限制)。
参数:
-
sign(query) 必填 — 签名 -
machineCode(query) 必填 — 节点码 -
timestamp(query) 必填 — 时间戳
成功(HTTP 200):
{
"success": true,
"data": {
"taskInterval": 30,
"allowedRegions": [
"US",
"GB",
"DE"
],
"maxConcurrentAds": 4,
"reportInterval": 60
}
} 错误(非 200):
{
"success": false,
"message": "Invalid sign or node",
"code": "AUTH_FAILED"
} 签名算法
远程 API 请求需要查询参数 sign, machineCode, 和 timestamp.
sign = SHA256(account + password + machineCode + timestamp)