get_transaction
Retrieve specific transaction details from YNAB budgets to view spending, track expenses, or verify financial records.
Instructions
[1 API call] Get details for a single transaction
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| budget_id | No | Budget ID or 'last-used' | last-used |
| transaction_id | Yes | The transaction ID |
Implementation Reference
- src/tools/transactions.ts:45-80 (handler)The handler and registration for the 'get_transaction' tool.
server.registerTool("get_transaction", { title: "Get Transaction", description: "[1 API call] Get details for a single transaction", inputSchema: { budget_id: z.string().default("last-used").describe("Budget ID or 'last-used'"), transaction_id: z.string().describe("The transaction ID"), }, annotations: { readOnlyHint: true }, }, async ({ budget_id, transaction_id }) => { try { const response = await getClient().transactions.getTransactionById(budget_id, transaction_id); const t = response.data.transaction; const lines = [ `Date: ${t.date}`, `Amount: ${formatCurrency(t.amount)}`, `Payee: ${t.payee_name ?? "None"} (ID: ${t.payee_id ?? "N/A"})`, `Category: ${t.category_name ?? "Uncategorized"} (ID: ${t.category_id ?? "N/A"})`, `Account: ${t.account_name} (ID: ${t.account_id})`, `Memo: ${t.memo ?? "None"}`, `Cleared: ${t.cleared}`, `Approved: ${t.approved}`, `Flag: ${t.flag_color ?? "None"}`, `Transfer Account: ${t.transfer_account_id ?? "None"}`, `ID: ${t.id}`, ]; if (t.subtransactions && t.subtransactions.length > 0) { lines.push(`\nSplit Transactions:`); for (const sub of t.subtransactions) { lines.push(` - ${formatCurrency(sub.amount)} | ${sub.category_name ?? "Uncategorized"} | ${sub.memo ?? ""}`); } } return textResult(lines.join("\n")); } catch (e: any) { return errorResult(e.message); } });