ofxy

Crates.ioofxy
lib.rsofxy
version0.2.0
created_at2025-04-15 02:54:20.883069+00
updated_at2025-09-15 20:07:49.6275+00
descriptionParse OFX files
homepage
repositoryhttps://github.com/n8henrie/ofxy
max_upload_size
id1633869
size286,230
Nathan Henrie (n8henrie)

documentation

README

ofxy

master: master branch build status

Crates.io Docs.rs

Introduction

Ofxy is a Rust library for reading Open Financial Exchange (OFX) data. It is still in early stages of development, and I am not a financial professional or a developer by training; temper your expectations accordingly. Contributions and feedback / constructive criticism are welcome and appreciated.

My primary motivation is for reading the OFX files provided by financial institutions that I use. Because Ofxy is now able to successfully read these files from all 3 different institutions that use, I thought it seemed reasonable to open source. There is a lot more to the OFX spec than what I've provided here; contributions to make Ofxy more correct or broadly useful are appreciated.

Features

  • Support for parsing OFX 1.6 files

Quickstart

use ofxy::{Ofx, body::TransactionType};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let content = std::fs::read_to_string("tests/files/simple.ofx")?;
    let doc: ofxy::Ofx = content.parse()?;
    for tx in doc
        .body
        .credit_card
        .expect("credit card section not found")
        .transaction_response
        .statement
        .bank_transactions
        .expect("bank transactions not found")
        .transactions
    {
        let ofxy::body::Transaction {
            transaction_type,
            date_posted,
            amount,
            name,
            ..
        } = tx;
        match transaction_type {
            TransactionType::Debit => {
                println!("{date_posted}: spent {amount} at {}", name.unwrap());
            }
            TransactionType::Payment => {
                println!("{date_posted}: paid {amount} to {}", name.unwrap());
            }
            _ => (),
        }
    }
    Ok(())
}

Development Setup

  1. Clone the repo: git clone https://github.com/n8henrie/ofxy && cd ofxy
  2. Install dependencies: cargo build

Acknowledgements

Goals

  • No unsafe code
  • Idiomatic error handling
  • Well tested code
  • Readable code

Wishlist / Maybe / Would Be Nice

  • OFX 2+ support
  • Decent performance
  • Serialization

OFX 1.6 Spec

Troubleshooting / FAQ

  • Ofxy fails to parse my OFX file!
    • If you're comfortable redacting the private information and comfortable with GPL3 licensing, please submit the file in a GitHub Issue; I'll gladly try to sort out the failure and add it to the existing test suite
    • Note that many financial institutions seem to provide OFX files that don't adhere to the spec, some of which currently fail. I'm not yet fully decided whether Ofxy should try to accomodate these by default, provide some kind of Strict vs Relaxed parsing, or reject the files as invalid. Feel free to submit opinions and justification.

Attribution

Test files were copied (with gratitude!) from:

Commit count: 12

cargo fmt