@xhilo/pi-sdk
v0.2.23
Published
A simplified SDK for Pi Network integration with React frontend and Node.js backend support - no provider needed!
Maintainers
Readme
Pi SDK
A unified SDK for Pi Network integration with React frontend and Node.js backend support.
🏗️ Architecture
The Pi SDK uses a configuration-driven architecture for backend operations:
- User-to-App (U2A) Payments: Uses
piPlatformFetchClientanduserToAppPaymentactions - App-to-User (A2U) Payments: Uses
pi-backend-sdkandappToUserPaymentactions - Configuration Required: All backend functions require explicit configuration parameters
- No Environment Dependencies: SDK functions don't read from environment variables
- Consistent Error Handling: All actions return standardized
PiOperationResulttypes - Type Safety: Full TypeScript support with comprehensive type definitions
- Security: Optional access token validation for enhanced security
🚀 Quick Start
# Install the SDK
npm install @xhilo/pi-sdk
# Create a new Next.js app with template
npx create-next-app@latest my-pi-app --template @xhilo/pi-sdk/nextjs📚 Documentation
Complete documentation is available at: pi-sdk-docs
Essential Guides
- Configuration Guide - Start here for proper setup
- Real Examples - Working examples based on actual implementation
- API Reference - Complete API documentation
Quick Links
🎯 Key Features
React Hooks
useXhiloPiNetwork- Core Pi Network integration with robust state managementusePiPayments- Complete payment lifecycle management with backend integrationusePiSimplePayments- Simplified payment processing using createAndMakePaymentusePiAds- Ads functionality (currently stub implementation)usePiAdsSimple- Simple ads functionality (currently stub implementation)
Backend Actions
processA2UWithdrawalAction- Server-side A2U payment processingcreateAndMakeA2UPayment- High-level A2U payment helperapprovePaymentAction- Server-side U2A payment approvalcompletePaymentAction- Server-side U2A payment completionverifyRewardedAdAction- Ads verification and reward processinggetAdEligibilityAction- Check user ad eligibilitygetUserAdStatsAction- Get user ad statisticspiPlatformFetchClient- Pi Platform API integration utilities
Configuration Management
The SDK requires explicit configuration - no environment variable dependencies:
// Backend Configuration
const piBackendConfig = {
apiKey: process.env.PI_API_KEY!,
privateSeed: process.env.PI_WALLET_PRIVATE_SEED!
}
// Platform Configuration
const piPlatformConfig = {
apiKey: process.env.PI_API_KEY!
}
// All backend functions require config
await processA2UWithdrawalAction(args, piBackendConfig)
await approvePaymentAction(args, piPlatformConfig)Environment Variables (for application code only):
# Required for your application
PI_API_KEY=your_pi_api_key
PI_WALLET_PRIVATE_SEED=your_wallet_private_seed🔗 Links
- npm Package: @xhilo/pi-sdk
- GitHub Repository: pi-sdk
- Pi Network Docs: developers.minepi.com
📞 Support & Contact
- Discord: realhavenn
- Telegram: realhavenn
- X (Twitter): realhavenn
- GitHub: Nanasark
Support Channels:
- Issues: GitHub Issues
- Discussions: GitHub Discussions
📄 License
MIT License - see LICENSE file for details.
Built with ❤️ for the Pi Network community by realhavenn
