Skip to content

自定义 API 操作#

¥Custom API operations

One of the most complex parts of setting up API calls is managing authentication. n8n provides credentials support for operations and services beyond those supported by built-in nodes.

  • Custom operations for existing nodes: n8n supplies hundreds of nodes to create workflows that link multiple products. However, some nodes don't include all the possible operations supported by a product's API. You can work around this by making a custom API call using the HTTP Request node.
  • Credential-only nodes: n8n includes credential-only nodes. These are integrations where n8n supports setting up credentials for use in the HTTP Request node, but doesn't provide a standalone node. You can find a credential-only node in the nodes panel, as you would for any other integration.

预定义凭据类型#

¥Predefined credential types

预定义凭据类型是指 n8n 中已存在的凭据。你可以在 HTTP 请求节点中使用预定义的凭据类型,而不是通用凭据。

¥A predefined credential type is a credential that already exists in n8n. You can use predefined credential types instead of generic credentials in the HTTP Request node.

例如:你可以创建一个 Asana 凭据,用于 Asana 节点。稍后,你希望使用 Asana 的 API 执行 Asana 节点不支持的操作。你可以在“HTTP 请求”节点中使用现有的 Asana 凭据来执行操作,无需额外的身份验证设置。

¥For example: you create an Asana credential, for use with the Asana node. Later, you want to perform an operation that isn't supported by the Asana node, using Asana's API. You can use your existing Asana credential in the HTTP Request node to perform the operation, without additional authentication setup.

使用预定义凭据类型#

¥Using predefined credential types

To use a predefined credential type:

  1. Open your HTTP Request node, or add a new one to your workflow.
  2. In Authentication, select Predefined Credential Type.
  3. In Credential Type, select the API you want to use.
  4. In Credential for <API name>, you can:
    1. Select an existing credential for that platform, if available.
    2. Select Create New to create a new credential.

凭据范围#

¥Credential scopes

一些现有的凭据类型具有特定的范围:它们使用的端点。当你选择凭证类型时,n8n 会发出警告。

¥Some existing credential types have specific scopes: endpoints that they work with. n8n warns you about this when you select the credential type.

例如,按照 使用预定义凭据类型 中的步骤操作,并将凭据类型选择为 Google Calendar OAuth2 API。n8n 显示一个框,列出了可将此凭据类型用于的两个端点:

¥For example, follow the steps in Using predefined credential types, and select Google Calendar OAuth2 API as your Credential Type. n8n displays a box listing the two endpoints you can use this credential type with:

The scopes box