0CodeKit icon

0CodeKit

A toolbox of no-code utilities

Code → Python

AI-generated

Overview

The CodeKit node (Resource: Code, Operation: Python) allows users to execute custom Python code within an n8n workflow. This is particularly useful for scenarios where you need to perform data manipulation, calculations, or logic that isn't easily achievable with built-in n8n nodes. For example, you might use this node to process incoming data, transform it using Python libraries, or implement custom algorithms before passing the results to subsequent workflow steps.

Practical examples:

  • Parsing and transforming complex JSON structures.
  • Performing mathematical computations not available in standard nodes.
  • Integrating with Python-based APIs or libraries for specialized tasks.

Properties

Name Meaning
Code Your python code. The Python script you want to execute. This field is required and supports multi-line input.

Output

  • The output will be a JSON object containing the result of your Python code execution.
  • If the execution fails and "Continue On Fail" is enabled, the output will include an error field with the error message as a string.

Example output:

[
  {
    "result": "your_python_output"
  }
]

or, on error (with Continue On Fail):

[
  {
    "error": "Error: <error details>"
  }
]

Dependencies

  • External Service: Requires valid credentials for codeKitApi.
  • n8n Configuration: Ensure the CodeKit node is properly installed and configured in your n8n instance.

Troubleshooting

Common Issues:

  • Syntax errors in Python code: If your code contains syntax errors, the node will throw an error. Double-check your Python script for typos or incorrect indentation.
  • Missing or invalid API credentials: If the required codeKitApi credentials are not set up, the node will fail to execute.
  • Unsupported Python features: Some Python modules or functions may not be available in the execution environment.

Common Error Messages:

  • "error": "Error: <error details>"
    • Resolution: Review the error message for clues. Check your Python code for mistakes, and ensure all required variables and imports are present.

Links and References

Discussion