# n8n-nodes-runninghub-api

[![npm version](https://img.shields.io/npm/v/n8n-nodes-runninghub-api.svg)](https://www.npmjs.com/package/n8n-nodes-runninghub-api)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

English | [简体中文](README-ZH.md)

This is an n8n community node that lets you use [Runninghub](https://www.runninghub.cn) in your n8n workflows.

Runninghub is a cloud-based ComfyUI task execution platform that provides powerful AI image/video generation capabilities through an easy-to-use API.

[n8n](https://n8n.io/) is a [fair-code licensed](https://docs.n8n.io/sustainable-use-license/) workflow automation platform.

## Table of Contents

- [Installation](#installation)
- [Operations](#operations)
- [Credentials](#credentials)
- [Compatibility](#compatibility)
- [Usage](#usage)
- [Resources](#resources)
- [Version History](#version-history)

## Installation

Follow the [installation guide](https://docs.n8n.io/integrations/community-nodes/installation/) in the n8n community nodes documentation.

### Community Node Installation

1. Go to **Settings > Community Nodes** in your n8n instance
2. Select **Install**
3. Enter `n8n-nodes-runninghub-api` in the **Enter npm package name** field
4. Agree to the risks and select **Install**

After installation, the **Runninghub Api** node will be available in your workflow editor.

## Operations

This node supports **14 operations** across **6 resources**, providing complete coverage of the Runninghub API:

### 📋 Account
- **Get Account Info** - Retrieve account status including RH coins, running tasks, wallet balance, and API type

### 🚀 Task
- **Create Task** - Create a ComfyUI task based on a workflow template
- **Get Task Info** - Query task status (QUEUED, RUNNING, SUCCESS, FAILED)
- **Get Task Output** - Retrieve task results (images, videos, etc.)
- **Get Workflow Info** - Get workflow JSON configuration
- **Cancel Task** - Cancel a running or queued task

### ⚡ Quick Create
- **Get Model Params** - Retrieve quick creation model library style parameters
- **Run Quick Create** - Initiate a quick creation task

### 🤖 AI App
- **Run AI App** - Initiate an AI application task
- **Get API Call Demo** - Get API call example for AI applications

### 📁 File
- **Upload File** - Upload images, videos, audio, or ZIP files (max 30MB)
  - Supported formats: JPG, PNG, JPEG, WEBP (images), MP4, AVI, MOV, MKV (videos), MP3, WAV, FLAC (audio), ZIP (archives)
- **Get Lora Upload URL** - Get upload URL for Lora model files

### 🔔 Webhook
- **Get Webhook Detail** - Get webhook event details for debugging
- **Retry Webhook** - Resend a specific webhook event

## Credentials

### Prerequisites

1. Sign up for a Runninghub account at [https://www.runninghub.cn](https://www.runninghub.cn)
2. Navigate to your account settings to generate an API key

### Setting up credentials in n8n

1. In n8n, go to **Credentials > New**
2. Search for **Runninghub Api**
3. Enter your **API Key** from Runninghub
4. Click **Save**

### Testing credentials

The credentials include a built-in test that verifies your API key by calling the account status endpoint.

## Compatibility

- **Minimum n8n version**: 1.0.0
- **Tested against**: n8n 1.0.0+
- **Node API Version**: 1

This node has been tested and is compatible with the latest versions of n8n.

## Usage

### Basic Workflow Example

Here's a simple workflow to create a ComfyUI task and retrieve the results:

1. **Add Runninghub Api node** to your workflow
2. **Select Resource**: Task
3. **Select Operation**: Create Task
4. **Enter Workflow ID**: Your ComfyUI workflow template ID
5. **Optionally customize node parameters** by enabling "Send NodeInfo List"
6. **Add another Runninghub Api node** to poll for task completion
7. **Select Operation**: Get Task Output
8. **Use the Task ID** from the previous node

### Working with Node Parameters

When creating tasks, you can customize node parameters using the `nodeInfoList` field:

```json
[
  {
    "nodeId": "6",
    "fieldName": "text",
    "fieldValue": "A beautiful sunset over mountains"
  },
  {
    "nodeId": "3",
    "fieldName": "seed",
    "fieldValue": "12345"
  }
]
```

### File Upload Example

To upload an image for use in a workflow:

1. **Add Runninghub Api node**
2. **Select Resource**: File
3. **Select Operation**: Upload File
4. **Enter file path** or reference from previous node
5. **Select File Type**: Image/Video/Audio/Zip
6. **Use the returned fileName** in your task's nodeInfoList

### Webhook Integration

For long-running tasks, use webhooks to get notified when tasks complete:

1. Set up a webhook endpoint in your n8n workflow
2. When creating a task, add the `webhookUrl` parameter
3. Runninghub will POST results to your webhook when the task finishes

## Resources

- [n8n community nodes documentation](https://docs.n8n.io/integrations/#community-nodes)
- [Runninghub Official Website](https://www.runninghub.cn)
- [Runninghub API Documentation](https://www.runninghub.cn/runninghub-api-doc)
- [ComfyUI Documentation](https://github.com/comfyanonymous/ComfyUI)

## Version History

### 0.1.1 (Current)
- ✅ Complete implementation of all 14 Runninghub API endpoints
- ✅ Added Quick Create resource with 2 operations
- ✅ Added AI App resource with 2 operations
- ✅ Added File resource with 2 operations
- ✅ Added Webhook resource with 2 operations
- ✅ Enhanced all operations with detailed descriptions
- ✅ Fixed cancelTask export naming
- ✅ Improved parameter validation and error handling

### 0.1.0
- Initial release
- Basic Task and Account operations
- API Key authentication

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

[MIT](LICENSE.md)

## Support

If you encounter any issues or have questions:

1. Check the [Runninghub API Documentation](https://www.runninghub.cn/runninghub-api-doc)
2. Open an issue on [GitHub](https://github.com/denislov/n8n-nodes-runninghub-api/issues)
3. Contact the Runninghub support team

## Acknowledgments

- Built with [n8n-node-dev](https://github.com/n8n-io/n8n/tree/master/packages/node-dev)
- Integrates with [Runninghub](https://www.runninghub.cn) ComfyUI cloud platform
- Created by [denislov](https://github.com/denislov)

---

**Made with ❤️ for the n8n community**
