Community-maintained Go client implementation of the Plaid Legacy API. Pull requests welcome.
Install:
$ go get github.com/alphaspark/plaid-go/plaid
Import:
import "github.com/alphaspark/plaid-go/plaid"
client := plaid.NewClient("test_id", "test_secret", plaid.Tartan)
// POST /auth
postRes, mfaRes, err := client.AuthAddUser("plaid_test", "plaid_good", "", "bofa", nil)
if err != nil {
fmt.Println(err)
} else if mfaRes != nil {
// Need to switch on different MFA types. See https://plaid.com/docs/api/#auth-mfa.
switch mfaRes.Type {
case "device":
fmt.Println("--Device MFA--")
fmt.Println("Message:", mfaRes.Device.Message)
case "list":
fmt.Println("--List MFA--")
fmt.Println("Mask:", mfaRes.List[0].Mask, "\nType:", mfaRes.List[0].Type)
case "questions":
fmt.Println("--Questions MFA--")
fmt.Println("Question:", mfaRes.Questions[0].Question)
case "selections":
fmt.Println("--Selections MFA--")
fmt.Println("Question:", mfaRes.Selections[1].Question)
fmt.Println("Answers:", mfaRes.Selections[1].Answers)
}
postRes2, mfaRes2, err := client.AuthStepSendMethod(mfaRes.AccessToken, "type", "email")
if err != nil {
fmt.Println("Error submitting send_method", err)
}
fmt.Println(mfaRes2, postRes2)
postRes2, mfaRes2, err = client.AuthStep(mfaRes.AccessToken, "tomato")
if err != nil {
fmt.Println("Error submitting mfa", err)
} else {
fmt.Println(mfaRes2, postRes2)
}
} else {
fmt.Println(postRes.Accounts)
fmt.Println("Auth Get")
fmt.Println(client.AuthGet("test_bofa"))
fmt.Println("Auth DELETE")
fmt.Println(client.AuthDelete("test_bofa"))
}
Exchange a Plaid Link public_token
for an API access_token
:
client := plaid.NewClient("test_id", "test_secret", plaid.Tartan)
// POST /exchange_token
postRes, err := client.ExchangeToken(public_token)
if err != nil {
fmt.Println(err)
} else {
// Use the returned Plaid API access_token to retrieve
// account information.
fmt.Println(postRes.AccessToken)
fmt.Println("Auth Get")
fmt.Println(client.AuthGet(postRes.AccessToken))
}
With the Plaid + Stripe ACH integration, exchange a Link public_token
and account_id
for an API access_token
and Stripe bank_account_token
:
client := plaid.NewClient(CLIENT_ID, SECRET, plaid.Tartan)
// POST /exchange_token
postRes, err := client.ExchangeTokenAccount(public_token, account_id)
if err != nil {
fmt.Println(err)
} else {
// Use the returned Plaid access_token to make Plaid API requests and the
// Stripe bank account token to make Stripe ACH API requests.
fmt.Println(postRes.AccessToken)
fmt.Println(postRes.BankAccountToken)
}
// GET /categories/13001001
category, err := plaid.GetCategory(plaid.Tartan, "13001001")
if err != nil {
fmt.Println(err)
} else {
fmt.Println("category", category.ID, "is", strings.Join(category.Hierarchy, ", "))
}
- Complete README
- Complete testing using sandbox credentials
- Add Travis CI
- Add support for v2 of API