GithubHelp home page GithubHelp logo

webmonarch / node-ofx Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chilts/node-ofx

0.0 2.0 0.0 16 KB

Parse OFX files into a usable data structure for Node.js.

License: Other

JavaScript 100.00%

node-ofx's Introduction

 _______  _______          
(  ___  )(  ____ \|\     /|
| (   ) || (    \/( \   / )
| |   | || (__     \ (_) / 
| |   | ||  __)     ) _ (  
| |   | || (       / ( ) \ 
| (___) || )      ( /   \ )
(_______)|/       |/     \|
                           

Parse Open Financial Exchange (OFX) files into a usable data structure. Serialize objects into OFX file format.

parsing

var ofx = require('ofx');

fs.readFile('Account-1234-5678.ofx', 'utf8', function(err, ofxData) {
    if (err) throw err;

    var data = ofx.parse(ofxData);
    console.dir(data);
});

serializing

var ofx = require('ofx');

var header = {
    OFXHEADER: '100',
    DATA: 'OFXSGML',
    VERSION: '103',
    SECURITY: 'NONE',
    ENCODING: 'USASCII',
    CHARSET: '1252',
    COMPRESSION: 'NONE',
    OLDFILEUID: 'NONE',
    NEWFILEUID: 'unique id here'
};

var body = {
    SIGNONMSGSRQV1: {
      SONRQ: {
        DTCLIENT: 'value',
        USERID: 'user id',
        USERPASS: 'password',
        LANGUAGE: 'ENG',
        FI: {
          ORG: 'org',
          FID: 'fid'
        },
        APPID: 'QWIN',
        APPVER: '2100',
        CLIENTUID: 'needed by some places'
      }
    }
};

var ofx_string = ofx.serialize(header, body);
console.log(ofx_string);

Data

In your data returned, you will have the following properties:

  • OFX - a dump of the XML parsing as a js object
  • header - just the 'key:values' pairs from the top of the OFX file

caveats

This file format is yucky, horrible and just silly. This module helps parse the ones I know about. And it doesn't do it in a nice way either. It may or may not work for your own use - only by trying it will you find out.

If you discover a broken file, please submit an issue with the sample file.

This module takes the OFX format and does the following:

  • splits off the initial set of metadata (the "Key:Value" lines)
  • tries to mechnically turn the SGML into a valid XML format
  • turns the XML into a JavaScript data structure

Credits

Thanks to Christian Sullivan for writing banking.js, upon which some of this code is based. Many thanks for letting me use it.

Author

Written by Andrew Chilton - Blog - Twitter.

License

The MIT License : http://appsattic.mit-license.org/2012/

node-ofx's People

Contributors

benjie avatar chilts avatar defunctzombie avatar joemcbride avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.