-
Notifications
You must be signed in to change notification settings - Fork 1
Types
alxspiker edited this page Jul 31, 2025
·
2 revisions
Complete reference for Pi Network API object structures and schemas
Essential data types for Pi SDK and API integration
Essential data types for Pi SDK and API integration
🎯 Returned by
Pi.authenticate()- contains user data and access token
Use Case: Frontend authentication result containing user information and API access token
type AuthResult = {
accessToken: string, // Bearer token for API calls
user: {
uid: string, // App-specific user identifier
username?: string, // Pi Network username (if 'username' scope granted)
credentials: {
scopes: string[], // Granted permission scopes
valid_until: {
timestamp: number, // Unix timestamp
iso8601: string // ISO 8601 formatted date
}
}
}
}{
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"user": {
"uid": "pioneer_app_specific_id_123",
"username": "pioneer_username",
"credentials": {
"scopes": ["payments", "username"],
"valid_until": {
"timestamp": 1709007140,
"iso8601": "2024-02-27T04:12:20Z"
}
}
}
}const auth = await Pi.authenticate(['payments'], onIncompletePaymentFound);
console.log('User ID:', auth.user.uid);
console.log('Access Token:', auth.accessToken);
console.log('Expires:', auth.user.credentials.valid_until.iso8601);🎯 Comprehensive payment data from Pi Network API payment endpoints
Use Case: Detailed payment information including status, blockchain data, and metadata
type PaymentDTO = {
// 💳 Payment Information
identifier: string, // Unique payment ID
Pioneer_uid: string, // Pioneer's app-specific ID
amount: number, // Payment amount in Pi
memo: string, // Developer-provided description
metadata: Object, // Custom developer data
to_address: string, // Recipient blockchain address
created_at: string, // Payment creation timestamp
// 📊 Status Tracking
status: {
developer_approved: boolean, // Server-side approval
transaction_verified: boolean, // Blockchain verification
developer_completed: boolean, // Server-side completion
canceled: boolean, // Canceled by developer/Pi Network
Pioneer_cancelled: boolean, // Canceled by Pioneer
},
// ⛓️ Blockchain Data (if transaction exists)
transaction: null | {
txid: string, // Blockchain transaction ID
verified: boolean, // Transaction verification status
_link: string, // Blockchain API operation link
}
}{
"identifier": "payment_12345abcdef",
"Pioneer_uid": "pioneer_app_id_456",
"amount": 5.25,
"memo": "Premium subscription upgrade",
"metadata": {
"plan_type": "premium",
"duration": "monthly",
"user_id": "internal_user_789"
},
"to_address": "pi1abc123def456...",
"created_at": "2024-02-27T10:30:00Z",
"status": {
"developer_approved": true,
"transaction_verified": true,
"developer_completed": true,
"canceled": false,
"Pioneer_cancelled": false
},
"transaction": {
"txid": "blockchain_tx_hash_xyz789",
"verified": true,
"_link": "https://api.blockchain.pi/operations/xyz789"
}
}🎯 User information returned by Pi Network API endpoints like
/me
Use Case: Basic Pioneer information from authenticated API calls
type UserDTO = {
uid: string, // App-specific unique identifier
username?: string, // Pi Network username (requires 'username' scope)
}{
"uid": "pioneer_app_specific_id_123",
"username": "pioneer_username"
}// Get user info via API call
const response = await fetch('https://api.minepi.com/v2/me', {
headers: { 'Authorization': `Bearer ${accessToken}` }
});
const userDTO = await response.json();
console.log('Pioneer UID:', userDTO.uid);
// Username only available if 'username' scope was granted during authentication
if (userDTO.username) {
console.log('Pioneer Username:', userDTO.username);
}🔐 Privacy & Scopes:
-
uidis always available for authenticated requests -
usernamerequires the'username'scope duringPi.authenticate() - The
uidis app-specific and differs across applications for privacy
- Authorization - How to authenticate and get access tokens
- API Reference - Complete API endpoint documentation
- SDK Reference - Pi SDK methods and usage
- Examples - Working code samples using these types
- 🏠 Home - Complete developer handbook
- 🆘 Community Support - Get help from Pi developers
- 🔐 Authorization - Authentication & security patterns
- 🔌 API Reference - Complete REST API documentation
- ⚡ SDK Reference - JavaScript SDK comprehensive guide
- 📋 Data Types - Object structures & schemas
- 🌐 Pi Browser Detection - Build hybrid Web2/Web3 apps
- 🔄 Migration Guide - Upgrade to hybrid architecture
- 💻 Code Examples - Production-ready samples & templates
- 🌍 What is PiNet? - Cross-platform app accessibility
- 💳 What is PiWallet? - Pi Network wallet integration
- 💰 Payments Overview - Transaction handling guide
- 💬 Chat Rooms for Apps - Community engagement features
- 🔄 Mainnet vs. Testnet - Environment selection guide
- 📋 Developer Terms - Terms of service
- ⚖️ Social Chain ToS - Platform terms
- 📄 Whitepaper - Pi Network foundations
💡 Need help? Join our Discord community!