Files
168fe0d68b [AI] Add api.importBudget() and api.exportBudget() (#8414)
* [AI] Add api.importBudget() and api.exportBudget()

Add first-class import/export functions to @actual-app/api so consumers
no longer have to drive the low-level worker RPC and the engine
filesystem by hand.

- api.importBudget(pathOrBytes, { type?, filename? }) imports an Actual
  .zip export (or a YNAB4/YNAB5 export), loads it, and resolves with the
  imported budget id. Raw bytes are passed straight to the import-budget
  handler instead of the upload-file-web temp-file dance, so it works in
  both the Node and browser builds and leaves no temp files behind.
- api.exportBudget() exports the currently-loaded budget and resolves
  with the zip contents as a Uint8Array.
- Both reject with an Error on failure instead of resolving { error }.
- The import-budget handler now optionally accepts raw file contents
  (buffer + filename) alongside the existing filepath input, and returns
  the id of the loaded budget on success; existing callers are
  unaffected.
- Add round-trip, file-path, and failure integration tests; update the
  API reference docs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014wq2oMcHb99mLb9qpaR8SN

* [AI] Move ImportableBudgetType re-export to models.ts

Type re-exports for API consumers live in models.ts (like Preferences),
not methods.ts — follow the existing pattern.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014wq2oMcHb99mLb9qpaR8SN

* [AI] Address review: relax error assertions, document type union

- Assert importBudget failures on the stable "Error importing budget:"
  prefix instead of backend-specific error codes
- Document options.type as the 'actual' | 'ynab4' | 'ynab5' union in the
  API reference instead of a generic string

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014wq2oMcHb99mLb9qpaR8SN

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-07-06 17:42:45 +00:00
..
2026-07-02 16:10:16 +00:00
2026-06-19 06:32:26 +00:00

npm install @actual-app/api

View docs here: https://actualbudget.org/docs/api/

TypeScript

@actual-app/api publishes TypeScript declarations. Consumers using TypeScript must set moduleResolution to "bundler", "nodenext", or "node16" in their tsconfig.json. Legacy "node" / "node10" / "classic" resolution is not supported in strict mode — the published declarations rely on package.json exports conditions that older resolvers don't honor.