didit-id-document-verification
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDidit ID Verification API
Didit 身份证件验证API
Overview
概述
Verifies identity documents by submitting images of the front and back sides. Performs OCR extraction, MRZ parsing, authenticity checks, and document liveness detection.
Key constraints:
- Supported formats: JPEG, PNG, WebP, TIFF
- Maximum file size: 5MB per image
- All document corners must be visible, full-color, no glare/shadows
- Original real-time photos only (no screenshots, scans, or digital copies)
Coverage: 4,000+ document types, 220+ countries, 130+ languages. Supports passports, national ID cards, driver's licenses, and residence permits.
Processing pipeline:
- Intelligent capture & document type detection
- OCR text extraction + MRZ/barcode parsing
- Template matching, security feature validation, tamper detection
- Document liveness (detects screen captures, printed copies, portrait manipulation)
API Reference: https://docs.didit.me/standalone-apis/id-verification
Feature Guide: https://docs.didit.me/core-technology/id-verification/overview
Supported Documents: https://docs.didit.me/core-technology/id-verification/supported-documents-id-verification
通过提交证件正反面图片验证身份证件。执行OCR提取、MRZ解析、真实性检查和文档活体检测。
关键约束:
- 支持格式:JPEG、PNG、WebP、TIFF
- 单张图片最大文件大小:5MB
- 证件四个角必须可见,全彩,无反光/阴影
- 仅接受实时拍摄的原始照片(不支持截图、扫描件或数字副本)
覆盖范围: 4000+种证件类型,220+个国家,130+种语言。支持护照、国民身份证、驾照和居住证。
处理流程:
- 智能采集与证件类型检测
- OCR文本提取 + MRZ/条形码解析
- 模板匹配、安全特征验证、篡改检测
- 文档活体检测(识别屏幕截图、打印副本、人像篡改)
API参考文档: https://docs.didit.me/standalone-apis/id-verification
功能指南: https://docs.didit.me/core-technology/id-verification/overview
支持的证件类型: https://docs.didit.me/core-technology/id-verification/supported-documents-id-verification
Authentication
身份验证
All requests require header. Get your key from Didit Business Console → API & Webhooks, or via programmatic registration (see below).
x-api-key所有请求均需携带请求头。您可以从Didit商务控制台 → API与Webhooks获取密钥,或通过程序化注册获取(详见下文)。
x-api-keyGetting Started (No Account Yet?)
快速上手(还没有账号?)
If you don't have a Didit API key, create one in 2 API calls:
- Register: with
POST https://apx.didit.me/auth/v2/programmatic/register/{"email": "you@gmail.com", "password": "MyStr0ng!Pass"} - Check email for a 6-character OTP code
- Verify: with
POST https://apx.didit.me/auth/v2/programmatic/verify-email/→ response includes{"email": "you@gmail.com", "code": "A3K9F2"}api_key
To add credits: to check, with for a Stripe checkout link.
GET /v3/billing/balance/POST /v3/billing/top-up/{"amount_in_dollars": 50}See the didit-verification-management skill for full platform management (workflows, sessions, users, billing).
如果您还没有Didit API密钥,可通过2个API调用创建:
- 注册: 向发送请求,参数为
POST https://apx.didit.me/auth/v2/programmatic/register/{"email": "you@gmail.com", "password": "MyStr0ng!Pass"} - 查看邮箱 获取6位OTP验证码
- 验证: 向发送请求,参数为
POST https://apx.didit.me/auth/v2/programmatic/verify-email/→ 响应结果包含{"email": "you@gmail.com", "code": "A3K9F2"}api_key
充值方式: 调用查询余额,调用并携带获取Stripe结账链接。
GET /v3/billing/balance/POST /v3/billing/top-up/{"amount_in_dollars": 50}如需完整平台管理(工作流、会话、用户、账单),请查看didit-verification-management技能。
Endpoint
接口地址
POST https://verification.didit.me/v3/id-verification/POST https://verification.didit.me/v3/id-verification/Headers
请求头
| Header | Value | Required |
|---|---|---|
| Your API key | Yes |
| | Yes |
| 请求头 | 值 | 是否必填 |
|---|---|---|
| 您的API密钥 | 是 |
| | 是 |
Request Parameters (multipart/form-data)
请求参数(multipart/form-data)
| Parameter | Type | Required | Default | Constraints | Description |
|---|---|---|---|---|---|
| file | Yes | — | JPEG/PNG/WebP/TIFF, max 5MB | Front image of ID document |
| file | No | — | Same as above | Back image (when applicable) |
| boolean | No | | — | Save in Business Console Manual Checks |
| string | No | — | — | Your identifier for session tracking |
| 参数 | 类型 | 是否必填 | 默认值 | 约束条件 | 描述 |
|---|---|---|---|---|---|
| 文件 | 是 | — | JPEG/PNG/WebP/TIFF,最大5MB | 身份证件正面图片 |
| 文件 | 否 | — | 同上 | 身份证件背面图片(如有需要) |
| 布尔值 | 否 | | — | 在商务控制台人工审核模块保存请求记录 |
| 字符串 | 否 | — | — | 用于会话追踪的自定义标识符 |
Example
示例代码
python
import requests
response = requests.post(
"https://verification.didit.me/v3/id-verification/",
headers={"x-api-key": "YOUR_API_KEY"},
files={
"front_image": ("front.jpg", open("front.jpg", "rb"), "image/jpeg"),
"back_image": ("back.jpg", open("back.jpg", "rb"), "image/jpeg"),
},
data={"vendor_data": "user-123"},
)typescript
const formData = new FormData();
formData.append("front_image", frontImageFile);
formData.append("back_image", backImageFile);
formData.append("vendor_data", "user-123");
const response = await fetch("https://verification.didit.me/v3/id-verification/", {
method: "POST",
headers: { "x-api-key": "YOUR_API_KEY" },
body: formData,
});python
import requests
response = requests.post(
"https://verification.didit.me/v3/id-verification/",
headers={"x-api-key": "YOUR_API_KEY"},
files={
"front_image": ("front.jpg", open("front.jpg", "rb"), "image/jpeg"),
"back_image": ("back.jpg", open("back.jpg", "rb"), "image/jpeg"),
},
data={"vendor_data": "user-123"},
)typescript
const formData = new FormData();
formData.append("front_image", frontImageFile);
formData.append("back_image", backImageFile);
formData.append("vendor_data", "user-123");
const response = await fetch("https://verification.didit.me/v3/id-verification/", {
method: "POST",
headers: { "x-api-key": "YOUR_API_KEY" },
body: formData,
});Response (200 OK)
响应结果(200 OK)
json
{
"request_id": "a1b2c3d4-...",
"id_verification": {
"status": "Approved",
"document_type": "Identity Card",
"document_number": "YZA123456",
"personal_number": "X9876543L",
"first_name": "Elena",
"last_name": "Martínez Sánchez",
"full_name": "Elena Martínez Sánchez",
"date_of_birth": "1985-03-15",
"age": 40,
"gender": "F",
"nationality": "ESP",
"issuing_state": "ESP",
"issuing_state_name": "Spain",
"expiration_date": "2030-08-21",
"date_of_issue": "2020-08-21",
"address": "Calle Mayor 10, Madrid",
"formatted_address": "Calle Mayor 10, 28013 Madrid, Spain",
"place_of_birth": "Valencia",
"portrait_image": "<base64>",
"front_document_image": "<base64>",
"back_document_image": "<base64>",
"mrz": {
"surname": "MARTINEZ SANCHEZ",
"given_name": "ELENA",
"document_type": "I",
"document_number": "YZA123456",
"country": "ESP",
"nationality": "ESP",
"birth_date": "850315",
"expiry_date": "300821",
"sex": "F"
},
"parsed_address": {"city": "Madrid", "region": "...", "postal_code": "28013", "country": "ES"},
"warnings": []
},
"created_at": "2025-05-01T13:11:07.977806Z"
}json
{
"request_id": "a1b2c3d4-...",
"id_verification": {
"status": "Approved",
"document_type": "Identity Card",
"document_number": "YZA123456",
"personal_number": "X9876543L",
"first_name": "Elena",
"last_name": "Martínez Sánchez",
"full_name": "Elena Martínez Sánchez",
"date_of_birth": "1985-03-15",
"age": 40,
"gender": "F",
"nationality": "ESP",
"issuing_state": "ESP",
"issuing_state_name": "Spain",
"expiration_date": "2030-08-21",
"date_of_issue": "2020-08-21",
"address": "Calle Mayor 10, Madrid",
"formatted_address": "Calle Mayor 10, 28013 Madrid, Spain",
"place_of_birth": "Valencia",
"portrait_image": "<base64>",
"front_document_image": "<base64>",
"back_document_image": "<base64>",
"mrz": {
"surname": "MARTINEZ SANCHEZ",
"given_name": "ELENA",
"document_type": "I",
"document_number": "YZA123456",
"country": "ESP",
"nationality": "ESP",
"birth_date": "850315",
"expiry_date": "300821",
"sex": "F"
},
"parsed_address": {"city": "Madrid", "region": "...", "postal_code": "28013", "country": "ES"},
"warnings": []
},
"created_at": "2025-05-01T13:11:07.977806Z"
}Status Values
状态值说明
| Status | Meaning |
|---|---|
| Document verified successfully |
| Verification failed (see |
| Requires manual review |
| 状态 | 含义 |
|---|---|
| 证件验证通过 |
| 验证失败(查看 |
| 需要人工审核 |
Error Responses
错误响应
| Code | Meaning | Action |
|---|---|---|
| Invalid request | Check file format, size, parameters |
| Invalid API key | Verify |
| Insufficient credits | Top up at business.didit.me |
| 状态码 | 含义 | 操作建议 |
|---|---|---|
| 请求无效 | 检查文件格式、大小及参数 |
| API密钥无效 | 确认 |
| 余额不足 | 在business.didit.me进行充值 |
Response Field Reference
响应字段参考
| Field | Type | Description |
|---|---|---|
| string | |
| string | |
| string | Document ID number |
| string | Personal/national ID number |
| string | Extracted name fields |
| string | |
| integer | Calculated age |
| string | |
| string | ISO 3166-1 alpha-3 |
| string | |
| string | Base64-encoded portrait from document |
| object | Machine Readable Zone data |
| object | Geocoded address: |
| array | |
| 字段 | 类型 | 描述 |
|---|---|---|
| 字符串 | |
| 字符串 | |
| 字符串 | 证件编号 |
| 字符串 | 个人/国民身份证号 |
| 字符串 | 提取的姓名字段 |
| 字符串 | |
| 整数 | 计算得出的年龄 |
| 字符串 | |
| 字符串 | ISO 3166-1 alpha-3格式 |
| 字符串 | |
| 字符串 | 证件人像的Base64编码 |
| 对象 | 机器可读区域(MRZ)数据 |
| 对象 | 地理编码后的地址: |
| 数组 | 格式为 |
Warning Tags
警告标签
Auto-Decline (always)
自动拒绝(始终触发)
| Tag | Description |
|---|---|
| Document in blocklist (previously flagged) |
| No portrait found on document |
| Document expiration date has passed |
| Document type not accepted |
| 标签 | 描述 |
|---|---|
| 证件在黑名单中(曾被标记) |
| 证件上未识别到人像 |
| 证件已过期 |
| 该证件类型不被接受 |
Configurable (Decline / Review / Approve)
可配置(拒绝/审核/通过)
| Category | Tags |
|---|---|
| Document liveness | |
| MRZ issues | |
| Data issues | |
| Duplicates | |
| Expected mismatch | |
| Geolocation | |
| 分类 | 标签 |
|---|---|
| 文档活体检测 | |
| MRZ问题 | |
| 数据问题 | |
| 重复检测 | |
| 信息不匹配 | |
| 地理位置 | |
Common Workflows
常见工作流
Basic ID Verification
基础身份证件验证
1. POST /v3/id-verification/ → front_image (+ back_image if applicable)
2. If "Approved" → extract first_name, last_name, date_of_birth, document_number
If "Declined" → check warnings:
DOCUMENT_EXPIRED → ask for valid document
SCREEN_CAPTURE_DETECTED → ask for real photo of physical document
MRZ_VALIDATION_FAILED → ask for clearer image1. 调用POST /v3/id-verification/ → 上传front_image(如有需要同时上传back_image)
2. 若返回"Approved" → 提取first_name、last_name、date_of_birth、document_number
若返回"Declined" → 查看warnings:
DOCUMENT_EXPIRED → 请求用户提供有效证件
SCREEN_CAPTURE_DETECTED → 请求用户提供实体证件的实拍照片
MRZ_VALIDATION_FAILED → 请求用户提供更清晰的证件图片Full Identity Verification Pipeline
完整身份验证流程
1. POST /v3/id-verification/ → verify document
2. POST /v3/passive-liveness/ → verify real person
3. POST /v3/face-match/ → compare selfie to document portrait
4. POST /v3/aml/ → screen extracted name/DOB/nationality
5. All Approved → fully verified identity1. 调用POST /v3/id-verification/ → 验证证件
2. 调用POST /v3/passive-liveness/ → 验证活体真人
3. 调用POST /v3/face-match/ → 对比自拍照与证件人像
4. 调用POST /v3/aml/ → 对提取的姓名/出生日期/国籍进行筛查
5. 所有步骤均返回Approved → 身份完全验证通过Utility Scripts
实用脚本
bash
export DIDIT_API_KEY="your_api_key"
python scripts/verify_id.py front.jpg
python scripts/verify_id.py front.jpg back.jpg --vendor-data user-123bash
export DIDIT_API_KEY="your_api_key"
python scripts/verify_id.py front.jpg
python scripts/verify_id.py front.jpg back.jpg --vendor-data user-123