All Projects → aclindsa → ofxgo

aclindsa / ofxgo

Licence: GPL-2.0 License
Golang library for querying and parsing OFX

Programming Languages

go
31211 projects - #10 most used programming language
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to ofxgo

bankster
Money Creation Made Easy
Stars: ✭ 30 (-68.75%)
Mutual labels:  finance, banking
FullFIX
A library for parsing FIX (Financial Information eXchange) protocol messages.
Stars: ✭ 60 (-37.5%)
Mutual labels:  finance, parsing
mxfactorial
a payment application intended for deployment by the united states treasury
Stars: ✭ 36 (-62.5%)
Mutual labels:  finance, banking
Parse Xml
A fast, safe, compliant XML parser for Node.js and browsers.
Stars: ✭ 184 (+91.67%)
Mutual labels:  parsing, xml
open-psd2
An open source framework for using banking API's built for PSD2 regulation.
Stars: ✭ 20 (-79.17%)
Mutual labels:  finance, banking
Php Curl Class
PHP Curl Class makes it easy to send HTTP requests and integrate with web APIs
Stars: ✭ 2,903 (+2923.96%)
Mutual labels:  client, xml
pyitau
Unofficial client to access your Itaú bank data
Stars: ✭ 28 (-70.83%)
Mutual labels:  finance, banking
Node Xml2js
XML to JavaScript object converter.
Stars: ✭ 4,402 (+4485.42%)
Mutual labels:  parsing, xml
OBIS
A JavaScript framework for downloading bank statements in OFX, QIF, CSV, and JSON. Currently supports HSBC UK Personal Banking.
Stars: ✭ 37 (-61.46%)
Mutual labels:  banking, ofx
awesome-open-finance
A curated list of open finance and open banking resources
Stars: ✭ 92 (-4.17%)
Mutual labels:  finance, banking
Serde Xml Rs
xml-rs based deserializer for Serde (compatible with 1.0+)
Stars: ✭ 141 (+46.88%)
Mutual labels:  parsing, xml
libcitygml
C++ Library for CityGML Parsing and Visualization
Stars: ✭ 69 (-28.12%)
Mutual labels:  parsing, xml
Coregpx
A library for parsing and creation of GPX location files. Purely Swift.
Stars: ✭ 132 (+37.5%)
Mutual labels:  parsing, xml
Webapiclient
An open source project based on the HttpClient. You only need to define the c# interface and modify the related features to invoke the client library of the remote http interface asynchronously.
Stars: ✭ 1,618 (+1585.42%)
Mutual labels:  client, xml
Fuzi
A fast & lightweight XML & HTML parser in Swift with XPath & CSS support
Stars: ✭ 894 (+831.25%)
Mutual labels:  parsing, xml
avanza
A Python library for the unofficial Avanza API
Stars: ✭ 54 (-43.75%)
Mutual labels:  finance, banking
fints-institute-db
Database of German Banks and their HBCI / FinTS endpoints
Stars: ✭ 28 (-70.83%)
Mutual labels:  finance, banking
bunq2ifttt
bunq2IFTTT creates a self-hosted interface between the bunq banking API and IFTTT.
Stars: ✭ 20 (-79.17%)
Mutual labels:  finance, banking
FinanceKit
FinanceKit is a Framework for iOS and Mac to build apps working with financial data, like money, currencies, stocks, portfolio, transactions and other concepts.
Stars: ✭ 15 (-84.37%)
Mutual labels:  finance, banking
trading sim
📈📆 Backtest trading strategies concurrently using historical chart data from various financial exchanges.
Stars: ✭ 21 (-78.12%)
Mutual labels:  finance

OFXGo

Go Report Card Build Status Coverage Status PkgGoDev

OFXGo is a library for querying OFX servers and/or parsing the responses. It also provides an example command-line client to demonstrate the use of the library.

Goals

The main purpose of this project is to provide a library to make it easier to query financial information with OFX from the comfort of Golang, without having to marshal/unmarshal to SGML or XML. The library does not intend to abstract away all of the details of the OFX specification, which would be difficult to do well. Instead, it exposes the OFX SGML/XML hierarchy as structs which mostly resemble it. Its primary goal is to enable the creation of other personal finance software in Go (as it was created to allow me to fetch OFX transactions for my own project, MoneyGo).

Because the OFX specification is rather... 'comprehensive,' it can be difficult for those unfamiliar with it to figure out where to start. To that end, I have created a sample command-line client which uses the library to do simple tasks (currently it does little more than list accounts and query for balances and transactions). My hope is that by studying its code, new users will be able to figure out how to use the library much faster than staring at the OFX specification (or this library's API documentation). The command-line client also serves as an easy way for me to test/debug the library with actual financial institutions, which frequently have 'quirks' in their implementations. The command-line client can be found in the cmd/ofx directory of this repository.

Library documentation

Documentation can be found with the go doc tool, or at https://pkg.go.dev/github.com/aclindsa/ofxgo

Example Usage

The following code snippet demonstrates how to use OFXGo to query and parse OFX code from a checking account, printing the balance and returned transactions:

client := ofxgo.BasicClient{} // Accept the default Client settings

// These values are specific to your bank
var query ofxgo.Request
query.URL = "https://secu.example.com/ofx"
query.Signon.Org = ofxgo.String("SECU")
query.Signon.Fid = ofxgo.String("1234")

// Set your username/password
query.Signon.UserID = ofxgo.String("username")
query.Signon.UserPass = ofxgo.String("hunter2")

uid, _ := ofxgo.RandomUID() // Handle error in real code
query.Bank = append(query.Bank, &ofxgo.StatementRequest{
	TrnUID: *uid,
	BankAcctFrom: ofxgo.BankAcct{
		BankID:   ofxgo.String("123456789"),   // Possibly your routing number
		AcctID:   ofxgo.String("00011122233"), // Possibly your account number
		AcctType: ofxgo.AcctTypeChecking,
	},
	Include: true, // Include transactions (instead of only balance information)
})

response, _ := client.Request(&query) // Handle error in real code

// Was there an OFX error while processing our request?
if response.Signon.Status.Code != 0 {
	meaning, _ := response.Signon.Status.CodeMeaning()
	fmt.Printf("Nonzero signon status (%d: %s) with message: %s\n", response.Signon.Status.Code, meaning, response.Signon.Status.Message)
	os.Exit(1)
}

if len(response.Bank) < 1 {
	fmt.Println("No banking messages received")
	os.Exit(1)
}

if stmt, ok := response.Bank[0].(*ofxgo.StatementResponse); ok {
	fmt.Printf("Balance: %s %s (as of %s)\n", stmt.BalAmt, stmt.CurDef, stmt.DtAsOf)
	fmt.Println("Transactions:")
	for _, tran := range stmt.BankTranList.Transactions {
		currency := stmt.CurDef
		if ok, _ := tran.Currency.Valid(); ok {
			currency = tran.Currency.CurSym
		}
		fmt.Printf("%s %-15s %-11s %s%s%s\n", tran.DtPosted, tran.TrnAmt.String()+" "+currency.String(), tran.TrnType, tran.Name, tran.Payee.Name, tran.Memo)
	}
}

Similarly, if you have an OFX file available locally, you can parse it directly:

func main() {
	f, err := os.Open("./transactions.qfx")
	if err != nil {
		fmt.Printf("can't open file: %v\n", err)
		return
	}
	defer f.Close()

	resp, err := ofxgo.ParseResponse(f)
	if err != nil {
		fmt.Printf("can't parse response: %v\n", err)
		return
	}

	// do something with resp (*ofxgo.Response)
}

Requirements

OFXGo requires go >= 1.12

Using the command-line client

To install the command-line client and test it out, you may do the following:

$ go get -v github.com/aclindsa/ofxgo/cmd/ofx && go install -v github.com/aclindsa/ofxgo/cmd/ofx

Once installed (at ~/go/bin/ofx by default, if you haven't set $GOPATH), the command's usage should help you to use it (./ofx --help for a listing of the available subcommands and their purposes, ./ofx subcommand --help for individual subcommand usage).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].