API、CLI 与扩展

Programmatic-style parameters

These are the parameters available for node base file of programmatic-style nodes.

This document gives short code snippets to help understand the code structure and concepts. For a full walk-through of building a node, including real-world code examples, refer to Build a programmatic-style node.

Programmatic-style nodes also use the execute() method. Refer to Programmatic-style execute method for more information.

Refer to Standard parameters for parameters available to all nodes.

defaultVersion

Number | Optional

Use defaultVersion when using the full versioning approach.

n8n support two methods of node versioning. Refer to Node versioning for more information.

methods and loadOptions

Object | Optional

Contains the loadOptions method for programmatic-style nodes. You can use this method to query the service to get user-specific settings (such as getting a user's email labels from Gmail), then return them and render them in the GUI so the user can include them in subsequent queries.

For example, n8n's Gmail node uses loadOptions to get all email labels:

js
	methods = {
		loadOptions: {
			// Get all the labels and display them
			async getLabels(
				this: ILoadOptionsFunctions,
			): Promise<INodePropertyOptions[]> {
				const returnData: INodePropertyOptions[] = [];
				const labels = await googleApiRequestAllItems.call(
					this,
					'labels',
					'GET',
					'/gmail/v1/users/me/labels',
				);
				for (const label of labels) {
					const labelName = label.name;
					const labelId = label.id;
					returnData.push({
						name: labelName,
						value: labelId,
					});
				}
				return returnData;
			},
		},
	};

version

Number or Array | Optional

Use version when using the light versioning approach.

If you have one version of your node, this can be a number. If you want to support multiple versions, turn this into an array, containing numbers for each node version.

n8n support two methods of node versioning. Programmatic-style nodes can use either. Refer to Node versioning for more information.

features

Object | Optional

Define named feature flags evaluated against the node version. Use features to control parameter visibility with @feature in displayOptions, or check them in code with this.isNodeFeatureEnabled().

Refer to Feature-based versioning for more information.

官方原文和授权

本页来自 N8N 英文官方网站固定快照,并转换成 xueai 静态页面。内容以 N8N 持续更新的官方页面为准。

来源、授权与修改

本站保留许可证、固定提交号、社区作者和修改说明,不代表 n8n 对本站背书。

查看许可证查看来源和修改说明