Welcome to OFX4J!
This project provides an implementaion of OFX for Java.
<dependency>
<groupId>com.webcohesion.ofx4j</groupId>
<artifactId>ofx4j</artifactId>
<version>1.38-SNAPSHOT</version>
</dependency>
You have to first find the financial institution you want to interface with. Use an implementation of
com.webcohesion.ofx4j.client.FinancialInstitutionDataStore
to list the available financial institution data.
Alternatively, use com.webcohesion.ofx4j.client.impl.BaseFinancialInstitutionData
to construct your own data if your
FI data isn't available.
The two default implementations of FinancialInstitutionDataStore
are com.webcohesion.ofx4j.client.impl.LocalResourceFIDataStore
and com.webcohesion.ofx4j.client.impl.OFXHomeFIDataStore
. The former looks up the data store list from a local resource (default is the
list at /META-INF/ofx4j/institutions.xml
on the classpath; a default one is packaged with the jar). The latter screen-scrapes
this page at OFX Home, so it's subject to break
depending on how often the format of that page changes.
Once you have a reference to the FinancialInstitutionData
you want, you can now use it to interface with your FI.
FinancialInstitutionData data = ...;
FinancialInstitutionService service
= new FinancialInstitutionServiceImpl();
FinancialInstitution fi = service.getFinancialInstitution(data);
fi.setLanguage(Locale.US.getISO3Language().toUpperCase());
// read the fi profile (note: not all institutions
// support this, and you normally don't need it.)
FinancialInstitutionProfile profile = fi.readProfile();
//get a reference to a specific bank account at your FI
BankAccountDetails bankAccountDetails
= new BankAccountDetails();
//routing number to the bank.
bankAccountDetails.setRoutingNumber("11111111");
//bank account number.
bankAccountDetails.setAccountNumber("1234-5678");
//it's a checking account
bankAccountDetails.setAccountType(AccountType.CHECKING);
BankAccount bankAccount
= fi.loadBankAccount(bankAccountDetails, "username", "password");
//read the statement (transaction details, etc.)
// for a given time period.
Date startDate = ...;
Date endDate = ...;
AccountStatement statement
= bankAccount.readStatement(startDate, endDate);
// get a reference to a specific credit card
// account at your FI
CreditCardAccountDetails ccDetails
= new CreditCardAccountDetails();
ccDetails.setAccountNumber("1234-567890-1111");
CreditCardAccount ccAccount
= fi.loadCreditCardAccount(ccDetails, "username", "password");
// read the statement (transaction details, etc.)
// for a given time period.
Date startDate = ...;
Date endDate = ...;
AccountStatement statement
= ccAccount.readStatement(startDate, endDate);