📖 API 文档

License Platform 提供 REST API 用于许可签发和验证。所有 API 均为 HTTP JSON。

公开 API(无需认证)

POST /api/issue

用户付款后签发许可。

curl -X POST http://localhost:3456/api/issue \
  -H 'Content-Type: application/json' \
  -d '{"product":1,"deviceFingerprint":"设备指纹","tier":"standard"}'

POST /api/verify

验证许可文件有效性。

curl -X POST http://localhost:3456/api/verify \
  -H 'Content-Type: application/json' \
  -d '{"license":{...license.json内容...}}'

GET /api/pubkey/:productId

获取产品公钥。

开发者 API(需要 Bearer Token)

POST /api/register

注册开发者账号。

POST /api/login

登录获取 Token。

GET /api/products

获取产品列表。

POST /api/products

创建产品。

GET /api/stats

获取统计数据。

集成到你的软件

在你的软件启动时请求 /api/verify 验证许可:

// Node.js 示例
const fs = require('fs');

async function checkLicense() {
  const licPath = './license.json';
  if (!fs.existsSync(licPath)) {
    console.log('❌ 未找到许可文件,请购买');
    return false;
  }

  const license = JSON.parse(fs.readFileSync(licPath, 'utf8'));
  const res = await fetch('http://localhost:3456/api/verify', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ license })
  });
  const result = await res.json();
  return result.valid;
}

← 返回首页