Skip to main content

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.6.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

n8n_py-0.0.6-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file n8n_py-0.0.6.tar.gz.

File metadata

  • Download URL: n8n_py-0.0.6.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.1.dev0+g94f810c.d20240510 CPython/3.12.5

File hashes

Hashes for n8n_py-0.0.6.tar.gz
Algorithm Hash digest
SHA256 28169a5884404c4d9da09d01869f583e3fb63ef947373eb969cbd1cde0e84fdb
MD5 11822024984e758adaba970e6fec5b18
BLAKE2b-256 4710a1bd01690d9e442157a53bc9d7e1c6237903f0ebf0b27d7db28c0b6c792a

See more details on using hashes here.

File details

Details for the file n8n_py-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: n8n_py-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.1.dev0+g94f810c.d20240510 CPython/3.12.5

File hashes

Hashes for n8n_py-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 dc1e237203ee2083475e32b781a2ae1079a771d06908ec99a7c460df962f5ae1
MD5 5229b6a5b05a5231c6e48d452fdbac2c
BLAKE2b-256 9d77b45ecc11d7beaf3b3a9b79f4a6765ae4b5fc3fb243949cd5a2c07320c1c9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page