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.
- 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.
To install pyn8n, run:
pip install pyn8n
- n8n Instance: Ensure you have an n8n instance running locally or hosted.
- API Key: Generate an API key in your n8n settings for secure access.
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.
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)
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": "[email protected]", "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)
from pyn8n import Credential
# Add credentials
client.create_credential(Credential(name="Google Sheets API", type="google", data={"api_key": "your_google_api_key"}))
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
Run tests with:
poe test
We welcome contributions! Follow these steps to get started:
- Fork the repository and create a new branch for your changes.
- Run
poe lint
to check code style. - Submit a pull request with a detailed description of your changes.
For detailed contribution guidelines, see CONTRIBUTING.md
.
- Dynamic Node Mapping: Automatically generate and sync node configurations based on n8n instances.
- Ash Framework Backend: Optional integration for handling state machines, advanced orchestration, and resource management.
- Enterprise Integrations: Extend n8n workflows with enterprise-grade observability and governance.
- Error Handling and Retries: Built-in support for managing failed executions with fallback strategies.
- Interactive Workflow Creation: Use natural language or the Python API to define workflows programmatically.
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 [email protected] for more details.
- AI-Assisted Workflow Suggestions
- Marketplace Integration for Pre-Built Workflows
- Advanced Analytics Dashboards
- Cross-Platform Automation
pyn8n is released under the MIT License.
Happy automating! 🚀