| Crates.io | ofxy |
| lib.rs | ofxy |
| version | 0.2.0 |
| created_at | 2025-04-15 02:54:20.883069+00 |
| updated_at | 2025-09-15 20:07:49.6275+00 |
| description | Parse OFX files |
| homepage | |
| repository | https://github.com/n8henrie/ofxy |
| max_upload_size | |
| id | 1633869 |
| size | 286,230 |
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.
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(())
}
git clone https://github.com/n8henrie/ofxy && cd ofxycargo buildStrict vs Relaxed parsing, or reject the files as invalid. Feel free to submit opinions and justification.Test files were copied (with gratitude!) from: