Skip to content
This repository has been archived by the owner on Jan 2, 2022. It is now read-only.

billglover/starling

Repository files navigation

Starling

Note: the project is now four years old and I believe the Starling API has moved on significantly and so this client may no longer function. I archived the project to reflect this. See https://developer.starlingbank.com as a good starting point for Starling development.

Build Status

This is an unofficial Go client for the Starling Bank API.

Both the Starling Bank API itself and this package are under active development and, whilst we try to keep breaking changes to a minimum, we cannot guarantee a stable interface. We use Semantic Versioning to quantify changes from one release to the next.

"Major version zero (0.y.z) is for initial development. Anything may change at any time. The public API should not be considered stable."

Installation

Use Go to fetch the latest version of the package.

go get -u 'github.com/billglover/starling'

Usage

It is assumed that you are able to provide an OAuth access-token when establishing the Starling client. Depending on your use case, it pay be as simple as passing in the personal access-token provided by Starling when you create an applicaiton. See the section on Personal Access Tokens in the Starling Developer Docs for more information on how to do this.

package main

import (
    "context"
    "fmt"

    "github.com/billglover/starling"
    "golang.org/x/oauth2"
)

func main() {
	ts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: "{{YOUR_ACCESS_TOKEN}}"})
	ctx := context.Background()
	tc := oauth2.NewClient(ctx, ts)

	client := NewClient(tc)

	txns, _, _ := client.Transactions(ctx, nil)

	for _, txn := range txns {
		fmt.Println(txn.Created, txn.Amount, txn.Currency, txn.Narrative)
	}
}

If you want to use the production API rather than the sandbox, you need to create a client with additional options.

package main

import (
    "context"
    "fmt"
    "net/url"

    "github.com/billglover/starling"
    "golang.org/x/oauth2"
)

func main() {
	ts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: "{{ACCESS_TOKEN}}"})
	ctx := context.Background()
	tc := oauth2.NewClient(ctx, ts)

	baseURL, _ := url.Parse(ProdURL)
	opts := ClientOptions{BaseURL: baseURL}
	client := NewClientWithOptions(tc, opts)

	txns, _, _ := client.Transactions(ctx, nil)

	for _, txn := range txns {
		fmt.Println(txn.Created, txn.Amount, txn.Currency, txn.Narrative)
	}
}

Starling Bank Developer Documentation

Contributors

About

A Go client for the Starling Bank API

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages