Invoice OCR API 文档

快速集成发票OCR识别功能到您的应用中

认证

所有API请求需要在请求头中包含API Key:

X-API-Key: your_api_key_here

或者在URL参数中传递:

?api_key=your_api_key_here

API 端点

POST /api/v1/invoice/ocr

识别发票图片并返回结构化数据

请求参数

参数类型必填说明
imagestringBase64编码的图片数据

请求示例

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
  }
}
GET /api/v1/stats

查看当前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_KEY401未提供API Key
INVALID_API_KEY401API Key无效
LIMIT_EXCEEDED429超出月度限制
MISSING_IMAGE400未提供图片
IMAGE_TOO_LARGE400图片超过10MB
PROCESSING_ERROR500处理失败

定价

套餐价格调用次数/月
Free$0100次
Starter$19/月1,000次
Pro$79/月10,000次
Business$199/月50,000次

SDK

我们提供官方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);