# ynab-api-importer

> Import bank transactions into YNAB

Latest version **3.0.25** (published 2023-08-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install ynab-api-importer
pnpm add ynab-api-importer
yarn add ynab-api-importer
bun add ynab-api-importer
```

Provides the command `ynab-importer`.

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.25 |
| Published | 2023-08-07 |
| First published | 2018-11-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 42.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Tim Smart |
| Maintainers | tim-smart |
| Keywords | ynab, api, importer |

## Links

- npm: https://www.npmjs.com/package/ynab-api-importer
- npm.io page: https://npm.io/package/ynab-api-importer

## Dependencies (6)

- [rxjs](https://npm.io/package/rxjs.md) ^7.5.5
- [ynab](https://npm.io/package/ynab.md) ^1.28.0
- [fp-ts](https://npm.io/package/fp-ts.md) ^2.11.10
- [luxon](https://npm.io/package/luxon.md) ^2.3.2
- [ofx-js](https://npm.io/package/ofx-js.md) ^0.1.1
- [puppeteer](https://npm.io/package/puppeteer.md) ^21.0.1

## Recent versions

- 3.0.25 (latest) — 2023-08-07
- 3.0.24 — 2023-08-07
- 3.0.23 — 2022-04-18
- 3.0.22 — 2022-04-18
- 3.0.21 — 2022-04-18
- 3.0.20 — 2022-04-18
- 3.0.19 — 2020-12-31
- 3.0.18 — 2020-12-30
- 3.0.17 — 2020-12-29
- 3.0.16 — 2020-12-29
- 3.0.15 — 2020-12-29
- 3.0.14 — 2020-12-28
- 3.0.13 — 2020-12-25
- 3.0.12 — 2020-12-15
- 3.0.11 — 2020-12-15
- … 19 more at https://npm.io/package/ynab-api-importer/versions

## README

# ynab-api-importer

A lot of international banks are unsupported by YNAB's direct feed feature. So
here is yet another YNAB API importer.

To make this useful you will need some technical knowledge. It is recommended
that you run this as a cron job everyday to make sure YNAB is always up-to-date.

Current the following adapters are implemented:

- BNZ (Bank of New Zealand)

## Installation

```
npm i -g ynab-api-importer
```

## Configuration

Copy `config.example.js` to `config.js` and change to your liking.

Then run:

```
ynab-importer config.js
```

## For developers

If you would like to create your own adapter, take a look at `src/banks/bnz.ts`.

You need to implement a `TBankAdapter` function and make it the default export
of your NPM module.
Users can then register it using the `registerAdapters` config option (see
`config.example.js`).

In your `peerDependencies` include `ynab-api-importer` and `ynab`;

For example:

```typescript
import { Page } from "puppeteer";
import {
  Adapters,
  Ynab,
  setupPage,
} from "ynab-api-importer";
import { SaveTransaction } from "ynab";

const export = (page: Page) => async (
  accountID: string,
  ynabAccountID: string,
): Promise<SaveTransaction[]> => {
  // Add your implmentation here
  // This will be run once for every account
  // It needs to return an array of YNAB transactions

  const ofxString = await doSomethingWith(page);
  const transactions = await Ynab.ofxToSaveTransactions(
    ofxString,
    ynabAccountID,
  );
  return transactions;
}

const fancyBankAdapter: Adapters.TBankAdapter = async (options: any) =>{
  // You can login here, setup puppeteer etc.
  const { browser, page } = await setupPage();

  // Return two functions. First one exports the transactions. Second one does
  // cleanup.
  return [export(page), () => browser.close()];
}

export default fancyBankAdapter;
```

---
_Source: https://npm.io/package/ynab-api-importer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
