API 开发文档
本文档介绍暗码云·可视化后台所有内置 API 的使用方法。项目审核通过后即可调用。
⚠️ 重要提示:所有接口均使用 POST 方法,参数以 JSON 格式放在请求体中。
快速开始
调用 API 只需三步:
第一步:登录开发者后台,进入「项目凭证」页面
第二步:复制你的 project_id 和 api_key
第三步:在 POST 请求体中携带这两个参数,调用下方任意 API
项目凭证
每个项目有三组凭证:
| 凭证 | 说明 | 用途 | 安全性 |
project_id | 项目唯一标识 | 放在请求体 | 公开,可展示 |
api_key | 项目 API 密钥 | 放在请求体 | 半公开,勿泄露 |
secret_key | 项目秘密密钥 | 高级签名用 | 仅创建/重置时显示一次 |
⚠️ 注意:如果缺少 project_id 或 api_key,接口会返回 401 错误。
所有接口返回 JSON,格式如下:
{
"code": 0, // 0=成功,非0=失败
"message": "操作成功", // 提示信息
"data": {} // 返回数据
}
1. 用户注册
POST
https://dash.huihui-it.cn/api/v1/register.php
注册一个新的终端用户
请求体参数
| 参数 | 类型 | 必填 | 说明 |
| project_id | string | ✅ 必填 | 项目ID |
| api_key | string | ✅ 必填 | 项目密钥 |
| username | string | ✅ 必填 | 用户名,3-20个字符 |
| password | string | ✅ 必填 | 密码,至少6个字符 |
| email | string | ❌ 选填 | 邮箱地址 |
请求示例
fetch('https://dash.huihui-it.cn/api/v1/register.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
project_id: 'prj_xxxxxxxx',
api_key: 'ak_xxxxxxxx',
username: 'test_user',
password: '123456',
email: 'test@example.com'
})
})
.then(res => res.json())
.then(data => console.log(data));
成功响应示例
{
"code": 0,
"message": "注册成功",
"data": {
"user_id": 1,
"username": "test_user",
"token": "a1b2c3d4..."
}
}
2. 用户登录
POST
https://dash.huihui-it.cn/api/v1/login.php
终端用户登录,返回用户信息和 token
请求体参数
| 参数 | 类型 | 必填 | 说明 |
| project_id | string | ✅ 必填 | 项目ID |
| api_key | string | ✅ 必填 | 项目密钥 |
| username | string | ✅ 必填 | 用户名 |
| password | string | ✅ 必填 | 密码 |
请求示例
fetch('https://dash.huihui-it.cn/api/v1/login.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
project_id: 'prj_xxxxxxxx',
api_key: 'ak_xxxxxxxx',
username: 'test_user',
password: '123456'
})
})
.then(res => res.json())
.then(data => console.log(data));
成功响应示例
{
"code": 0,
"message": "登录成功",
"data": {
"user_id": 1,
"username": "test_user",
"is_vip": false,
"token": "a1b2c3d4..."
}
}
3. 查询用户信息
POST
https://dash.huihui-it.cn/api/v1/user_info.php
根据用户ID或用户名查询用户信息
请求体参数
| 参数 | 类型 | 必填 | 说明 |
| project_id | string | ✅ 必填 | 项目ID |
| api_key | string | ✅ 必填 | 项目密钥 |
| user_id | int | 二选一 | 用户ID |
| username | string | 二选一 | 用户名 |
请求示例
fetch('https://dash.huihui-it.cn/api/v1/user_info.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
project_id: 'prj_xxxxxxxx',
api_key: 'ak_xxxxxxxx',
username: 'test_user'
})
})
.then(res => res.json())
.then(data => console.log(data));
4. 查询VIP状态
POST
https://dash.huihui-it.cn/api/v1/vip_status.php
查询用户是否是VIP
请求体参数
| 参数 | 类型 | 必填 | 说明 |
| project_id | string | ✅ 必填 | 项目ID |
| api_key | string | ✅ 必填 | 项目密钥 |
| user_id | int | 二选一 | 用户ID |
| username | string | 二选一 | 用户名 |
请求示例
fetch('https://dash.huihui-it.cn/api/v1/vip_status.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
project_id: 'prj_xxxxxxxx',
api_key: 'ak_xxxxxxxx',
user_id: 1
})
})
.then(res => res.json())
.then(data => console.log(data));
成功响应示例
{
"code": 0,
"message": "操作成功",
"data": {
"is_vip": true,
"vip_text": "VIP用户"
}
}
5. 获取公告列表
POST
https://dash.huihui-it.cn/api/v1/announcements.php
获取项目下发布的公告,支持分页
请求体参数
| 参数 | 类型 | 必填 | 说明 |
| project_id | string | ✅ 必填 | 项目ID |
| api_key | string | ✅ 必填 | 项目密钥 |
| page | int | ❌ 选填 | 页码,默认1 |
| limit | int | ❌ 选填 | 每页条数,默认10,最大50 |
请求示例
fetch('https://dash.huihui-it.cn/api/v1/announcements.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
project_id: 'prj_xxxxxxxx',
api_key: 'ak_xxxxxxxx',
page: 1,
limit: 10
})
})
.then(res => res.json())
.then(data => console.log(data));
成功响应示例
{
"code": 0,
"message": "操作成功",
"data": {
"list": [
{
"id": 1,
"title": "系统更新通知",
"content": "系统将于今晚维护",
"is_pinned": 0,
"created_at": "2026-08-19 10:00:00"
}
],
"total": 1,
"page": 1,
"limit": 10
}
}
6. 查询维护状态
POST
https://dash.huihui-it.cn/api/v1/maintenance.php
查询项目是否处于维护模式
请求体参数
| 参数 | 类型 | 必填 | 说明 |
| project_id | string | ✅ 必填 | 项目ID |
| api_key | string | ✅ 必填 | 项目密钥 |
请求示例
fetch('https://dash.huihui-it.cn/api/v1/maintenance.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
project_id: 'prj_xxxxxxxx',
api_key: 'ak_xxxxxxxx'
})
})
.then(res => res.json())
.then(data => console.log(data));
成功响应示例
{
"code": 0,
"message": "操作成功",
"data": {
"is_maintenance": false,
"message": "系统正常运行",
"estimated_time": null
}
}
7. 检查版本更新
POST
https://dash.huihui-it.cn/api/v1/update.php
检查是否有新版本发布
请求体参数
| 参数 | 类型 | 必填 | 说明 |
| project_id | string | ✅ 必填 | 项目ID |
| api_key | string | ✅ 必填 | 项目密钥 |
| version | string | ❌ 选填 | 当前版本号,如 1.0.0 |
| platform | string | ❌ 选填 | 平台:android / ios |
请求示例
fetch('https://dash.huihui-it.cn/api/v1/update.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
project_id: 'prj_xxxxxxxx',
api_key: 'ak_xxxxxxxx',
version: '1.0.0',
platform: 'android'
})
})
.then(res => res.json())
.then(data => console.log(data));
成功响应示例
{
"code": 0,
"message": "操作成功",
"data": {
"has_update": true,
"latest_version": "1.1.0",
"update_url": "https://example.com/download.apk",
"update_note": "修复bug,优化性能",
"is_force": false
}
}
8. 查询项目用户列表
POST
https://dash.huihui-it.cn/api/dev_project_users.php
查询项目下所有终端用户,支持分页和搜索
请求体参数
| 参数 | 类型 | 必填 | 说明 |
| project_id | string | ✅ 必填 | 项目ID |
| api_key | string | ✅ 必填 | 项目密钥 |
| keyword | string | ❌ 选填 | 搜索用户名或邮箱 |
| page | int | ❌ 选填 | 页码,默认1 |
| limit | int | ❌ 选填 | 每页条数,默认50,最大100 |
请求示例
fetch('https://dash.huihui-it.cn/api/dev_project_users.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
project_id: 'prj_xxxxxxxx',
api_key: 'ak_xxxxxxxx',
page: 1,
limit: 20
})
})
.then(res => res.json())
.then(data => console.log(data));
成功响应示例
{
"code": 0,
"message": "操作成功",
"data": {
"project_name": "我的项目",
"total": 100,
"vip_count": 5,
"banned_count": 3,
"page": 1,
"limit": 20,
"users": [
{
"id": 1,
"username": "test_user",
"email": "test@example.com",
"status": "active",
"is_vip": false,
"created_at": "2026-08-19 10:00:00"
}
]
}
}
9. 查询单个用户详情
POST
https://dash.huihui-it.cn/api/dev_user_detail.php
根据用户ID或用户名查询单个用户详情
请求体参数
| 参数 | 类型 | 必填 | 说明 |
| project_id | string | ✅ 必填 | 项目ID |
| api_key | string | ✅ 必填 | 项目密钥 |
| user_id | int | 二选一 | 用户ID |
| username | string | 二选一 | 用户名 |
请求示例
fetch('https://dash.huihui-it.cn/api/dev_user_detail.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
project_id: 'prj_xxxxxxxx',
api_key: 'ak_xxxxxxxx',
user_id: 1
})
})
.then(res => res.json())
.then(data => console.log(data));
成功响应示例
{
"code": 0,
"message": "操作成功",
"data": {
"id": 1,
"username": "test_user",
"email": "test@example.com",
"status": "active",
"is_vip": false,
"created_at": "2026-08-19 10:00:00"
}
}
错误码说明
| code | 含义 | 处理建议 |
| 0 | 成功 | - |
| 400 | 参数错误 | 检查参数是否完整、格式是否正确 |
| 401 | 未授权 | 检查 project_id 和 api_key 是否正确 |
| 403 | 禁止访问 | 项目未通过审核,或账号被封禁 |
| 404 | 资源不存在 | 检查 ID 是否正确 |
| 405 | 请求方法错误 | 确保使用 POST 请求 |
| 500 | 服务器错误 | 联系平台管理员 |
完整示例代码
JavaScript 示例
// 配置
const API_BASE = 'https://dash.huihui-it.cn/api/v1';
const PROJECT_ID = 'prj_xxxxxxxx';
const API_KEY = 'ak_xxxxxxxx';
// 通用请求函数
async function apiRequest(path, body) {
const response = await fetch(API_BASE + path, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
project_id: PROJECT_ID,
api_key: API_KEY,
...body
})
});
return await response.json();
}
// 1. 注册用户
const regResult = await apiRequest('/register.php', {
username: 'user001',
password: 'pass123456',
email: 'user001@example.com'
});
console.log('注册结果:', regResult);
// 2. 登录
const loginResult = await apiRequest('/login.php', {
username: 'user001',
password: 'pass123456'
});
console.log('登录结果:', loginResult);
// 3. 获取公告
const announcements = await apiRequest('/announcements.php', { page: 1, limit: 10 });
console.log('公告列表:', announcements);
// 4. 查询维护状态
const maintenance = await apiRequest('/maintenance.php', {});
console.log('维护状态:', maintenance);
// 5. 检查更新
const update = await apiRequest('/update.php', { version: '1.0.0' });
console.log('更新检查:', update);
// 6. 查询项目用户列表
const users = await apiRequest('/dev_project_users.php', { page: 1, limit: 20 });
console.log('用户列表:', users);
Python 示例
import requests
API_BASE = 'https://dash.huihui-it.cn/api/v1'
PROJECT_ID = 'prj_xxxxxxxx'
API_KEY = 'ak_xxxxxxxx'
def api_request(path, body=None):
data = {'project_id': PROJECT_ID, 'api_key': API_KEY}
if body:
data.update(body)
response = requests.post(f'{API_BASE}{path}', json=data)
return response.json()
# 1. 注册用户
reg_result = api_request('/register.php', {
'username': 'user001',
'password': 'pass123456',
'email': 'user001@example.com'
})
print('注册结果:', reg_result)
# 2. 登录
login_result = api_request('/login.php', {
'username': 'user001',
'password': 'pass123456'
})
print('登录结果:', login_result)
# 3. 获取公告
announcements = api_request('/announcements.php', {'page': 1, 'limit': 10})
print('公告列表:', announcements)
# 4. 查询维护状态
maintenance = api_request('/maintenance.php')
print('维护状态:', maintenance)
✅ 提示:把 prj_xxxxxxxx 和 ak_xxxxxxxx 替换成你在开发者后台「项目凭证」里看到的值,即可直接运行示例代码。