n8n 元数据#
用于处理n8n元数据的方法。
这包括:
- 访问自托管n8n环境的n8n环境变量。
- 关于工作流、执行和节点的元数据。
- 关于实例Variables和External secrets的信息。
Python支持
你可以在代码节点中使用Python。但在表达式中不可用。
| 方法 | 描述 | 是否在代码节点中可用? |
|---|---|---|
$env |
Contains n8n instance configuration environment variables. | |
$execution.customData |
Set and get custom execution data. Refer to Custom executions data for more information. | |
$execution.id |
The unique ID of the current workflow execution. | |
$execution.mode |
Whether the execution was triggered automatically, or by manually running the workflow. Possible values are test and production. |
|
$execution.resumeUrl |
The webhook URL to call to resume a workflow waiting at a Wait node. | |
$getWorkflowStaticData(type) |
View an example. Static data doesn't persist when testing workflows. The workflow must be active and called by a trigger or webhook to save static data. This gives access to the static workflow data. | |
$("<node-name>").isExecuted |
Check whether a node has already executed. | |
$itemIndex |
The index of an item in a list of items. | |
$nodeVersion |
Get the version of the current node. | |
$prevNode.name |
The name of the node that the current input came from. When using the Merge node, note that $prevNode always uses the first input connector. |
|
$prevNode.outputIndex |
The index of the output connector that the current input came from. Use this when the previous node had multiple outputs (such as an If or Switch node). When using the Merge node, note that $prevNode always uses the first input connector. |
|
$prevNode.runIndex |
The run of the previous node that generated the current input. When using the Merge node, note that $prevNode always uses the first input connector. |
|
$runIndex |
How many times n8n has executed the current node. Zero-based (the first run is 0, the second is 1, and so on). | |
$secrets |
Contains information about your External secrets setup. | |
$vars |
Contains the Variables available in the active environment. | |
$version |
The node version. | |
$workflow.active |
Whether the workflow is active (true) or not (false). | |
$workflow.id |
The workflow ID. | |
$workflow.name |
The workflow name. |
| 方法 | 描述 |
|---|---|
_env |
Contains n8n instance configuration environment variables. |
_execution.customData |
Set and get custom execution data. Refer to Custom executions data for more information. |
_execution.id |
The unique ID of the current workflow execution. |
_execution.mode |
Whether the execution was triggered automatically, or by manually running the workflow. Possible values are test and production. |
_execution.resumeUrl |
The webhook URL to call to resume a workflow waiting at a Wait node. |
_getWorkflowStaticData(type) |
View an example. Static data doesn't persist when testing workflows. The workflow must be active and called by a trigger or webhook to save static data. This gives access to the static workflow data. |
_("<node-name>").isExecuted |
Check whether a node has already executed. |
_nodeVersion |
Get the version of the current node. |
_prevNode.name |
The name of the node that the current input came from. When using the Merge node, note that _prevNode always uses the first input connector. |
_prevNode.outputIndex |
The index of the output connector that the current input came from. Use this when the previous node had multiple outputs (such as an If or Switch node). When using the Merge node, note that _prevNode always uses the first input connector. |
_prevNode.runIndex |
The run of the previous node that generated the current input. When using the Merge node, note that _prevNode always uses the first input connector. |
_runIndex |
How many times n8n has executed the current node. Zero-based (the first run is 0, the second is 1, and so on). |
_secrets |
Contains information about your External secrets setup. |
_vars |
Contains the Variables available in the active environment. |
_workflow.active |
Whether the workflow is active (true) or not (false). |
_workflow.id |
The workflow ID. |
_workflow.name |
The workflow name. |