goavanza

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2022 License: MIT Imports: 6 Imported by: 0

README

Avanza Unofficial GO API Client

Go Reference CI

Please note that I am not affiliated with Avanza Bank AB in any way. The underlying API can be taken down or changed without warning at any point in time.

Installation

go get github.com/open-wallstreet/go-avanza

Getting a TOTP Secret

NOTE: Since May 2018 two-factor authentication is used to log in.

Here are the steps to get your TOTP Secret:

  1. Go to Mina Sidor > Profil > Sajtinställningar > Tvåfaktorsinloggning and click "Återaktivera". (Only do this step if you have already set up two-factor auth.)
  2. Click "Aktivera" on the next screen.
  3. Select "Annan app för tvåfaktorsinloggning".
  4. Click "Kan du inte scanna QR-koden?" to reveal your TOTP Secret.
  5. Finally, run go run github.com/open-wallstreet/go-avanza/cmd/totp 'PASTE_YOUR_TOTP_SECRET_HERE' to generate an initial code.
  6. Done! From now on all you have to do is supply your secret in with AVANZA_TOTP_SECRET environment variable function as in the example below.

Documentation

Docs: Go Reference

Websocket information

Quick Guide

// You can create a new client simply like this
func main() {
    client := goavanza.New()
    defer client.Close()
}
// Or if you need to debug http responses
func main() {
    client := goavanza.New(goavanza.WithDebug(true))
    defer client.Close()
}

Most API calls need you to authenticate using a TOPT token. see [Getting a TOTP Secret](#Getting a TOTP Secret) section how to create one. After that call the Authenticate method

authenticate, err := client.Auth.Authenticate(context.Background(), username, password, totpSecret)

You should not save your username, password or totpSecret in your code. You ENV variables or other ways to encrypt or hide the data

See /examples or GoDocs for more information

Shoutouts

Major inspiration goes to Node.js unofficial avanza api

RESPONSIBILITIES

The author of this software is not responsible for any indirect damages (foreseeable or unforeseeable), such as, if necessary, loss or alteration of or fraudulent access to data, accidental transmission of viruses or of any other harmful element, loss of profits or opportunities, the cost of replacement goods and services or the attitude and behavior of a third party.

Known issues
  • GetMarketData response does not have correct interface mapping due to not being able to seen a response with data in it yet.
  • Most streaming data has not been mapped to correct structs due to not being able to test responses due to Avanza being down for maintenance during development

Documentation

Overview

Package goavanza is a Go Unoffical API Client for Avanza Bank AB

Please note that I am not affiliated with Avanza Bank AB in any way. The underlying API can be taken down or changed without warning at any point in time.

To install the package simply run

go get github.com/open-wallstreet/go-avanza

You can create a new client simply like this

func main() {
    client := goavanza.New()
    defer client.Close()
}

Or if you need to debug http responses

func main() {
    client := goavanza.New(goavanza.WithDebug(true))
    defer client.Close()
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithDebug added in v1.0.0

func WithDebug(debug bool) func(a *AvanzaClient)

Types

type AvanzaClient added in v1.0.0

type AvanzaClient struct {
	*client.Client
	Auth      *auth.AuthClient
	Account   *account.AccountClient
	Market    *market.MarketClient
	Order     *order.OrderClient
	Websocket *websocket.WebsocketClient
}

func New added in v1.0.0

func New(opts ...func(a *AvanzaClient)) *AvanzaClient

func (*AvanzaClient) Close added in v1.0.0

func (a *AvanzaClient) Close()

Directories

Path Synopsis
avanza
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL