Skip to main content

N8N client and AI tools.

Project description

pyn8n v4

pyn8n is an advanced Python client and automation toolkit designed to extend and enhance the functionality of n8n. This new release introduces dynamic integration capabilities, conversational automation tools, and a seamless developer experience for orchestrating workflows with Python. It integrates directly with n8n while leveraging Python's flexibility to tackle advanced use cases, ensuring a smooth, efficient, and scalable automation process.


🚀 Features

  • Dynamic Workflow Generation: Create, manage, and monitor workflows programmatically using a Pythonic API.
  • Conversational CLI: Use natural language to define workflows with an interactive CLI powered by AI.
  • Ash Framework Integration: Enable advanced orchestration and business logic layers with Ash while remaining invisible to n8n automators.
  • n8n API Wrapper: Simplified and robust interaction with n8n’s REST APIs, including node discovery and dynamic updates.
  • Plug-and-Play Extensibility: Add custom nodes, integrations, and pre-built actions with minimal setup.
  • Enterprise-Grade Governance: Monitor workflows, track execution logs, and implement error handling for compliance-ready automation.

🛠️ Installation

To install pyn8n, run:

pip install pyn8n

🔧 Configuration

Prerequisites

  1. n8n Instance: Ensure you have an n8n instance running locally or hosted.
  2. API Key: Generate an API key in your n8n settings for secure access.

Environment Variables

Create a .env file in your project directory with the following:

N8N_BASE_URL=http://localhost:5678
N8N_API_KEY=your_api_key_here

Or set them directly in your environment.


📚 Usage

CLI

Run the following command to start the interactive CLI:

pyn8n

Example:

$ pyn8n
Welcome to pyn8n! What would you like to automate today?
> Send an email when a new row is added to Google Sheets.
> Generating workflow...
> Workflow created! Would you like to run it now? (yes/no)

Python API

Creating a Workflow

from pyn8n import N8nClient, Workflow

# Initialize client
client = N8nClient(base_url="http://localhost:5678", api_key="your_api_key")

# Define a workflow
workflow = Workflow(
    name="New Row Email Notification",
    nodes=[
        {
            "id": "1",
            "type": "trigger",
            "parameters": {"sheet": "ExampleSheet"},
            "position": [200, 150],
        },
        {
            "id": "2",
            "type": "email",
            "parameters": {"recipient": "user@example.com", "message": "New row added!"},
            "position": [400, 150],
        },
    ],
    connections={"1": ["2"]},
)

# Create and activate workflow
created_workflow = client.create_workflow(workflow)
client.activate_workflow(created_workflow.id)

Managing Credentials

from pyn8n import Credential

# Add credentials
client.create_credential(Credential(name="Google Sheets API", type="google", data={"api_key": "your_google_api_key"}))

🧑‍💻 Development

Running Locally

Clone the repository and start a development environment:

git clone https://github.com/user/seanchatmangpt/pyn8n.git
cd pyn8n

# Using Docker
docker compose up --detach dev
docker compose exec dev zsh

# Or, using Codespaces or VS Code Dev Containers

Testing

Run tests with:

poe test

🤝 Contributing

We welcome contributions! Follow these steps to get started:

  1. Fork the repository and create a new branch for your changes.
  2. Run poe lint to check code style.
  3. Submit a pull request with a detailed description of your changes.

For detailed contribution guidelines, see CONTRIBUTING.md.


🌟 Features in v4

  1. Dynamic Node Mapping: Automatically generate and sync node configurations based on n8n instances.
  2. Ash Framework Backend: Optional integration for handling state machines, advanced orchestration, and resource management.
  3. Enterprise Integrations: Extend n8n workflows with enterprise-grade observability and governance.
  4. Error Handling and Retries: Built-in support for managing failed executions with fallback strategies.
  5. Interactive Workflow Creation: Use natural language or the Python API to define workflows programmatically.

💼 For Enterprises

For enterprise users, pyn8n offers support for:

  • Role-based Access Control (RBAC)
  • Custom Node Libraries
  • Advanced Logging and Monitoring
  • Dedicated Support and SLAs

Contact us at enterprise@pyn8n.io for more details.


🛣️ Roadmap

  • AI-Assisted Workflow Suggestions
  • Marketplace Integration for Pre-Built Workflows
  • Advanced Analytics Dashboards
  • Cross-Platform Automation

📜 License

pyn8n is released under the MIT License.

Happy automating! 🚀

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

pyn8n-2024.12.24.4.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyn8n-2024.12.24.4-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

Details for the file pyn8n-2024.12.24.4.tar.gz.

File metadata

  • Download URL: pyn8n-2024.12.24.4.tar.gz
  • Upload date:
  • Size: 18.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.0 Darwin/23.5.0

File hashes

Hashes for pyn8n-2024.12.24.4.tar.gz
Algorithm Hash digest
SHA256 ce274615970370f8e6a8a6e0a7457eb48f4e5a622b44891f8eaeeb56d42230c6
MD5 5f21d75f9dc28bddef2267023f36a992
BLAKE2b-256 da21127456a7252cb39e9275334f13a2acb815ffed9db0809e5553729c6344bc

See more details on using hashes here.

File details

Details for the file pyn8n-2024.12.24.4-py3-none-any.whl.

File metadata

  • Download URL: pyn8n-2024.12.24.4-py3-none-any.whl
  • Upload date:
  • Size: 19.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.0 Darwin/23.5.0

File hashes

Hashes for pyn8n-2024.12.24.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d2f391f1ebd99410923fc7366482cf26a9a87c65eb126a9412c7c8d39459a4d4
MD5 ff57cb9e1ec888c158d42e1dc5e1ac82
BLAKE2b-256 c1ab0e169474ec4f075f89991f2a04d35052dfaa6f18b38748f0d3dff50930d3

See more details on using hashes here.

Supported by

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