快速开始
简介
安装 SDK
初始化
第一次认证
REST API
认证端点
NFT 铸造
身份查询
授权撤销
钩子 Webhooks
SDK 参考
JavaScript
Python
Go
Rust
API v3.2.0

开发者文档

FaceID Authority 提供完整的 REST API 与多语言 SDK,让你在 5 分钟内将链上人脸确权能力集成到任意应用。

安装 SDK

npm install @faceid/authority-sdk

初始化

import { FaceIDAuthority } from '@faceid/authority-sdk';

const faceid = new FaceIDAuthority({
  apiKey: 'fid_live_xxxxxxxxxxxxxxxx',
  network: 'mainnet',   // 'mainnet' | 'testnet'
  chain: 'ethereum',    // 支持 14 条链
});

发起身份认证

// 1. 获取认证会话
const session = await faceid.createSession({
  userId: 'user_abc123',
  level: 'standard',     // standard | enterprise | sovereign
  callbackUrl: 'https://your-app.com/webhook',
});

// 2. 重定向用户完成扫描
window.location.href = session.authorizeUrl;

// 3. Webhook 回调验证结果
app.post('/webhook', async (req, res) => {
  const event = faceid.verifyWebhook(req.headers, req.body);
  if (event.type === 'identity.verified') {
    console.log('已确权:', event.data.did, event.data.nftId);
  }
});

API 端点参考

POST /v3/sessions 创建身份认证会话 需要 API Key
GET /v3/sessions/:id 查询会话状态 需要 API Key
GET /v3/identities/:did 查询 DID 身份信息 公开
POST /v3/nfts/mint 手动触发 NFT 铸造 需要 API Key
DELETE /v3/identities/:did/revoke 撤销授权 需要 API Key + 签名

速率限制

计划请求/分钟月配额支持链数
免费601,0002
专业版 ¥299/月60050,0007
企业版 ¥2,999/月无限无限14