在数据工坊API中,查询已发布算子模板详情的功能通过ShowPublicTemplateInfo接口实现,该接口特别适用于三方算子开发者,以便他们能够获取到公开的算子模板详细信息,以下是对该接口的详细介绍和使用方法。

ShowPublicTemplateInfo接口是数据工坊API提供的一个用于查询已发布算子模板详情的功能,通过调用该接口,开发者可以获取到特定算子模板的详细信息,包括模板名称、描述、参数列表、输入输出等信息。
接口调用
请求参数
调用ShowPublicTemplateInfo接口时,需要传入以下参数:
| 参数名 | 类型 | 描述 |
|---|---|---|
| templateId | String | 算子模板的唯一标识符 |
| accessToken | String | 访问令牌 |
请求示例
以下是一个调用ShowPublicTemplateInfo接口的示例代码:

import requests
def show_public_template_info(template_id, access_token):
url = f"https://api.dataworkshop.com/v1/templates/{template_id}/info"
headers = {
"Authorization": f"Bearer {access_token}"
}
response = requests.get(url, headers=headers)
return response.json()
# 使用示例
template_id = "1234567890"
access_token = "your_access_token_here"
info = show_public_template_info(template_id, access_token)
print(info)响应格式
接口调用成功后,会返回一个JSON格式的响应,以下是一个示例响应:
{
"code": 200,
"message": "Success",
"data": {
"templateName": "DataCleaning",
"description": "用于数据清洗的算子模板",
"parameters": [
{
"name": "inputData",
"type": "String",
"description": "输入数据"
},
{
"name": "outputData",
"type": "String",
"description": "清洗后的数据"
}
],
"inputs": [
{
"name": "inputData",
"type": "String",
"description": "输入数据"
}
],
"outputs": [
{
"name": "outputData",
"type": "String",
"description": "清洗后的数据"
}
]
}
}FAQs
问题:ShowPublicTemplateInfo接口支持哪些类型的参数查询?
解答:ShowPublicTemplateInfo接口支持通过templateId查询特定算子模板的详情,目前不支持通过其他参数进行查询。
问题:调用ShowPublicTemplateInfo接口时,如果传入错误的accessToken会怎样?
解答:如果传入错误的accessToken,接口会返回401错误码,表示认证失败,开发者需要检查访问令牌是否正确,并确保有权限访问该接口。

图片来源于AI模型,如侵权请联系管理员。作者:酷小编,如若转载,请注明出处:https://www.kufanyun.com/ask/71708.html




