Nanonets 文档提取 API。可将 PDF 和图像转换为 Markdown、JSON 或 CSV,并提供置信度评分。适用于文档 OCR、发票字段提取、收据解析或表格转结构化数据。
DocStrange by Nanonets.是一项面向实际任务的技能,主要用于Document retrieved API – 转换PDF,图像和文档,以标记下,JSON,或CSV,并按每个字段打入信任分.;Get your API key: https://docstrang.nanonets.。
实际使用前应先确认任务范围、数据来源、运行环境、必要权限和关键参数,再依据技能说明逐步执行;若输入条件不完整,应先补齐信息或采用保守配置,避免因错误假设导致结果偏离需求。执行过程中需要关注工具调用是否成功、接口或依赖是否可用、输出格式是否符合预期,并对异常提示、缺失字段和边界情况进行处理;
涉及批量任务时,还应保存进度,避免中断后重复操作。该技能适合用于一次性任务,也可以接入自动化工作流,与其他技能或上层代理配合完成更完整的业务链路;在组合使用时,应明确每一步的输入输出关系,并避免不同步骤之间出现参数冲突。
文档提取 API —— 将 PDF、图像及各类文档转换为 Markdown、JSON 或 CSV 格式,并为每个字段提供置信度评分。
获取您的 API 密钥: https://docstrange.nanonets.com/app
curl -X POST "https://extraction-api.nanonets.com/api/v1/extract/sync" -H "Authorization: Bearer $DOCSTRANGE_API_KEY" -F "file=@document.pdf" -F "output_format=markdown"
响应示例:
{
"success": true,
"record_id": "550e8400-e29b-41d4-a716-446655440000",
"status": "completed",
"result": {
"markdown": {
"content": "# Invoice\n\n**Invoice Number:** INV-2024-001..."
}
}
}
# 访问控制台 https://docstrange.nanonets.com/app
保存您的 API 密钥:
export DOCSTRANGE_API_KEY="your_api_key_here"
推荐方式:使用环境变量(最安全):
{
skills: {
entries: {
"docstrange": {
enabled: true,
// API 密钥从环境变量 DOCSTRANGE_API_KEY 中加载
},
},
},
}
替代方式:存储于配置文件中(请谨慎使用):
{
skills: {
entries: {
"docstrange": {
enabled: true,
env: {
DOCSTRANGE_API_KEY: "your_api_key_here",
},
},
},
},
}
安全提示: 若将 API 密钥存储在 ~/.openclaw/openclaw.json 中,请注意:
chmod 600 ~/.openclaw/openclaw.jsoncurl -X POST "https://extraction-api.nanonets.com/api/v1/extract/sync" -H "Authorization: Bearer $DOCSTRANGE_API_KEY" -F "file=@document.pdf" -F "output_format=markdown"
访问内容字段:response["result"]["markdown"]["content"]
简单字段列表:
curl -X POST "https://extraction-api.nanonets.com/api/v1/extract/sync" -H "Authorization: Bearer $DOCSTRANGE_API_KEY" -F "file=@invoice.pdf" -F "output_format=json" -F 'json_options=["invoice_number", "date", "total_amount", "vendor"]' -F "include_metadata=confidence_score"
使用 JSON Schema:
curl -X POST "https://extraction-api.nanonets.com/api/v1/extract/sync"
-H "Authorization: Bearer $DOCSTRANGE_API_KEY"
-F "file=@invoice.pdf"
-F "output_format=json"
-F '{"type": "object", "properties": {"invoice_number": {"type": "string"}, "total_amount": {"type": "number"}}}'
带置信度评分的响应示例:
{
"result": {
"json": {
"content": {
"invoice_number": "INV-2024-001",
"total_amount": 500.00
},
"metadata": {
"confidence_score": {
"invoice_number": 98,
"total_amount": 99
}
}
}
}
}
curl -X POST "https://extraction-api.nanonets.com/api/v1/extract/sync" -H "Authorization: Bearer $DOCSTRANGE_API_KEY" -F "file=@table.pdf" -F "output_format=csv" -F "csv_options=table"
对于页数超过 5 页的文档,请使用异步接口并轮询结果:
提交文档至队列:
curl -X POST "https://extraction-api.nanonets.com/api/v1/extract/async"
-H "Authorization: Bearer $DOCSTRANGE_API_KEY"
-F "file=@large-document.pdf"
-F "output_format=markdown"
# 返回示例:{"record_id": "12345", "status": "processing"}
轮询提取结果:
curl -X GET "https://extraction-api.nanonets.com/api/v1/extract/results/12345"
-H "Authorization: Bearer $DOCSTRANGE_API_KEY"
# 返回示例:{"status": "completed", "result": {...}}
获取元素坐标,用于版面分析:
-F "include_metadata=bounding_boxes"
提取文档结构(章节、表格、键值对等):
-F "json_options=hierarchy_output"
增强的表格识别与数字格式化能力:
-F "markdown_options=financial-docs"
通过提示词引导提取行为:
-F "custom_instructions=Focus on financial data. Ignore headers." -F "prompt_mode=append"
单次请求返回多种格式:
-F "output_format=markdown,json"
| 文档大小 | 接口路径 | 说明 |
|---|---|---|
| ≤5 页 | /extract/sync |
即时响应 |
| >5 页 | /extract/async |
需轮询结果 |
JSON 提取方式:
["field1", "field2"] —— 快速提取{"type": "object", ...} —— 支持强类型校验与嵌套结构置信度评分:
include_metadata=confidence_score{
"type": "object",
"properties": {
"invoice_number": {"type": "string"},
"date": {"type": "string"},
"vendor": {"type": "string"},
"total": {"type": "number"},
"line_items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"description": {"type": "string"},
"quantity": {"type": "number"},
"price": {"type": "number"}
}
}
}
}
}
{
"type": "object",
"properties": {
"merchant": {"type": "string"},
"date": {"type": "string"},
"total": {"type": "number"},
"items": {
"type": "array",
"items": {"type": "object", "properties": {"name": {"type": "string"}, "price": {"type": "number"}}}
}
}
}
重要提示: 上传至 DocStrange 的文档将传输至 https://extraction-api.nanonets.com 并在外部服务器上进行处理。
上传敏感文档前,请务必:
最佳实践:
file_url 参数配合公开可访问的 URL,而非直接上传大型文件"your_api_key_here")400 错误(Bad Request):
file、file_url 或 file_base64同步调用超时:
/extract/results/{record_id} 获取结果缺失置信度评分:
json_options(字段列表或 JSON Schema)include_metadata=confidence_score认证错误:
DOCSTRANGE_API_KEY 环境变量在发布或更新本技能前,请确认完成以下检查项:
package.json 中已声明 requiredEnv 和 primaryEnv 字段,且其值为 DOCSTRANGE_API_KEYpackage.json 的 endpoints 数组中已列出所有 API 接口地址"your_api_key_here"),未包含真实密钥SKILL.md 与 package.json 中均未嵌入任何 API 密钥或敏感信息相关专题
热门下载
相关下载
精品课程
共6课时 | 54.7万人学习
共89课时 | 133.9万人学习
共49课时 | 82.5万人学习