Package Information
Downloads: 42 weekly / 107 monthly
Latest Version: 1.2.9
Author: Deepak Dhaka
Available Nodes
Documentation
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)
- ✅ Get Account Balance
- ✅ Get Trading Bills
Market Data Operations (7)
- ✅ Get Contract Info
- ✅ Get Swap Index Price
- ✅ Get Leverage Info (Risk Limit)
- ✅ Get Funding Rate
- ✅ Get Historical Funding Rate
- ✅ Get Multi-Asset Collateral
- ✅ Get Fee Info
Order Operations (10)
- ✅ Place Order
- ✅ Place Multiple Orders
- ✅ Cancel Order
- ✅ Cancel Multiple Orders
- ✅ Cancel All Orders
- ✅ Close Symbol at Market Price
- ✅ Close All at Market Price
- ✅ Get Current Orders
- ✅ Get Order History
- ✅ Get Order Info
Position Operations (4)
- ✅ Get Current Position
- ✅ Set Leverage
- ✅ Get Position Mode
- ✅ 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)
credentials/SunxPerpsApi.credentials.ts- API credential configurationnodes/SunxPerps/SunxPerps.node.ts- Main node with all 23 operationsnodes/SunxPerps/SunxPerpsUtils.ts- Authentication & HTTP utilitiesnodes/SunxPerps/sunx.svg- Custom node icongulpfile.js- Icon build script
Configuration (7 files)
package.json- NPM package configurationtsconfig.json- TypeScript compiler options.eslintrc.js- ESLint rules.prettierrc.js- Code formatting rules.gitignore- Git exclusions.npmignore- NPM publish exclusionsLICENSE.md- MIT License
Documentation (5 files)
README.md- Installation & usage guideDEVELOPMENT.md- Developer documentationTESTING.md- Comprehensive testing guideCHANGELOG.md- Version historyexample-workflow.json- Sample n8n workflow
CI/CD & Templates (3 files)
.github/workflows/ci.yml- GitHub Actions workflow.github/ISSUE_TEMPLATE/bug_report.md- Bug report template.github/ISSUE_TEMPLATE/feature_request.md- Feature request template
Total: 20 Files Created
🚀 Installation & Usage
Quick Start
Install in n8n:
npm install n8n-nodes-sunx-perpsConfigure Credentials:
- Access Key ID
- Secret Key
- Base URL (default: https://api.sunx.io)
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
- Testing: Follow TESTING.md to test all operations
- Publishing: Publish to npm registry
- Documentation: Add to n8n community nodes registry
- Monitoring: Set up error tracking
- 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