OCR证件识别服务API接口文档,帮助您快速接入
https://ocr.5811.cn注册账号后,在控制台创建API密钥,即可开始调用OCR识别接口。
// 1. 注册账号并登录控制台 // 2. 创建 API 密钥 // 3. 使用密钥调用识别接口 // 接口地址 POST /api/v1/ocr // 认证方式 Authorization: Bearer your_api_key
| 请求方式 | POST |
| 接口地址 | /api/v1/ocr |
| Content-Type | multipart/form-data 或 application/json |
使用 multipart/form-data 上传图片文件
使用 JSON 格式传递图片URL
{
"image_url": "https://example.com/id-card.jpg"
}# 上传图片文件
curl -X POST https://ocr.5811.cn/api/v1/ocr \
-H "Authorization: Bearer your_api_key" \
-F "image=@/path/to/image.jpg"
# 使用图片URL
curl -X POST https://ocr.5811.cn/api/v1/ocr \
-H "Authorization: Bearer your_api_key" \
-H "Content-Type: application/json" \
-d '{"image_url": "https://example.com/image.jpg"}'// 使用 fetch API
const formData = new FormData();
formData.append('image', fileInput.files[0]);
const response = await fetch('/api/v1/ocr', {
method: 'POST',
headers: {
'Authorization': 'Bearer your_api_key'
},
body: formData
});
const result = await response.json();
console.log(result);
// 使用图片URL
const response2 = await fetch('/api/v1/ocr', {
method: 'POST',
headers: {
'Authorization': 'Bearer your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
image_url: 'https://example.com/image.jpg'
})
});import requests
# 上传图片文件
url = "https://ocr.5811.cn/api/v1/ocr"
headers = {"Authorization": "Bearer your_api_key"}
with open("image.jpg", "rb") as f:
files = {"image": f}
response = requests.post(url, headers=headers, files=files)
result = response.json()
print(result)
# 使用图片URL
import json
response = requests.post(url,
headers={
"Authorization": "Bearer your_api_key",
"Content-Type": "application/json"
},
data=json.dumps({"image_url": "https://example.com/image.jpg"})
){
"status": "success",
"data": {
// OCR识别结果,包含证件信息
}
}{
"statusCode": 401,
"message": "缺少API密钥"
}