0CodeKit icon

0CodeKit

A toolbox of no-code utilities

Actions132

Code → Python B2

AI-generated

Overview

The node provides a way to execute custom Python code snippets within an n8n workflow using a backend service. It is designed for scenarios where users want to run arbitrary Python scripts, potentially with external dependencies, and get the output as JSON. This can be useful for data processing, automation tasks, or integrating Python-based logic that is not natively supported in n8n.

For example, you might use this node to:

  • Run a Python script that processes input data and returns transformed results.
  • Execute machine learning inference code by importing required libraries.
  • Perform complex calculations or data manipulations that are easier in Python.

Properties

Name Meaning
Code The Python code snippet to execute. This should be a valid Python script.
Requirements A list of PyPI package names that your Python code depends on. These packages will be installed before running the code.
Dependencies A list of system-level dependencies (Alpine packages) required by your Python code. These will be installed via apk package manager.

Output

The node outputs the result of the executed Python code as JSON in the json field of the output item. Typically, the Python script should print or return JSON-serializable data, which the node captures and makes available downstream.

If the Python code produces binary data, it would typically be handled separately, but based on the provided information, the primary output is JSON-formatted data representing the script's output.

Dependencies

  • Requires an API key credential to authenticate with the backend service at https://prod.0codekit.com.
  • The backend service executes the Python code; thus, no local Python environment is needed.
  • Users must specify any Python package dependencies explicitly to ensure they are installed correctly.
  • System dependencies can be specified and will be installed using Alpine Linux's package manager (apk).

Troubleshooting

  • Missing dependencies: If your Python code fails due to missing packages, ensure you have listed all required PyPI packages under "Requirements" and system packages under "Dependencies".
  • Syntax errors in Python code: The node expects valid Python syntax. Errors in the code will cause execution failure. Validate your code before running.
  • Output parsing errors: The node expects the Python script to output valid JSON. If the output is malformed or not JSON, downstream nodes may fail.
  • API authentication issues: Ensure the API key credential is configured correctly; otherwise, the request to the backend service will fail.
  • Long-running scripts: Scripts that take too long to execute may time out depending on backend limits.

Links and References

Discussion