# 购物小票识别

# 购物小票识别

请求方式: POST(HTTPS
请求地址: https://openapi.waiqin365.com/api/ocr/v1/shoppingReceipt/{ openid }/{ timestamp }/{ digest }/{ msg_id } 在线调试
请求示例:

{
 "image": "/9j/4AA",
 "url": "https://image.com/example1.jpg",
 "probability": "false",
 "location": "false"
}
说明: 本示例仅供参考,具体以参数说明为准。

参数说明:

参数 类型 必填 说明
image STRING
和url二选一
图像数据,base64编码后进行urlencode,要求base64编码和urlencode后大小不超过8M,最短边至少15px,最长边最大8192px,支持jpg/jpeg/png/bmp格式,优先级:image > url ,当image字段存在时,url字段失效
url STRING 和image二选一 图片完整url,url长度不超过1024字节,url对应的图片base64编码后大小不超过8M,最短边至少15px,最长边最大8192px,支持jpg/jpeg/png/bmp格式 优先级:image > url ,当image字段存在时,url字段失效,请注意关闭URL防盗链
probability STRING 是否返回字段置信度,可选值范围true/false,默认为 false ,即不返回
location STRING 是否返回字段位置坐标,可选值范围true/false,默认为 false ,即不返回

响应示例:

{
    "return_code": "0", 
    "return_msg": "响应信息",
    "msg_id": "{ msg_id }",
    "response_data": "<<DATA>>"
}

数据DATA示例:

{
  "recognition_id": 1562612082702144114,
  "recognition_results": [
    {
      "shop_name": [
        {
          "word": "大润发"
        }
      ],
      "receipt_id": [
        {
          "word": "26300076447544127425"
        }
      ],
      "machine_id": [
        {
          "word": "030"
        }
      ],
      "employee_id": [
        {
          "word": "004"
        }
      ],
      "payment_date": [
        {
          "word": "2022-08-15"
        }
      ],
      "payment_time": [
        {
          "word": "13:26:03"
        }
      ],
      "total_amount": [
        {
          "word": "1013.60"
        }
      ],
      "change": [
        {
          "word": "60.00"
        }
      ],
      "currency": [
        {
          "word": "人民币"
        }
      ],
      "paid_amount": [
        {
          "word": "1800.00"
        }
      ],
      "discount": [
        {
          "word": "0.00"
        }
      ],
      "print_date": [
        {
          "word": "2022-08-15"
        }
      ],
      "print_time": [
        {
          "word": "13:26:04"
        }
      ],
      "product_table_num": 1,
      "product_table": [
        {
          "product": {
            "word": "342529"
          },
          "quantity": {
            "word": "2"
          },
          "unit_price": {
            "word": "50.00"
          },
          "subtotal": {
            "word": "100.00"
          }
        }
      ]
    }
  ]
}

参数说明:

参数 类型 必填 说明
recognition_id uint64 唯一的id,用于问题定位
recognition_results object{} 识别结果
shop_name string 店名
receipt_id string 小票号码
machine_id string 机器编号
employee_id string 工号
payment_date string 消费日期
payment_time string 消费时间
total_amount string 总金额
change string 找零
currency string 币种
paid_amount string 实收金额
discount string 优惠/折扣
print_date string 打印日期
print_time string 打印时间
product_table_num string 商品明细行数,表示Table中的object个数
product_table List 消费明细区域
product string 商品名称
quantity string 数量
unit_price string 单价
subtotal string 小计金额
word string 字段识别结果,以上各字段均包含此参数
location object 字段位置信息,当请求参数 location=true 时,以上各字段均包含此参数
top uint32 字段的上边距
left uint32 字段的左边距
height uint32 字段的高度
width uint32 字段的宽度
probability object 字段识别结果置信度,当请求参数 probability=true 时,以上各字段均包含此参数
average float 字段识别结果中各字符的置信度平均值
min float 字段识别结果中各字符的置信度最小值