npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

n8n-nodes-sunx-perps

v1.2.9

Published

n8n node for SunX Perpetual Futures Trading

Readme

SunX Perps n8n Node - Project Summary

Overview

Complete n8n community node implementation for SunX Perpetual Futures API with all requested features.

✅ Implemented Features

Account Operations (2)

  1. ✅ Get Account Balance
  2. ✅ Get Trading Bills

Market Data Operations (7)

  1. ✅ Get Contract Info
  2. ✅ Get Swap Index Price
  3. ✅ Get Leverage Info (Risk Limit)
  4. ✅ Get Funding Rate
  5. ✅ Get Historical Funding Rate
  6. ✅ Get Multi-Asset Collateral
  7. ✅ Get Fee Info

Order Operations (10)

  1. ✅ Place Order
  2. ✅ Place Multiple Orders
  3. ✅ Cancel Order
  4. ✅ Cancel Multiple Orders
  5. ✅ Cancel All Orders
  6. ✅ Close Symbol at Market Price
  7. ✅ Close All at Market Price
  8. ✅ Get Current Orders
  9. ✅ Get Order History
  10. ✅ Get Order Info

Position Operations (4)

  1. ✅ Get Current Position
  2. ✅ Set Leverage
  3. ✅ Get Position Mode
  4. ✅ Set Position Mode

Total: 23 Operations Implemented

📁 Project Structure

n8n-nodes-sunx-perps/
├── credentials/
│   └── SunxPerpsApi.credentials.ts    # API authentication
├── nodes/
│   └── SunxPerps/
│       ├── SunxPerps.node.ts          # Main node with all operations
│       ├── SunxPerpsUtils.ts          # Auth & API utilities
│       └── sunx.svg                   # Node icon
├── .github/
│   ├── workflows/
│   │   └── ci.yml                     # CI/CD pipeline
│   └── ISSUE_TEMPLATE/
│       ├── bug_report.md
│       └── feature_request.md
├── package.json                        # Dependencies & scripts
├── tsconfig.json                       # TypeScript config
├── gulpfile.js                         # Build scripts
├── .eslintrc.js                        # Linting rules
├── .prettierrc.js                      # Code formatting
├── .gitignore
├── .npmignore
├── README.md                           # User documentation
├── DEVELOPMENT.md                      # Developer guide
├── TESTING.md                          # Testing guide
├── CHANGELOG.md                        # Version history
├── LICENSE.md                          # MIT License
└── example-workflow.json              # Example n8n workflow

🔑 Key Features

Authentication

  • ✅ HMAC SHA256 signature generation
  • ✅ Automatic timestamp handling
  • ✅ Full SunX API v2 authentication support
  • ✅ Secure credential storage

Error Handling

  • ✅ Comprehensive error messages
  • ✅ API error parsing
  • ✅ Continue on fail support
  • ✅ Detailed error context

API Coverage

  • ✅ All public endpoints (no auth required)
  • ✅ All authenticated endpoints
  • ✅ Query string parameter support
  • ✅ Request body support for POST/PUT

Developer Experience

  • ✅ TypeScript with full type safety
  • ✅ ESLint configuration
  • ✅ Prettier formatting
  • ✅ Build scripts
  • ✅ Development mode (watch)

📦 Files Created

Core Implementation (5 files)

  1. credentials/SunxPerpsApi.credentials.ts - API credential configuration
  2. nodes/SunxPerps/SunxPerps.node.ts - Main node with all 23 operations
  3. nodes/SunxPerps/SunxPerpsUtils.ts - Authentication & HTTP utilities
  4. nodes/SunxPerps/sunx.svg - Custom node icon
  5. gulpfile.js - Icon build script

Configuration (7 files)

  1. package.json - NPM package configuration
  2. tsconfig.json - TypeScript compiler options
  3. .eslintrc.js - ESLint rules
  4. .prettierrc.js - Code formatting rules
  5. .gitignore - Git exclusions
  6. .npmignore - NPM publish exclusions
  7. LICENSE.md - MIT License

Documentation (5 files)

  1. README.md - Installation & usage guide
  2. DEVELOPMENT.md - Developer documentation
  3. TESTING.md - Comprehensive testing guide
  4. CHANGELOG.md - Version history
  5. example-workflow.json - Sample n8n workflow

CI/CD & Templates (3 files)

  1. .github/workflows/ci.yml - GitHub Actions workflow
  2. .github/ISSUE_TEMPLATE/bug_report.md - Bug report template
  3. .github/ISSUE_TEMPLATE/feature_request.md - Feature request template

Total: 20 Files Created

🚀 Installation & Usage

Quick Start

  1. Install in n8n:

    npm install n8n-nodes-sunx-perps
  2. Configure Credentials:

    • Access Key ID
    • Secret Key
    • Base URL (default: https://api.sunx.io)
  3. Use in Workflow:

    • Add "SunX Perps" node
    • Select resource (Account, Market Data, Order, Position)
    • Select operation
    • Configure parameters
    • Execute!

Example Operations

Get Funding Rate:

  • Resource: Market Data
  • Operation: Get Funding Rate
  • Contract Code: BTC-USDT

Place Limit Order:

  • Resource: Order
  • Operation: Place Order
  • Contract Code: BTC-USDT
  • Direction: buy
  • Offset: open
  • Order Price Type: limit
  • Volume: 1
  • Price: 50000
  • Leverage Rate: 10

Get Account Balance:

  • Resource: Account
  • Operation: Get Balance

🔧 Development

Build

npm run build

Watch Mode

npm run dev

Lint

npm run lint
npm run lintfix

Format

npm run format

📊 API Endpoint Mapping

| Operation | Method | Endpoint | Auth | |-----------|--------|----------|------| | Get Balance | GET | /sapi/v1/account/balance | ✓ | | Get Trading Bills | GET | /sapi/v1/account/financial_record | ✓ | | Get Contract Info | GET | /sapi/v1/public/contract_info | ✗ | | Get Fee Info | GET | /sapi/v1/public/swap_fee | ✗ | | Get Funding Rate | GET | /sapi/v1/public/funding_rate | ✗ | | Get Historical Funding | GET | /sapi/v1/public/historical_funding_rate | ✗ | | Get Leverage Info | GET | /sapi/v1/public/swap_adjustfactor | ✗ | | Get Multi-Asset | GET | /sapi/v1/public/cross_transfer_info | ✗ | | Get Swap Index | GET | /sapi/v1/public/swap_index | ✗ | | Place Order | POST | /sapi/v1/order | ✓ | | Place Multiple Orders | POST | /sapi/v1/order/batch | ✓ | | Cancel Order | POST | /sapi/v1/order/cancel | ✓ | | Cancel All Orders | POST | /sapi/v1/order/cancelall | ✓ | | Close Symbol | POST | /sapi/v1/order/close_position | ✓ | | Close All | POST | /sapi/v1/order/close_all_position | ✓ | | Get Current Orders | GET | /sapi/v1/order/openorders | ✓ | | Get Order History | GET | /sapi/v1/order/hisorders | ✓ | | Get Order Info | GET | /sapi/v1/order/info | ✓ | | Get Position | GET | /sapi/v1/position/info | ✓ | | Set Leverage | POST | /sapi/v1/position/switch_lever_rate | ✓ | | Get Position Mode | GET | /sapi/v1/position/position_mode | ✓ | | Set Position Mode | POST | /sapi/v1/position/switch_position_mode | ✓ |

🎯 Next Steps

  1. Testing: Follow TESTING.md to test all operations
  2. Publishing: Publish to npm registry
  3. Documentation: Add to n8n community nodes registry
  4. Monitoring: Set up error tracking
  5. Updates: Monitor SunX API for changes

📝 Notes

  • All 23 requested operations are fully implemented
  • Authentication uses HMAC SHA256 as per SunX API requirements
  • Public endpoints don't require authentication
  • Error handling includes API-specific error messages
  • Supports both single and batch operations
  • Includes comprehensive documentation
  • Ready for npm publishing
  • CI/CD pipeline configured

🤝 Support

  • GitHub: Create an issue for bugs or features
  • n8n Community: https://community.n8n.io/
  • SunX Docs: https://docs.sunx.io

Status: ✅ Complete and Ready for Use Version: 1.0.0 License: MIT