communications-mining
latest
false
重要 :
请注意,此内容已使用机器翻译进行了本地化。
Communications Mining 开发者指南
Last updated 2024年9月27日

使用 API

欢迎使用 Communications Mining API。 我们努力使 API 可预测、易于使用且易于集成。 如果您认为我们可以采取任何改进措施,或者您遇到任何错误或意外行为,请联系支持团队,我们会尽快给您答复。

您可以在API 参考中查看所有可用的端点。 还有一个API 教程。

API 端点

所有 API 请求都作为 JSON 对象,通过 HTTPS 发送到租户端点

通过 UiPath 载入的租户:

https://cloud.uipath.com/<my_uipath_organisation>/<my_uipath_tenant>/reinfer_/api/...https://cloud.uipath.com/<my_uipath_organisation>/<my_uipath_tenant>/reinfer_/api/...

通过 Communications Mining 载入的租户:

https://<mydomain>.reinfer.io/api/...https://<mydomain>.reinfer.io/api/...
重要提示:

开发和生产环境

在 Communications Mining 中,可以通过使用单独的租户或将开发和生产数据及工作流放置在同一租户的单独项目中来将开发和生产的数据及工作流分开。 在每种情况下,数据访问权限都是单独授予的(以便开发者可以对开发数据具有管理员访问权限,同时可以对生产进行更严格的控制)。 如果使用单独的租户,则每个开发和生产数据的 API 端点都不同;如果在同一租户中使用单独的项目,则该单个租户的端点可用于两者。

身份验证

所有 API 请求都需要身份验证,以识别发出请求的用户。 通过访问令牌提供身份验证。 可以从“管理帐户”页面获取开发者访问令牌。

备注:

您一次只能激活一个 API 令牌。 生成新令牌将使前一个令牌失效。

您需要在进行的每个 API 调用中包含以下 HTTP 标头,其中$REINFER_TOKEN是您的 Communications Mining API 令牌。
Authorization: Bearer $REINFER_TOKENAuthorization: Bearer $REINFER_TOKEN
API 参考中的 bash 示例假定您已将令牌保存在环境变量中。 API 参考中的 Python 和节点示例假定令牌已通过您选择的配置解决方案存储在本地变量REINFER_TOKEN中。
  • 重击
    curl -X GET 'https://<my_api_endpoint>/api/...' \
        -H "Authorization: Bearer $REINFER_TOKEN"curl -X GET 'https://<my_api_endpoint>/api/...' \
        -H "Authorization: Bearer $REINFER_TOKEN"
  • 节点
    const request = require("request");
    
    request.get(
      {
        url: "https://<my_api_endpoint>/api/...",
        headers: {
          Authorization: "Bearer " + process.env.REINFER_TOKEN,
        },
      },
      function (error, response, json) {
        // digest response
        console.log(JSON.stringify(json, null, 2));
      }
    );const request = require("request");
    
    request.get(
      {
        url: "https://<my_api_endpoint>/api/...",
        headers: {
          Authorization: "Bearer " + process.env.REINFER_TOKEN,
        },
      },
      function (error, response, json) {
        // digest response
        console.log(JSON.stringify(json, null, 2));
      }
    );
  • Python
    import json
    import os
    
    import requests
    
    response = requests.get(
        "https://<my_api_endpoint>/api/...",
        headers={"Authorization": "Bearer " + os.environ["REINFER_TOKEN"]},
    )
    
    print(json.dumps(response.json(), indent=2, sort_keys=True))import json
    import os
    
    import requests
    
    response = requests.get(
        "https://<my_api_endpoint>/api/...",
        headers={"Authorization": "Bearer " + os.environ["REINFER_TOKEN"]},
    )
    
    print(json.dumps(response.json(), indent=2, sort_keys=True))
    
  • 响应
    {
      "status": "ok"
    }{
      "status": "ok"
    }

权限

API 参考中的每个 API 端点都列出了其所需的权限。 您可以转到“管理帐户”页面来查看拥有的权限。 该页面显示您有权访问的项目以及您在每个项目中拥有的权限

错误

我们使用传统的 HTTP 响应代码来指示 API 请求成功或失败。 通常, 2xx范围中的代码表示成功, 4xx范围中的代码表示由于提供的请求而导致的错误,而5xx范围中的代码表示 Communications Mining 平台存在问题。
该错误的请求还将返回status值为error而不是ok的正文,以及描述错误的错误消息。
  • 重击
    curl -X GET 'https://<my_api_endpoint>/api/v1/nonexistent_page' \
        -H "Authorization: Bearer $REINFER_TOKEN"curl -X GET 'https://<my_api_endpoint>/api/v1/nonexistent_page' \
        -H "Authorization: Bearer $REINFER_TOKEN"
    
  • 节点
    const request = require("request");
    
    request.get(
      {
        url: "https://<my_api_endpoint>/api/v1/nonexistent_page",
        headers: {
          Authorization: "Bearer " + process.env.REINFER_TOKEN,
        },
      },
      function (error, response, json) {
        // digest response
        console.log(JSON.stringify(json, null, 2));
      }
    );const request = require("request");
    
    request.get(
      {
        url: "https://<my_api_endpoint>/api/v1/nonexistent_page",
        headers: {
          Authorization: "Bearer " + process.env.REINFER_TOKEN,
        },
      },
      function (error, response, json) {
        // digest response
        console.log(JSON.stringify(json, null, 2));
      }
    );
  • Python
    import json
    import os
    
    import requests
    
    response = requests.get(
        "https://<my_api_endpoint>/api/v1/nonexistent_page",
        headers={"Authorization": "Bearer " + os.environ["REINFER_TOKEN"]},
    )
    
    print(json.dumps(response.json(), indent=2, sort_keys=True))import json
    import os
    
    import requests
    
    response = requests.get(
        "https://<my_api_endpoint>/api/v1/nonexistent_page",
        headers={"Authorization": "Bearer " + os.environ["REINFER_TOKEN"]},
    )
    
    print(json.dumps(response.json(), indent=2, sort_keys=True))
    
  • 响应
    {
      "message": "404 Not Found",
      "status": "error"
    }{
      "message": "404 Not Found",
      "status": "error"
    }

请注意,您的请求在到达 Communications Mining 之前可能会由于网络中的问题而失败。 在这种情况下,您收到的响应将与上述 Communications Mining 错误响应不同。

性能计时

我们使用Server-Tiim HTTP 标头将请求发送到 API 所需的时间传达给我们的 API 进行处理。 我们提供了一个指标total ,您可以使用该指标来衡量我们的平台在没有网络请求延迟的情况下处理您的请求所花费的时间。

将在响应中看到的标头示例:

Server-Timing: total;dur=37.7Server-Timing: total;dur=37.7
Server-Timing值始终以毫秒为单位,因此在本例中,具有此标头值的 API 请求在我们的平台上需要 37.7 毫秒才能得到处理。
  • API 端点
  • 身份验证
  • 权限
  • 错误
  • 性能计时

此页面有帮助吗?

获取您需要的帮助
了解 RPA - 自动化课程
UiPath Community 论坛
Uipath Logo White
信任与安全
© 2005-2024 UiPath。保留所有权利。