/wallets/{name}
GET DELETE SYNCGet information about a specific wallet or delete a wallet.
Description
This endpoint allows you to retrieve details about a specific wallet (GET) or delete a wallet (DELETE). The wallet is identified by its name, which must be provided in the URL path.
This is a synchronous API call that returns results immediately, without creating a task.
Parameters
Path Parameters
Parameter | Type | Required | Description |
---|---|---|---|
name |
string | Yes | The name of the wallet to retrieve or delete. |
GET /wallets/{name}
Returns detailed information about the specified wallet, including its balance, denomination breakdown, and transaction history.
Response
Returns a 200 OK response with a JSON object containing details about the specified wallet.
Response Properties (Wallet Object)
Transaction Object Properties
Example Response
{
"name": "Default",
"email": "",
"password_hash": "",
"balance": 3000000020,
"denominations": {
"0": 0,
"1": 3,
"2": 0,
"3": 0,
"4": 0,
"5": 0,
"6": 0,
"248": 0,
"249": 2,
"250": 0,
"251": 0,
"252": 0,
"253": 0,
"254": 0,
"255": 0
},
"transactions": [
{
"amount": 3000000020,
"message": "Receive",
"type": "GetFromLocker",
"datetime": "2023-03-10T10:01:06+03:00",
"receiptid": "f3e1d60e2461e8c5832ca9f0a617a988",
"details": null,
"running_balance": 3000000020,
"negative": false
},
{
"amount": 18446744070709551000,
"message": "Balance Adjustment",
"type": "Adjustment",
"datetime": "2023-03-10T10:02:04+03:00",
"receiptid": "-",
"details": null,
"running_balance": 0,
"negative": false
}
// Additional transactions omitted for brevity
],
"amount_stats": {
"Bank": 3000000020
}
}
DELETE /wallets/{name}
Deletes the specified wallet. This action is permanent and cannot be undone.
Response
Returns a 200 OK response if the wallet was successfully deleted.
Deleting a wallet will permanently remove all its data, including transaction history and any CloudCoins stored in it. Make sure to back up any important information before deleting a wallet.
Examples
JavaScript Example - GET Wallet
// Using Fetch API to get a specific wallet
const apiHost = 'http://localhost:8004';
const walletName = 'Default'; // Replace with the wallet name you want to retrieve
fetch(`${apiHost}/api/v1/wallets/${encodeURIComponent(walletName)}`)
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
return response.json();
})
.then(wallet => {
console.log('Wallet details:', wallet);
// Display wallet information
console.log(`Wallet: ${wallet.name}`);
console.log(`Balance: ${wallet.balance}`);
console.log(`Transactions: ${wallet.transactions.length}`);
// Display denomination breakdown
console.log('Denominations:');
for (const [denom, count] of Object.entries(wallet.denominations)) {
if (count > 0) {
console.log(` Denomination ${denom}: ${count} coins`);
}
}
// Display recent transactions
console.log('Recent transactions:');
const recentTransactions = wallet.transactions.slice(0, 3); // Show 3 most recent
recentTransactions.forEach(tx => {
console.log(` ${tx.datetime}: ${tx.type} - ${tx.amount} (${tx.message})`);
});
})
.catch(error => {
console.error(`Error fetching wallet "${walletName}":`, error);
});
// JavaScript Example - DELETE Wallet
function deleteWallet(walletName) {
if (!confirm(`Are you sure you want to delete the wallet "${walletName}"? This action cannot be undone.`)) {
return; // User cancelled the operation
}
fetch(`${apiHost}/api/v1/wallets/${encodeURIComponent(walletName)}`, {
method: 'DELETE'
})
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
console.log(`Wallet "${walletName}" deleted successfully!`);
})
.catch(error => {
console.error(`Error deleting wallet "${walletName}":`, error);
});
}
// Call the function to delete a wallet (uncomment to use)
// deleteWallet('WalletToDelete');
cURL Example - GET Wallet
# Get a specific wallet by name
curl -X GET "http://localhost:8004/api/v1/wallets/Default" -H "accept: application/json"
# Example response (truncated for brevity):
# {"name":"Default","email":"","password_hash":"","balance":3000000020,"denominations":{"0":0,"1":3,...},"transactions":[...],"amount_stats":{"Bank":3000000020}}
cURL Example - DELETE Wallet
# Delete a wallet
curl -X DELETE "http://localhost:8004/api/v1/wallets/WalletToDelete" -H "accept: application/json"
# The response should be an empty 200 OK if successful