npm package: @imocat/n8n-nodes-sj
Description: n8n node for Shanjian API integration
Author: Your Name
Latest version: 0.2.0

# n8n-nodes-sj

This is an n8n community node that allows you to integrate with Shanjian (闪剪) AI Open Platform API in your n8n workflows.

Shanjian is an AI-powered platform for digital human cloning, voice cloning, and video synthesis.

[n8n](https://n8n.io/) is a [fair-code licensed](https://docs.n8n.io/reference/license/) workflow automation platform.

## Installation

Follow the [installation guide](https://docs.n8n.io/integrations/community-nodes/installation/) in the n8n community nodes documentation.

### Community Nodes (Recommended)

1. Go to **Settings > Community Nodes**
2. Select **Install**
3. Enter `n8n-nodes-sj` in **Enter npm package name**
4. Agree to the [risks](https://docs.n8n.io/integrations/community-nodes/risks/) of using community nodes
5. Select **Install**

### Manual Installation

To install this node manually, run:

```bash
npm install n8n-nodes-sj
```

## Configuration

Before using this node, you need to configure your Shanjian API credentials:

1. In n8n, go to **Credentials > New**
2. Search for **Shanjian API**
3. Enter your Shanjian API details:
   - **Domain**: `https://openapi.shanjian.tv` (default)
   - **API Key**: Your Shanjian API key (get it from https://openapi-doc.shanjian.tv/)

## Operations

This node supports the following operations:

### Cloning Resource

Digital human and voice cloning operations:

- **Professional Digital Human**: Clone a professional digital human from video
  - Requires: Video URL, Auth Video URL, Auth Text, Green Background flag (optional)
  - Endpoint: `/v1/virtualman/train`

- **Fast Digital Human**: Quick clone a digital human
  - Requires: Video URL, Auth Video URL, Auth Text
  - Endpoint: `/v1/virtualman/fast/train`

- **Voice**: Clone a voice from audio
  - Requires: Audio URL, Auth Audio URL, Auth Text
  - Endpoint: `/v1/voice/train`

- **Image to Digital Human**: Convert an image to a digital human
  - Requires: Image URL, Voice ID, Auth Image URL, Auth Text
  - Endpoint: `/v1/virtualman/image/train`

### Video Synthesis Resource

Video generation and synthesis operations:

- **Digital Human Voiceover**: Create digital human voiceover video (unpackaged)
  - Requires: Digital Human ID, Text content
  - Endpoint: `/v1/virtualman/video`

- **Digital Human Mixed Clip**: Create digital human mixed clip video
  - Requires: Anchor ID, Script, Video Materials (JSON array)
  - Endpoint: `/v1/clip/video/virtualman_broadcast`

- **Real Person Mixed Clip**: Create real person mixed clip video
  - Requires: Anchor ID, Script, Video Materials (JSON array)
  - Endpoint: `/v1/clip/video/realman_broadcast`

- **Material Mixed Clip**: Create material-only mixed clip video
  - Requires: Script, Video Materials (JSON array), Voice ID
  - Endpoint: `/v1/clip/video/broadcast_mixcut`

### Task Resource

Task management and monitoring:

- **Get Task Info**: Query task details and status
  - Requires: Task ID
  - Endpoint: `/v1/task/info`

## Usage Examples

### Clone a Professional Digital Human

1. Add the **Shanjian** node to your workflow
2. Select **Cloning** as the resource
3. Select **Professional Digital Human** as the operation
4. Configure the parameters:
   - **Video URL**: URL of your training video
   - **Auth Video URL**: URL of your authorization video
   - **Auth Text**: Authorization text (e.g., "闪剪")
   - **Is Green Background**: Toggle if using green screen
   - **Callback URL**: Optional webhook URL for completion notification
5. Connect your Shanjian API credentials
6. Execute the node

### Create a Digital Human Video

1. Add the **Shanjian** node to your workflow
2. Select **Video Synthesis** as the resource
3. Select **Digital Human Voiceover** as the operation
4. Configure the parameters:
   - **Digital Human ID**: ID from your cloned digital human
   - **Text**: Script content for the video
   - **Callback URL**: Optional webhook URL for completion notification
5. Connect your Shanjian API credentials
6. Execute the node

### Check Task Status

1. Add the **Shanjian** node to your workflow
2. Select **Task** as the resource
3. Select **Get Task Info** as the operation
4. Enter the **Task ID** (from a previous cloning or synthesis operation)
5. Connect your Shanjian API credentials
6. Execute the node

## Compatibility

This node has been tested with:
- n8n version: 1.0.0+
- Node.js version: 18+

## API Response Format

All operations return task information in the following format:

```json
{
  "code": 0,
  "msg": "success",
  "data": {
    "taskId": "task_xxx",
    "status": "pending|processing|completed|failed",
    "result": {
      // Operation-specific result data
    }
  }
}
```

## Resources

- [n8n community nodes documentation](https://docs.n8n.io/integrations/community-nodes/)
- [Shanjian API Documentation](https://openapi-doc.shanjian.tv/)

## Development

### Setup

```bash
# Install dependencies
npm install

# Build the node
npm run build

# Link to n8n (for local development)
npm link
cd ~/.n8n/custom
npm link n8n-nodes-sj
```

### Testing

To test the node in your local n8n instance:

```bash
# Start n8n
n8n start
```

Then navigate to `http://localhost:5678` and search for "Shanjian" in the nodes panel.

## License

[MIT](LICENSE.md)

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## Support

If you have any questions or issues, please open an issue on the [GitHub repository](https://github.com/yourusername/n8n-nodes-sj/issues).