> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: getAccount(_id: string) # Method package: wixLoyaltyV2 # Method menu location: wixLoyaltyV2 --> accounts --> getAccount # Method Link: https://dev.wix.com/docs/velo/apis/wix-loyalty-v2/accounts/get-account.md # Method Description: Retrieves a loyalty account by ID. You can also retrieve an account using a secondary ID, such as a contact ID or a member ID by calling Get Account by Secondary ID. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Get a loyalty account (dashboard page code) ```javascript import { accounts } from 'wix-loyalty.v2'; // Sample accountId value: 'e6f39a5b-a6d0-4556-b889-0cf09d8a84f7' export async function myGetLoyaltyAccountFunction() { try { const loyaltyAccount = await accounts.getAccount(accountId); const currentBalance = loyaltyAccount.account.points.balance; const canGetReward = loyaltyAccount.account.rewardAvailable; console.log('Success! Current points balance for this account is: ', currentBalance, ' and there is a reward available: ', canGetReward); return loyaltyAccount; } catch (error) { console.error(error); } } /* Promise resolves to: * { * "account": { * "_id": "e6f39a5b-a6d0-4556-b889-0cf09d8a84f7", * "contactId": "88615e02-3e8a-4297-8939-5d0a432b322a", * "memberId": "a517751b-a1ca-4423-8d91-aaf8f5b34215", * "points": { * "balance": 15, * "earned": 10, * "redeemed": 0, * "adjusted": 5 * }, * "rewardAvailable": true, * "_createdDate": "2021-12-06T14:33:19.114Z", * "_updatedDate": "2021-12-07T07:30:23.749Z", * "revision": "4" * } * } */ ``` ## Get a loyalty account (export from backend code) ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { accounts } from 'wix-loyalty.v2'; // Sample accountId value: 'e6f39a5b-a6d0-4556-b889-0cf09d8a84f7' export const myGetLoyaltyAccountFunction = webMethod( Permissions.Anyone, async () => { try { const loyaltyAccount = await accounts.getAccount(accountId); const currentBalance = loyaltyAccount.account.points.balance; const canGetReward = loyaltyAccount.account.rewardAvailable; console.log('Success! Current points balance for this account is: ', currentBalance, ' and there is a reward available: ', canGetReward); return loyaltyAccount; } catch (error) { console.error(error); } }); /* Promise resolves to: * { * "account": { * "_id": "e6f39a5b-a6d0-4556-b889-0cf09d8a84f7", * "contactId": "88615e02-3e8a-4297-8939-5d0a432b322a", * "memberId": "a517751b-a1ca-4423-8d91-aaf8f5b34215", * "points": { * "balance": 15, * "earned": 10, * "redeemed": 0, * "adjusted": 5 * }, * "rewardAvailable": true, * "_createdDate": "2021-12-06T14:33:19.114Z", * "_updatedDate": "2021-12-07T07:30:23.749Z", * "revision": "4" * } * } */ ``` ---