Query and manage personal finances via the official Actual Budget Node.js API. Use for budget queries, transaction imports/exports, account management, categorization, rules, schedules, and bank sync with self-hosted Actual Budget instances.
Actual Budget 的官方 Node.js API。支持无头运行——适用于从服务器同步的本地预算数据。
bash
npm install @actual-app/api
| 变量 | 必填 | 说明 |
|---|---|---|
| ACTUALSERVERURL | 是 | 服务器 URL(例如 https://actual.example.com) |
| ACTUAL_PASSWORD |
如果您的 Actual Budget 服务器使用自签名证书:
请避免完全禁用 TLS 验证——这会使您暴露于中间人攻击。
javascript
const api = require(@actual-app/api);
await api.init({
dataDir: process.env.ACTUALDATADIR || /tmp/actual-cache,
serverURL: process.env.ACTUALSERVERURL,
password: process.env.ACTUAL_PASSWORD,
});
await api.downloadBudget(
process.env.ACTUALSYNCID,
process.env.ACTUALENCRYPTIONPASSWORD ? { password: process.env.ACTUALENCRYPTIONPASSWORD } : undefined
);
// ... 执行操作 ...
await api.shutdown();
// 带去重和规则的导入(银行导入推荐)
const { added, updated } = await api.importTransactions(accountId, [
{ date: 2026-01-15, amount: -2500, payee_name: Grocery Store, notes: Weekly run },
{ date: 2026-01-16, amount: -1200, payeename: Coffee Shop, importedid: bank-123 },
]);
// 更新交易
await api.updateTransaction(txnId, { category: categoryId, cleared: true });
// 创建
const catId = await api.createCategory({ name: Subscriptions, group_id: groupId });
const payeeId = await api.createPayee({ name: Netflix, category: catId });
对于复杂查询,使用 ActualQL:
javascript
const { q, runQuery } = require(@actual-app/api);
// 本月按类别汇总支出
const { data } = await runQuery(
q(transactions)
.filter({
date: [{ $gte: 2026-01-01 }, { $lte: 2026-01-31 }],
amount: { $lt: 0 },
})
.groupBy(category.name)
.select([category.name, { total: { $sum: $amount } }])
);
// 搜索交易
const { data } = await runQuery(
q(transactions)
.filter({ payee.name: { $like: %grocery% } })
.select([date, amount, payee.name, category.name])
.orderBy({ date: desc })
.limit(20)
);
运算符: $eq、$lt、$lte、$gt、$gte、$ne、$oneof、$regex、$like、$notlike
拆分: .options({ splits: inline | grouped | all })
javascript
// 按名称查找 ID
const acctId = await api.getIDByName(accounts, Checking);
const catId = await api.getIDByName(categories, Food);
const payeeId = await api.getIDByName(payees, Amazon);
// 列出预算
const budgets = await api.getBudgets(); // 本地 + 远程文件
转账使用特殊的收款方。通过 transfer_acct 字段查找转账收款方:
javascript
const payees = await api.getPayees();
const transferPayee = payees.find(p => p.transfer_acct === targetAccountId);
await api.importTransactions(fromAccountId, [
{ date: 2026-01-15, amount: -10000, payee: transferPayee.id }
]);
javascript
await api.importTransactions(accountId, [{
date: 2026-01-15,
amount: -5000,
payee_name: Costco,
subtransactions: [
{ amount: -3000, category: groceryCatId },
{ amount: -2000, category: householdCatId },
]
}]);
用于从其他应用迁移:
javascript
await api.runImport(My-New-Budget, async () => {
for (const acct of myData.accounts) {
const id = await api.createAccount(acct);
await api.addTransactions(id, myData.transactions.filter(t => t.acctId === id));
}
});
完整 API:https://actualbudget.org/docs/api/reference
ActualQL:https://actualbudget.org/docs/api/actual-ql
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 actual-budget-1776380781 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 actual-budget-1776380781 技能
skillhub install actual-budget-1776380781
文件大小: 3.26 KB | 发布时间: 2026-4-17 13:49