Python SDK for n8n-nodes-python-function
Project description
n8n_py
The n8n_py SDK connects the n8n-nodes-python-function custom node with your python functions.
Examples
Hello World
Returns a hello world json response
from n8n_py import expose_function, String
from n8n_py.handler import handle
@expose_function("Hello World", "returns a friendly greeting", [
"name": String(friendly_name="Name", description="Name of person to greet", required=True, default="Alice")
])
def hello_world(name: str): dict[str, str]: # Exposed functions must return a JSON serializable dictionary
return {
"greeting": f"Hello {name}!"
}
handle() # Starts the n8n_py server and exposes the function declared above
Multi-File Projects
n8n_py can handle functions from anywhere as long as they are imported into the handler, and have the @expose_function decorator
File Structure
multi-file/
mapping.py
hello_world.py
hello_world.py
from n8n_py import expose_function, String
@expose_function("Hello World", "returns a friendly greeting", [
"name": String(friendly_name="Name", description="Name of person to greet", required=True, default="Alice")
])
def hello_world(name: str): dict[str, str]: # Exposed functions must return a JSON serializable dictionary
return {
"greeting": f"Hello {name}!"
}
mapping.py
from n8n_py.handler import handle
import hello_world as _ # Includes the exposed function.
handle() # Starts the n8n_py server and exposes all imported functions
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
n8n_py-0.0.2.tar.gz
(3.0 kB
view hashes)
Built Distribution
n8n_py-0.0.2-py3-none-any.whl
(3.3 kB
view hashes)