快速集成发票OCR识别功能到您的应用中
所有API请求需要在请求头中包含API Key:
X-API-Key: your_api_key_here
或者在URL参数中传递:
?api_key=your_api_key_here
识别发票图片并返回结构化数据
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
image | string | 是 | Base64编码的图片数据 |
curl -X POST https://invoice-ocr-api.pages.dev/api/v1/invoice/ocr \
-H "Content-Type: application/json" \
-H "X-API-Key: your_api_key" \
-d '{
"image": "base64_encoded_image_data"
}'
{
"success": true,
"data": {
"amount": "¥1,234.56",
"company": "北京XX科技有限公司",
"date": "2026-04-08",
"taxNumber": "91110000...",
"invoiceCode": "011001900111",
"invoiceNumber": "12345678"
},
"confidence": 0.95,
"processing_time_ms": 856,
"usage": {
"current": 1,
"remaining": 99,
"limit": 100
}
}
查看当前API使用统计
curl https://invoice-ocr-api.pages.dev/api/v1/stats \
-H "X-API-Key: your_api_key"
{
"usage": {
"this_month": 15,
"limit": 100,
"remaining": 85
},
"plan": "free",
"key_created_at": "2026-04-01T00:00:00Z"
}
| 错误码 | HTTP状态 | 说明 |
|---|---|---|
MISSING_API_KEY | 401 | 未提供API Key |
INVALID_API_KEY | 401 | API Key无效 |
LIMIT_EXCEEDED | 429 | 超出月度限制 |
MISSING_IMAGE | 400 | 未提供图片 |
IMAGE_TOO_LARGE | 400 | 图片超过10MB |
PROCESSING_ERROR | 500 | 处理失败 |
| 套餐 | 价格 | 调用次数/月 |
|---|---|---|
| Free | $0 | 100次 |
| Starter | $19/月 | 1,000次 |
| Pro | $79/月 | 10,000次 |
| Business | $199/月 | 50,000次 |
我们提供官方SDK以简化集成:
# JavaScript/TypeScript
npm install invoice-ocr-client
# Python
pip install invoice-ocr-client
import InvoiceOCRClient from 'invoice-ocr-client';
const client = new InvoiceOCRClient({
apiKey: 'your_api_key'
});
const result = await client.recognize('./invoice.jpg');
console.log(result.data);