Public
Forkable Akahu to YNAB importer with a review UI.
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.

Akahu to YNAB Importer

A forkable Val Town app that imports settled Akahu transactions into a local SQLite review queue, then lets you manually import selected transactions into YNAB.

What v1 does

  • Uses Akahu Personal App tokens, so each fork is for one person's own Akahu account.
  • Uses a YNAB Personal Access Token.
  • Stores state in the val-scoped Val Town SQLite database.
  • Protects the dashboard with Val Town login plus ADMIN_USERNAMES.
  • Syncs settled Akahu transactions only. Pending transactions are intentionally out of scope.
  • Lets scheduled syncs fetch from Akahu into SQLite only. YNAB writes happen only from the web UI.
  • Imports YNAB transactions as cleared, unapproved, uncategorized transactions with a stable import_id.

Required env vars

Set these on your fork. For OAUTH_STATE_ENCRYPTION_KEY, use any long random string; it is not shared with Akahu or YNAB.

  • ADMIN_USERNAMES: comma-separated Val Town usernames allowed to open the dashboard.
  • OAUTH_STATE_ENCRYPTION_KEY: random secret used by Val Town OAuth session state.
  • AKAHU_USER_TOKEN: your Akahu User Access Token.
  • AKAHU_APP_TOKEN: your Akahu App ID Token.
  • YNAB_ACCESS_TOKEN: your YNAB Personal Access Token.

For this val, add them here:

https://www.val.town/x/jonpdw/ynab-import/environment-variables

Getting credentials

Akahu:

  1. Sign in at https://my.akahu.nz/.
  2. Go to Developers.
  3. Create or open your Personal App.
  4. Copy the User Access Token and App ID Token into Val Town env vars.

YNAB:

  1. Sign in to https://app.ynab.com/.
  2. Go to Account Settings, then Developer Settings.
  3. Create a Personal Access Token.
  4. Copy it into YNAB_ACCESS_TOKEN.

First run

  1. Open the dashboard.
  2. Log in with Val Town.
  3. Click Refresh accounts.
  4. Select one YNAB plan.
  5. Map each Akahu account to a YNAB account or choose Ignore this account.
  6. Pick a backfill window. The default is 30 days.
  7. Run backfill.
  8. Review ready transactions and click Import selected.

Scheduled sync

The sync.ts interval runs daily at 0 18 * * * UTC. It only fetches settled Akahu transactions into SQLite. It does not write to YNAB.

After the first successful sync, future syncs use the last successful sync timestamp with a 7-day overlap so late changes can be seen again.

Forking notes

When someone remixes or forks the val, they should set their own env vars and keep their own val-scoped SQLite database. Do not share personal access tokens with other users.

Akahu Personal Apps are free but limited to your own Akahu account and do not support webhooks. YNAB Personal Access Tokens are intended for individual usage. A multi-user hosted version would need Akahu OAuth and YNAB OAuth instead.