磅单 OCR API 文档

当前接口:POST /openapi/v1/bangdan。认证方式:X-API-Key 或 Authorization: Bearer。

接口结构(固定展示)

入参multipart/form-data,字段:image(图片文件,必填)

出参:统一结构

{
  "code": 0,
  "message": "ok",
  "data": {
    "plate_no": "粤B12345",
    "weighing_time": "2026-05-07 10:20:30",
    "gross_weight": 49.32,
    "tare_weight": 12.10,
    "net_weight": 37.22,
    "goods_name": "碎石"
  }
}

字段释义

  1. data.plate_no:车牌号
  2. data.weighing_time:称重时间
  3. data.gross_weight:毛重(总重)
  4. data.tare_weight:皮重(空车重量)
  5. data.net_weight:净重(结算重量)
  6. data.goods_name:货物名称

在页面里测试

  1. 点击下方 Swagger 区域右上角的 Authorize 按钮。
  2. X-API-Key 输入框填入服务 key。当前本地测试 key 是 dev-service-key
  3. 展开 POST /openapi/v1/bangdan
  4. 点击 Try it out,上传一张磅单图片。
  5. 点击 Execute,查看返回 JSON。
  6. 展开 GET /openapi/v1/usage/me,可按时间段和分页查看当前 key 的调用记录。

调用示例

下面三个示例都调用同一个接口,上传一张图片并携带 X-API-Key

import requests

url = "https://smartocr.napuai.cn/openapi/v1/bangdan"
headers = {"X-API-Key": "dev-service-key"}

with open("samples/bangdan_1/1.png", "rb") as f:
    files = {"image": ("1.png", f, "image/png")}
    response = requests.post(url, headers=headers, files=files, timeout=300)

response.raise_for_status()
print(response.json())

usage_response = requests.get(
    "https://smartocr.napuai.cn/openapi/v1/usage/me",
    headers=headers,
    params={"page": 1, "page_size": 20},
    timeout=30,
)
usage_response.raise_for_status()
print(usage_response.json())
curl.exe -X POST "https://smartocr.napuai.cn/openapi/v1/bangdan" `
  -H "X-API-Key: dev-service-key" `
  -F "image=@samples/bangdan_1/1.png"

curl.exe -X GET "https://smartocr.napuai.cn/openapi/v1/usage/me" `
  -H "X-API-Key: dev-service-key"

curl.exe -X GET "https://smartocr.napuai.cn/openapi/v1/usage/me?page=1&page_size=100" `
  -H "X-API-Key: dev-service-key"
curl -X POST "https://smartocr.napuai.cn/openapi/v1/bangdan"   -H "X-API-Key: dev-service-key"   -F "image=@samples/bangdan_1/1.png"

curl -X GET "https://smartocr.napuai.cn/openapi/v1/usage/me"   -H "X-API-Key: dev-service-key"

curl -X GET "https://smartocr.napuai.cn/openapi/v1/usage/me?page=1&page_size=100"   -H "X-API-Key: dev-service-key"