OCR API
图片文字识别 API — 支持中英文,每天100次免费调用
服务运行中
推荐
了解更多
需要更多 API 调用?使用 AI 模型 API
OpenAI / Claude 等大模型 API,也可实现OCR识别,准确率更高
免费 API Key
复制下方 API Key,每天可调用 100 次
dtb-free-00000000000000000000000000000001
套餐方案
API 文档
健康检查
GET
GET http://82.156.34.78/api/ocr-health
curl http://82.156.34.78/api/ocr-health
图片识别
POST
POST http://82.156.34.78/api/ocr
Headers:
Content-Type: application/json
X-API-Key: YOUR_API_KEY
Request Body:
{
"image": "base64编码的图片数据",
"lang": "chi_sim+eng"
}
参数说明:
| 参数 | 类型 | 说明 |
|---|---|---|
| image | string | Base64 编码的图片(支持 data:image 前缀) |
| lang | string | 识别语言:chi_sim(中文)、eng(英文)、chi_sim+eng(中英混合) |
Response:
{
"text": "识别出的文字内容",
"language": "chi_sim+eng",
"confidence": 85.3,
"remaining_today": 98
}
代码示例
Python
import requests
import base64
with open('image.png', 'rb') as f:
img_b64 = base64.b64encode(f.read()).decode()
resp = requests.post(
'http://82.156.34.78/api/ocr',
json={'image': img_b64, 'lang': 'chi_sim+eng'},
headers={'X-API-Key': 'YOUR_API_KEY'}
)
print(resp.json()['text'])
JavaScript
const resp = await fetch('http://82.156.34.78/api/ocr', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': 'YOUR_API_KEY'
},
body: JSON.stringify({ image: base64str, lang: 'eng' })
});
const data = await resp.json();
console.log(data.text);
curl
curl -X POST http://82.156.34.78/api/ocr \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_API_KEY" \
-d '{"image":"'$(base64 -w0 image.png)'","lang":"eng"}'
使用技巧
图片预处理能显著提高识别率:确保图片清晰、对比度高、无倾斜。建议在发送前将图片转为 PNG 格式。
混合语言识别(lang=chi_sim+eng)适合中英文混排文档,但会比单语言略慢。如果确定只有中文,用 chi_sim 更快。
confidence 字段表示识别置信度(0-100),低于 60 的结果建议人工复核。
常见问题
免费版够用吗?
每天 100 次免费调用,适合个人项目和小型应用。如果超过限制,返回 429 错误。升级到标准版或无限版可解除限制。
支持哪些图片格式?
支持 PNG、JPG、WebP、BMP、TIFF 等常见格式。使用 PIL 进行预处理,建议发送 PNG 格式以获得最佳效果。
数据安全吗?
图片在识别后立即从服务器删除,不会存储或用于任何其他目的。所有传输通过 HTTPS 加密。
如果这些工具对你有帮助
请我喝杯咖啡,支持我开发更多免费工具
支付宝
微信支付