Skip to content

Fabiopf02/ofx-data-extractor

Repository files navigation

npm version MIT License codecov Release Package

ofx-data-extractor is a TypeScript library for parsing, normalizing and validating OFX files in Node.js and browser environments.

Table of Contents

Installation

npm install ofx-data-extractor
yarn add ofx-data-extractor

Quick Start

import { Ofx } from 'ofx-data-extractor'

const data = 'OFXHEADER:100\nDATA:OFXSGML\nVERSION:102\n...'
const ofx = new Ofx(data)

const raw = ofx.toJson()
const summary = ofx.getTransactionsSummary()
const normalized = ofx.toNormalized()
const validation = ofx.validate()

Node.js

import fs from 'fs'
import { Ofx } from 'ofx-data-extractor'

const file = fs.readFileSync('/path/to/file.ofx')
const ofx = Ofx.fromBuffer(file)
console.log(ofx.getTransactionsSummary())

Browser (fromBlob is async)

import { Ofx } from 'ofx-data-extractor'

async function handleFile(event: Event) {
  const input = event.target as HTMLInputElement
  const file = input.files?.[0]
  if (!file) return

  const ofx = await Ofx.fromBlob(file)
  console.log(ofx.toJson())
}

Main Public API (Ofx)

  • new Ofx(data: string, config?: ExtractorConfig)
  • Ofx.fromBuffer(buffer: Buffer)
  • Ofx.fromBlob(blob: Blob)
  • config(options)
  • getType()
  • getHeaders()
  • getBankTransferList()
  • getCreditCardTransferList()
  • getTransactionsSummary()
  • getContent()
  • toJson()
  • toNormalized(options?)
  • validate()
  • getWarnings()

Configuration (Extract)

  • nativeTypes?: boolean
  • fitId?: 'normal' | 'separated'
  • formatDate?: string
  • parserMode?: 'strict' | 'lenient'

Parser mode:

  • strict (default): parsing errors throw.
  • lenient: parsing errors fallback and are collected via getWarnings().

Developer Documentation

Examples

License

MIT

About

TypeScript library to parse, normalize, and validate OFX files in Node.js and browsers, with strict/lenient modes and developer-friendly transaction output.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors