跳到主要内容

工作流模板#

功能可用性说明

嵌入功能需要嵌入许可证。有关使用嵌入功能的场景、成本及授权流程的详细信息,请参阅 n8n 官网上的嵌入功能说明

n8n 提供了工作流模板库。在嵌入 n8n 时,您可以:

  • 继续使用 n8n 的工作流模板库(此为默认行为)
  • 禁用工作流模板
  • 创建专属的工作流模板库

禁用工作流模板#

在环境变量中将 N8N_TEMPLATES_ENABLED 设置为 false。

使用专属工作流模板库#

在环境变量中将 N8N_TEMPLATES_HOST 设置为您的 API 基础地址。

端点#

您的 API 必须提供与 n8n 相同的端点和数据结构。

支持的端点包括:

方法路径
GET/templates/workflows/<id>
GET/templates/search
GET/templates/collections/<id>
GET/templates/collections
GET/templates/categories
GET/health

查询参数#

/templates/search 端点支持以下查询参数:

参数类型说明
page整数要返回的结果页码
rows整数每页返回的最大结果数量
category逗号分隔的字符串列表(分类)要搜索的分类范围
search字符串搜索查询词

/templates/collections 端点支持以下查询参数:

参数类型说明
category逗号分隔的字符串列表(分类)要搜索的分类范围
search字符串搜索查询词

数据模式#

您可通过以下链接查看端点返回的响应对象中各项数据的数据结构:

显示 workflow 项目数据模式

{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Generated schema for Root",
"type": "object",
"properties": {
"id": {
"type": "number"
},
"name": {
"type": "string"
},
"totalViews": {
"type": "number"
},
"price": {},
"purchaseUrl": {},
"recentViews": {
"type": "number"
},
"createdAt": {
"type": "string"
},
"user": {
"type": "object",
"properties": {
"username": {
"type": "string"
},
"verified": {
"type": "boolean"
}
},
"required": [
"username",
"verified"
]
},
"nodes": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "number"
},
"icon": {
"type": "string"
},
"name": {
"type": "string"
},
"codex": {
"type": "object",
"properties": {
"data": {
"type": "object",
"properties": {
"details": {
"type": "string"
},
"resources": {
"type": "object",
"properties": {
"generic": {
"type": "array",
"items": {
"type": "object",
"properties": {
"url": {
"type": "string"
},
"icon": {
"type": "string"
},
"label": {
"type": "string"
}
},
"required": [
"url",
"label"
]
}
},
"primaryDocumentation": {
"type": "array",
"items": {
"type": "object",
"properties": {
"url": {
"type": "string"
}
},
"required": [
"url"
]
}
}
},
"required": [
"primaryDocumentation"
]
},
"categories": {
"type": "array",
"items": {
"type": "string"
}
},
"nodeVersion": {
"type": "string"
},
"codexVersion": {
"type": "string"
}
},
"required": [
"categories"
]
}
}
},
"group": {
"type": "string"
},
"defaults": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"color": {
"type": "string"
}
},
"required": [
"name"
]
},
"iconData": {
"type": "object",
"properties": {
"icon": {
"type": "string"
},
"type": {
"type": "string"
},
"fileBuffer": {
"type": "string"
}
},
"required": [
"type"
]
},
"displayName": {
"type": "string"
},
"typeVersion": {
"type": "number"
},
"nodeCategories": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "number"
},
"name": {
"type": "string"
}
},
"required": [
"id",
"name"
]
}
}
},
"required": [
"id",
"icon",
"name",
"codex",
"group",
"defaults",
"iconData",
"displayName",
"typeVersion"
]
}
}
},
"required": [
"id",
"name",
"totalViews",
"price",
"purchaseUrl",
"recentViews",
"createdAt",
"user",
"nodes"
]
}

显示 category 项目数据结构

{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"id": {
"type": "number"
},
"name": {
"type": "string"
}
},
"required": [
"id",
"name"
]
}

显示 collection 项目数据结构

{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"id": {
"type": "number"
},
"rank": {
"type": "number"
},
"name": {
"type": "string"
},
"totalViews": {},
"createdAt": {
"type": "string"
},
"workflows": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "number"
}
},
"required": [
"id"
]
}
},
"nodes": {
"type": "array",
"items": {}
}
},
"required": [
"id",
"rank",
"name",
"totalViews",
"createdAt",
"workflows",
"nodes"
]
}

您还可以通过交互方式探索 n8n 的 API 端点:

https://api.n8n.io/templates/categories

https://api.n8n.io/templates/collections

https://api.n8n.io/templates/search

https://api.n8n.io/health

如需更多支持,请联系我们

将工作流添加至 n8n 模板库#

n8n 正在推进创作者计划,并开发模板市场。这是一个持续演进的项目,具体细节可能调整。