用户中心 API
基础信息
| Base URL | https://api.idcxb.com/api/v1/account |
|---|---|
| 数据格式 | 请求与响应均为 JSON(Content-Type: application/json,Accept: application/json) |
| 字符编码 | UTF-8;时间使用 ISO 8601,例如 2026-10-28T21:00:00+08:00 |
| 限流 | 登录 10 次/分钟;其余接口 120 次/分钟(按 IP) |
| 跨域 | 已允许 Authorization 请求头,支持 GET/POST/PUT/DELETE/OPTIONS |
接口总览
以下是用户中心(/uc)对应的全部接口,路径均相对于 https://api.idcxb.com/api/v1/account。
「令牌」列 ✕ 表示无需登录,✓ 表示需携带 Authorization: Bearer。
| 令牌 | 方法 | 路径 | 说明 |
|---|---|---|---|
| ✕ | POST | /auth/register | 注册并直接获得令牌 |
| ✕ | GET | /auth/check | 用户名 / 邮箱查重 |
| ✕ | POST | /auth/login | 登录,返回 48 位令牌 |
| ✕ | POST | /auth/password/forgot | 发送找回密码验证码 |
| ✕ | POST | /auth/password/reset | 用验证码重置密码 |
| ✕ | GET | /openapi.json | 本文档的 OpenAPI 3.0 描述 |
| ✓ | POST | /auth/logout | 退出并重置令牌 |
| ✓ | GET | /me | 我的资料 |
| ✓ | PUT | /me | 更新昵称 / 邮箱 / 手机 |
| ✓ | PUT | /me/username | 修改用户名 |
| ✓ | PUT | /me/password | 修改密码 |
| ✓ | POST | /me/token | 重置接口令牌 |
| ✓ | GET | /dashboard | 仪表盘统计 |
| ✓ | GET | /logs | 授权日志 |
| ✓ | GET | /licenses | 授权列表 |
| ✓ | GET | /licenses/{license_key} | 授权详情 + 绑定 + 日志 |
| ✓ | POST | /licenses/claim | 认领授权 |
| ✓ | POST | /licenses/{license_key}/bind | 绑定域名与服务器 IP |
| ✓ | POST | /licenses/{license_key}/detect-ip | 检测域名解析 IP |
| ✓ | GET | /licenses/{license_key}/activations | 绑定记录 |
| ✓ | DELETE | /licenses/{license_key}/activations/{id} | 解绑 |
| ✓ | GET | /licenses/{license_key}/logs | 单授权日志 |
| ✓ | GET | /developer | 开发者信息 |
| ✓ | POST | /developer/apply | 申请开发者 |
| ✓ | GET | /developer/apps | 我的应用 |
| ✓ | POST | /developer/apps | 新建应用 |
| ✓ | PUT | /developer/apps/{id} | 编辑应用 |
| ✓ | POST | /developer/apps/{id}/submit | 提交审核 |
| ✓ | DELETE | /developer/apps/{id} | 删除应用 |
OpenAPI 规范
上面所有接口都有一份 OpenAPI 3.0 描述,可直接导入 Postman、Apifox、Swagger UI 或用于生成 SDK:
https://api.idcxb.com/api/v1/account/openapi.json
导入后把环境变量里的 Bearer 令牌填成本人令牌即可调用;授权方式已在规范里声明为 bearerAuth。
# 保存到本地,导入 Apifox / Postman curl -s "https://api.idcxb.com/api/v1/account/openapi.json" -o idcgo-account-openapi.json
规范只覆盖用户中心;公开的授权校验与商店接口分别有独立规范: license.json、 store.json, 统一入口见 文档总览 · 通用资源,避免客户端误带令牌。
SDK 与示例
提供两个单文件客户端,覆盖用户中心全部接口,直接下载即可用,无需安装依赖:
| PHP(账户) | /sdk/idcgo-account.php.txt 下载后重命名为 idcgo-account.php,需 curl 扩展,PHP 7.4+ |
|---|---|
| PHP(授权) | /sdk/idcgo-license.php.txt 提供 licenseRequest() 与 licenseVerifySign(),用于服务端授权校验,见授权文档 · 快速开始 |
| JavaScript | /sdk/idcgo-account.js 浏览器 / Node 18+,基于 fetch |
require 'idcgo-account.php';
$client = new IdcgoAccountClient();
$login = $client->login('demo', 'secret123'); // ['code'=>0, 'data'=>['token'=>...]]
if ($login['code'] === 0) {
$client->setToken($login['data']['token']);
$licenses = $client->licenses(['status' => 'usable']);
$bind = $client->bind('IDCG-XXXX-XXXX-XXXX-XXXX', 'demo.example.com');
}
const client = new IdcgoAccountClient();
const login = await client.login('demo', 'secret123');
if (login.code === 0) {
// 登录成功后令牌已自动写入客户端
const list = await client.licenses({ status: 'usable' });
const bind = await client.bind('IDCG-XXXX-XXXX-XXXX-XXXX', 'demo.example.com');
}
两个客户端的方法名与接口一一对应(bind、unbind、claim 等),
返回值都是接口原始结构,业务失败时 code 非 0,不会抛异常;网络错误才抛错。
鉴权方式
除登录、注册与查重接口外,所有接口都需要在请求头携带用户中心的接口令牌。令牌可在「账号设置」页面查看或重置。
Authorization: Bearer YOUR_API_TOKEN
先调用登录接口获取令牌:
curl -X POST "https://api.idcxb.com/api/v1/account/auth/login" \
-H "Content-Type: application/json" \
-d '{"account":"demo","password":"secret123"}'
{
"code": 0,
"message": "登录成功",
"data": {
"token": "48位令牌字符串",
"token_type": "Bearer",
"user": { "id": 12, "username": "demo", "balance": 33200, "balance_text": "¥332.00" }
}
}
退出登录会重置令牌,所有已登录客户端都将失效;重置令牌接口同理。
统一响应与分页
{
"code": 0,
"message": "ok",
"data": { }
}
分页接口的 data 结构:
{
"items": [],
"page": 1,
"per_page": 15,
"total": 42,
"last_page": 3
}
分页参数统一为 page、per_page(1–50),超出范围返回 42201。
错误码
| code | HTTP | 含义 |
|---|---|---|
| 0 | 200 | 成功 |
| 40101 | 401 | 未登录或令牌无效 |
| 40102 | 401 | 账号或密码不正确 |
| 40301 | 403 | 账号已被禁用 |
| 40302 | 403 | 无权访问该资源 |
| 40401 | 404 | 授权不存在 |
| 40402 | 404 | 应用不存在或无权操作 |
| 40403 | 404 | 绑定记录不存在或已解绑 |
| 40901 | 409 | 状态冲突:授权不可用、重复认领等 |
| 42201 | 422 | 参数校验失败,errors 内含字段错误 |
| 42901 | 429 | 请求过于频繁,响应头含 Retry-After |
注册与查重
| POST | /auth/register 用户名 + 邮箱 + 密码注册,成功直接返回令牌,公开接口(5 次/分钟) |
|---|---|
| GET | /auth/check?username=demo 用户名 / 邮箱可用性,公开接口(30 次/分钟) |
用户名 3–32 位,只能包含字母、数字、下划线和中文;密码至少 8 位,需带 password_confirmation。
curl -X POST "https://api.idcxb.com/api/v1/account/auth/register" \
-H "Content-Type: application/json" \
-d '{"username":"demo","email":"demo@example.com","password":"secret123","password_confirmation":"secret123"}'
{
"code": 0,
"message": "注册成功",
"data": {
"token": "48 位接口令牌",
"token_type": "Bearer",
"user": { "id": 18, "username": "demo", "nickname": "demo", "balance": 0 }
}
}
查重接口返回 available 与提示文案,可同时传 username、email:
{
"code": 0,
"message": "ok",
"data": {
"username": { "value": "demo", "available": false, "message": "该用户名已被使用" },
"email": { "value": "demo@example.com", "available": true, "message": "邮箱可用" }
}
}
登录与退出
| POST | /auth/login 账号(用户名或邮箱)+ 密码,公开接口 |
|---|---|
| POST | /auth/logout 重置令牌,使所有客户端失效 |
curl -X POST "https://api.idcxb.com/api/v1/account/auth/logout" \ -H "Authorization: Bearer YOUR_API_TOKEN"
我的资料
| GET | /me 当前用户、余额、开发者状态 |
|---|---|
| PUT | /me 修改 nickname、email、phone |
curl -X PUT "https://api.idcxb.com/api/v1/account/me" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"nickname":"小明","email":"demo@example.com","phone":"13800000000"}'
修改用户名
| PUT | /me/username 需要 username、password(当前密码确认) |
|---|
curl -X PUT "https://api.idcxb.com/api/v1/account/me/username" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"username":"newname","password":"secret123"}'
用户名重复返回 42201,密码错误返回 40901;登录令牌不受影响。
密码与令牌
| PUT | /me/password 需要 current_password、password、password_confirmation(至少 8 位) |
|---|---|
| POST | /me/token 重置并返回新令牌 |
curl -X PUT "https://api.idcxb.com/api/v1/account/me/password" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"current_password":"old12345","password":"new12345","password_confirmation":"new12345"}'
找回密码
通过绑定邮箱的 6 位验证码重置密码。首次使用前需在管理后台 系统设置 → 邮件服务 填写 SMTP 服务器、账号与授权码,并用「发送测试」确认可达;未配置时验证码只写入服务器日志,用户收不到邮件。
| POST | /auth/password/forgot 参数 account(用户名或邮箱),发送验证码;10 分钟有效,同一邮箱 60 秒内只能发一次 |
|---|---|
| POST | /auth/password/reset 参数 account、code、password、password_confirmation |
curl -X POST "https://api.idcxb.com/api/v1/account/auth/password/forgot" \
-H "Content-Type: application/json" \
-d '{"account":"demo@example.com"}'
{
"code": 0,
"message": "如果账号存在,验证码已发送至绑定邮箱",
"data": { "email": "d***@example.com", "expires_in": 600, "resend_after": 60 }
}
curl -X POST "https://api.idcxb.com/api/v1/account/auth/password/reset" \
-H "Content-Type: application/json" \
-d '{"account":"demo@example.com","code":"123456","password":"new12345","password_confirmation":"new12345"}'
重置成功后旧令牌全部失效,响应返回新令牌;验证码连错 5 次即作废,需重新获取。 账号不存在也返回同样的提示,避免被用来探测账号。
仪表盘
| GET | /dashboard 授权统计与最近 8 条授权日志 |
|---|
{
"data": {
"summary": { "total": 3, "usable": 2, "expiring": 1, "bindings": 4 },
"recent_logs": []
}
}
授权日志
| GET | /logs 我的全部授权日志,分页;可用 action=activate|verify|deactivate|heartbeat |
|---|
授权列表与详情
| GET | /licenses 分页;支持 keyword、status=usable|expired|disabled |
|---|---|
| GET | /licenses/{license_key} 详情、当前绑定与最近 20 条日志 |
| GET | /licenses/{license_key}/activations 有效绑定列表 |
| GET | /licenses/{license_key}/logs 单授权日志,分页 |
curl "https://api.idcxb.com/api/v1/account/licenses?status=usable&per_page=20" \ -H "Authorization: Bearer YOUR_API_TOKEN"
{
"items": [
{
"license_key": "IDCG-XXXX-XXXX-XXXX-XXXX",
"status_text": "正常",
"usable": true,
"permanent": false,
"days_left": 28,
"max_activations": 3,
"active_activations_count": 1
}
],
"page": 1, "per_page": 20, "total": 1, "last_page": 1
}
认领授权
把未归属或已属于当前账号的授权码绑定到账号;支持带或不带横线的授权码。
| POST | /licenses/claim 参数 license_key |
|---|
curl -X POST "https://api.idcxb.com/api/v1/account/licenses/claim" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"license_key":"IDCG-XXXX-XXXX-XXXX-XXXX"}'
绑定与解绑
| POST | /licenses/{license_key}/bind 参数 domain(真实域名)、ip(可选,留空自动解析域名);绑定前会校验域名解析结果,必须与服务器 IP 一致 |
|---|---|
| DELETE | /licenses/{license_key}/activations/{id} 解绑并记录日志 |
绑定后授权接口会同时核对域名与来源 IP:任一项与绑定不一致都会返回 1014。服务器换 IP 或域名后重新调用本接口(传入新 ip 或留空自动解析)即可更新基准。
curl -X POST "https://api.idcxb.com/api/v1/account/licenses/IDCG-XXXX-XXXX-XXXX-XXXX/bind" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"domain":"demo.example.com"}'
curl -X DELETE "https://api.idcxb.com/api/v1/account/licenses/IDCG-XXXX-XXXX-XXXX-XXXX/activations/12" \ -H "Authorization: Bearer YOUR_API_TOKEN"
服务器 IP 检测
绑定前可先检测域名当前解析到的服务器 IP。授权接口在激活、校验时也会自动记录调用方出口 IP,并在响应里返回 server_ip,原理与 1014 判定见 授权文档 · 服务器 IP 检测。
| POST | /licenses/{license_key}/detect-ip 参数 domain,返回解析到的 IP 列表 |
|---|
curl -X POST "https://api.idcxb.com/api/v1/account/licenses/IDCG-XXXX-XXXX-XXXX-XXXX/detect-ip" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"domain":"demo.example.com"}'
{
"code": 0,
"message": "ok",
"data": {
"domain": "demo.example.com",
"ip": "38.76.166.40",
"ips": ["38.76.166.40"],
"public": true,
"source": "dns",
"resolved_at": "2026-10-28 22:10:00"
}
}
绑定接口的 ip 可以省略,服务端会自动检测;使用 CDN 时请手动传源站 IP。绑定后该 IP 会锁定为校验基准,来源 IP 不一致时授权接口返回 1014,重新绑定即可更新。
应用商店(公开接口)
商店接口无需登录,前缀 https://api.idcxb.com/api/v1/store(不在 /account 下),
共 7 个只读接口;完整参数、响应与示例只在
应用商店接口文档 维护,本页不重复。
客户端只需记住入口:分类与类型用 /categories、/types,列表用 /apps,搜索用 /search。
开发者
| GET | /developer 开发者状态、最近申请、我的应用、可选分类、审核开关 |
|---|---|
| POST | /developer/apply 提交申请:type(individual/company)、real_name、product_name、description(≥10 字)等 |
curl -X POST "https://api.idcxb.com/api/v1/account/developer/apply" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"type":"individual","real_name":"张三","product_name":"我的面板","description":"为 IDCGo 提供增强能力"}'
应用管理
| GET | /developer/apps 我的应用列表 |
|---|---|
| POST | /developer/apps 新建应用(需已通过开发者认证) |
| PUT | /developer/apps/{id} 编辑应用,修改后重新进入审核 |
| POST | /developer/apps/{id}/submit 提交/重新提交审核 |
| DELETE | /developer/apps/{id} 删除应用 |
应用字段:name、category(应用分类 slug)、summary、description、version、icon、download_url、docs_url。分类可选 value-added(增值功能)、verification(认证验证)、login(登录方式)、notify(通知渠道)、realname(实名认证)、server(服务器管理)、theme(资源主题),类型由分类推导为 plugin / theme / patch。下载/文档地址仅支持 http/https。
快速开始
TOKEN=$(curl -s -X POST "https://api.idcxb.com/api/v1/account/auth/login" \
-H "Content-Type: application/json" \
-d '{"account":"demo","password":"secret123"}' | jq -r '.data.token')
curl "https://api.idcxb.com/api/v1/account/dashboard" -H "Authorization: Bearer $TOKEN"
curl "https://api.idcxb.com/api/v1/account/licenses" -H "Authorization: Bearer $TOKEN"