跳到主要内容
版本:latest

API接口文档

  1. 域名:https://cloud.laiye.com/idp

  2. 请求协议:https

  3. 数据格式:json

  4. 验证方式

    4.1 应用签名验证

    • HTTP Header:
    header key描述
    Api-Auth-pubkey用户创建应用的 pubkey
    Api-Auth-timestamp当前时间戳(秒)
    Api-Auth-nonce随机字符串
    Api-Auth-sign签名(signature)(签名生成规则:(Api-Auth-nonce+Api-Auth-timestamp+secret_key)的sha1值)
    • 示例代码(python)
    encoding:utf-8  
    import requests
    import json
    import time
    import hashlib
    import random
    import string
    def GenerateHeader(api_auth_pubkey, app_auth_secretkey):
    api_auth_timestamp = str(int(time.time()))
    api_auth_nounce = "".join(random.sample(string.ascii_letters + string.digits, 10))
    HeaderDict = dict()
    prefix = "Value Exception"
    if api_auth_pubkey == "":
    raise Exception("{0}, the api_auth_pubkey must not be empty".format(prefix))
    if app_auth_secretkey == "":
    raise Exception("{0}, the app_auth_secret_key must not be empty".format(prefix))
    prefix = "Type Exception"
    if not isinstance(api_auth_pubkey, str):
    raise Exception("{0}, the type of api_auth_pubkey must be string".format(prefix))
    if not isinstance(app_auth_secretkey, str):
    raise Exception("{0}, the type of app_auth_secretkey must be string".format(prefix))
    HeaderDict["Api-Auth-nonce"] = api_auth_nounce
    HeaderDict["Api-Auth-pubkey"] = api_auth_pubkey
    HeaderDict["Api-Auth-timestamp"] = api_auth_timestamp
    token_name = hashlib.sha1()
    token_key = api_auth_nounce + api_auth_timestamp+app_auth_secretkey
    token_name.update(token_key.encode("utf-8"))
    HeaderDict["Api-Auth-sign"] = token_name.hexdigest()
    return HeaderDict

    4.2 token验证

    • Http Header:
    header key描述
    Api-Auth-access-token账号oauth登录后得到的access-token

常见错误码

code描述
0正常
3(参数错误, 具体返回的 Message 根据错误类型不同会有差异)
8(资源耗尽, 比如请求体过大, 具体返回的 Message 根据错误类型不同会有差异)
10000服务内部错误
10001header解析错误
10002签名验证失败
10003参数不正确,应用不存在(
10004分类器算法类型不匹配
10005需要先更新分类器模型
10006需要选择待识别的图片
10007错误的文件类型
10008格式不正确,只支持png,jpeg,jpg,bmp,tiff,pdf
10009文件尺寸不正确,文件的长宽需要在15和4096像素之间
10010处理超时
10011账号配额不足
10012token已失效
10013无效的AI能力模块ID
10014当前AI能力未开启
10015调用频率超限
10016应用类型不匹配,请选择正确的API
10017不支持加密的PDF
10018请求数据过大,请控制在10M以内
10019不存在生效模板,无法进行模版识别
10020未匹配到任何生效模板
10021不存在已发布版本,无法进行抽取
10022请求参数错误
10023只支持UTF8编码

限流说明

为了安全性和响应效率,我们对开放平台接口做了调用频率的限流。 每次调用,在返回的 Headers 对象中(Response Headers)中会给出以下三个参数:

  • X-Ratelimit-Remaining:当前时间窗口剩余请求;
  • X-Ratelimit-Reset:下次重置时间;
  • UTCX-Ratelimit-Limit:当前时间窗口最大限流次数。

限流规则:

AI能力URI限制规则-
通用文字识别/v1/mage/ocr/general企业版:根据商务沟通确定 免费版: 每分钟6次--
通用表格识别/v1/mage/ocr/table企业版:根据商务沟通确定 免费版: 每分钟6次--
通用卡证识别/v1/mage/ocr/license企业版:根据商务沟通确定 免费版: 每分钟6次--
通用多票据识别/v1/mage/ocr/bills企业版:根据商务沟通确定 免费版: 每分钟6次--
模板识别/v1/document/ocr/template企业版:根据商务沟通确定 免费版: 每分钟6次--

更详细的接口说明,请参考接口文档IDP接口文档