Wallets API
Manage multi-asset cryptocurrency wallets with real-time balance tracking and automatic valuation.
Overview
The Wallets API allows you to create and manage cryptocurrency wallets for your users. Each wallet is associated with a specific crypto asset (BTC, ETH, YANI, etc.) and tracks both available and locked balances.
Supported Assets
Encryption
Price Updates
YaniChain Wallets
Les wallets YaniPay sont nativement compatibles avec YaniChain, permettant une gestion simplifiée des tokens YANI et de tous les actifs de l'écosystème. La sécurité est assurée par un chiffrement 256-bit et des smart contracts audités.
Y.A.N.I. Sécurise Vos Wallets
Authentication
All Wallets API endpoints require authentication. Include the user's session token in the request headers or use NextAuth session cookies.
const response = await fetch('/api/defi/wallets', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
// Session cookie automatically included
},
credentials: 'include',
});GET /api/defi/wallets
Retrieve all wallets for the authenticated user with current balances and valuations.
Request
GET /api/defi/wallets HTTP/1.1
Host: localhost:3000
Cookie: next-auth.session-token=...Response
1 { 2 "wallets": [ 3 { 4 "id": "wallet_123", 5 "asset": { 6 "symbol": "YANI", 7 "name": "YANICoin", 8 "logoUrl": "https://...", 9 "network": "YaniChain" 10 }, 11 "balance": 1000.0, 12 "lockedBalance": 250.0, 13 "availableBalance": 750.0, 14 "value": { 15 "usd": 1500.50, 16 "eur": 1380.45 17 }, 18 "price": { 19 "usd": 1.50, 20 "eur": 1.38, 21 "change24h": 5.2 22 }, 23 "publicAddress": "0x742d35Cc6634C0532925a3b844D23aDF..." 24 } 25 ], 26 "portfolio": { 27 "totalValueUsd": 15420.75, 28 "totalValueEur": 14186.88 29 } 30 }
Response Fields
| Field | Type | Description |
|---|---|---|
wallets | array | Array of wallet objects |
balance | number | Total balance in wallet |
lockedBalance | number | Balance locked in staking/farming |
availableBalance | number | Available for transactions (balance - locked) |
value.usd | number | Wallet value in USD |
price.change24h | number | 24-hour price change percentage |
GET /api/defi/wallets/[id]
Get detailed information about a specific wallet including transaction history.
Request
GET /api/defi/wallets/wallet_123 HTTP/1.1
Host: localhost:3000Response
{
"wallet": {
"id": "wallet_123",
"asset": { "symbol": "YANI", "name": "YANICoin" },
"balance": 1000.0,
"lockedBalance": 250.0,
"publicAddress": "0x742d35Cc6634C0532925a3b844D23aDF...",
"createdAt": "2026-01-01T00:00:00Z"
},
"transactions": [
{
"id": "tx_456",
"type": "DEPOSIT",
"amount": 100.0,
"from": "0x123...",
"timestamp": "2026-01-15T12:00:00Z"
}
],
"stats": {
"totalDeposits": 5000.0,
"totalWithdrawals": 4000.0,
"transactionCount": 42
}
}POST /api/defi/wallets
Create a new wallet for a specific asset. Only one wallet per asset per user is allowed.
Request
{
"assetSymbol": "YANI",
"publicAddress": "0x742d35Cc6634C0532925a3b844D23aDF..." // optional
}Response
{
"success": true,
"message": "Wallet created successfully",
"wallet": {
"id": "wallet_789",
"assetSymbol": "YANI",
"balance": 0.0,
"createdAt": "2026-01-16T10:30:00Z"
}
}PUT /api/defi/wallets/[id]
Update wallet balance. This endpoint is typically used internally for deposits and withdrawals.
Request
{
"operation": "DEPOSIT", // or "WITHDRAW"
"amount": 100.0,
"reason": "User deposit via bank transfer"
}Response
{
"success": true,
"message": "Balance updated successfully",
"wallet": {
"id": "wallet_123",
"balance": 1100.0,
"availableBalance": 850.0
}
}Error Codes
The Wallets API uses standard HTTP status codes:
| Code | Description |
|---|---|
200 | Success |
400 | Bad Request - Invalid parameters |
401 | Unauthorized - Authentication required |
404 | Not Found - Wallet doesn't exist |
409 | Conflict - Wallet already exists for this asset |
500 | Internal Server Error |
Error Response Example
{
"error": "Wallet already exists for this asset",
"code": "WALLET_EXISTS",
"assetSymbol": "YANI"
}