fastify-xplaid
accounts.get(accessToken, options?)
Get all accounts associated with a Plaid Item.
accounts.get(accessToken, options?)
Returns all accounts associated with an Item, including account name, type, subtype, mask, and current balance snapshot.
Signature
fastify.xplaid.accounts.get(
accessToken: string,
options?: { accountIds?: string[] }
): Promise<{ accounts: Account[]; item: Item; requestId: string }>
Params
| Name | Type | Required | Description |
|---|---|---|---|
accessToken | string | Yes | The Item's access token |
options.accountIds | string[] | No | Filter to specific account IDs |
Returns
{ accounts: Account[]; item: Item; requestId: string }
Throws
Error: [xPlaid] accessToken is required and must be a non-empty string- Plaid API error with
.plaidErrorand.statusCode
Examples
List all accounts
fastify.get("/accounts", async (request) => {
const item = await getPlaidItem(request.user.id);
const { accounts } = await fastify.xplaid.accounts.get(item.accessToken);
return accounts.map((a) => ({
id: a.account_id,
name: a.name,
type: a.type,
subtype: a.subtype,
mask: a.mask,
}));
});
Filter to checking accounts only
const { accounts } = await fastify.xplaid.accounts.get(accessToken);
const checkingIds = accounts
.filter((a) => a.subtype === "checking")
.map((a) => a.account_id);
const { accounts: checking } = await fastify.xplaid.accounts.get(accessToken, {
accountIds: checkingIds,
});
See also
- accounts.getBalance(accessToken, options?) — real-time balance refresh
- transactions.sync(accessToken, options?) — sync transactions for the item
AI Context
package: "@xenterprises/fastify-xplaid"
method: fastify.xplaid.accounts.get(accessToken, options?)
use-when: Get all accounts for a Plaid Item with last-known balance snapshot (cached, not live)
returns: { accounts: [ { account_id, name, type, subtype, balances, mask } ] }
