Coder Social home page Coder Social logo

n26's Introduction

Go Report Card

n26

Go API and CLI to get information of your N26 account

Installation

  • macOS: Available via Homebrew. Just run brew install guitmz/tools/n26
  • Linux: You can manually build this project or download a binary release.

You can also install with go get -u github.com/guitmz/n26/cmd/n26 (make sure you have your Go env setup correctly).

Docker

A Dockerfile is also provided and the prebuilt image is available for pulling: docker pull guitmz/n26 or docker pull guitmz/n26:DESIRED_TAG

You can run it like:

$ docker run -e N26_USERNAME="username" -e N26_PASSWORD="password" -e N26_DEVICE_TOKEN="device_token_uuid" guitmz/n26

or if you want to be asked for your credentials:

$ docker run -ti -e N26_DEVICE_TOKEN="device_token_uuid" guitmz/n26

Authentication

Since 14th of September 2019, N26 requires a login confirmation (2 factor authentication) from the paired phone N26 application to login on devices that are not paired (more details here). This means you will receive a notification on your phone when you start using this library to request data. This tool checks for your login confirmation every 5 seconds. If you fail to approve the login request within 60 seconds an exception is raised.

Device Token

Since 17th of June 2020, N26 requires a device_token to differentiate clients. This requires you to specify the N26_DEVICE_TOKEN environment variable with an UUID of your choice. Feel free to use any proper UUID generator like https://www.uuidgenerator.net to generate the token.

Usage

NAME:
   N26 - your N26 Bank financial information on the command line

USAGE:
   n26 command [json|csv|statement ID]

VERSION:
   1.5.0

AUTHOR:
   Guilherme Thomazi <[email protected]>

COMMANDS:
     addresses     addresses linked to your account
     balance       your balance information
     block         blocks a card
     cards         list your cards information
     contacts      your saved contacts
     info          personal information
     limits        your account limits
     spaces        your spaces
     statements    your statements. Passing the statement ID as argument, downloads the PDF to the current directory
     status        general status of your account
     transactions  list your past transactions. Supports CSV output
     unblock       unblocks a card
     help, h       Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h     show help
   --version, -v  print the version

You can have the N26_USERNAME and N26_PASSWORD environment variables set to your N26 user email and password. If you don't, you will be prompt for this information, so it's not mandatory. Example of getting your account balance:

$ n26 balance
+------------------------+-------------+-------------------+----------------+
|          IBAN          |     BIC     | AVAILABLE BALANCE | USABLE BALANCE |
+------------------------+-------------+-------------------+----------------+
| DE74100XXXXXXXXXXXXXXX | NTSXXXXXXXX |              88.8 |           88.8 |
+------------------------+-------------+-------------------+----------------+

You can also use the json option to output it as JSON with more information:

$ n26 balance json
N26 password: ********
{
  "availableBalance": 107.5,
  "usableBalance": 107.5,
  "iban": "DEXXXXXXXXXXXXXX",
  "bic": "NTXXXXXXXXXXX",
  "bankName": "N26 Bank",
  "seized": false,
  "id": "11111-1scasda-1112312-adasdasdasdas"
}

And csv for transactions.

You can run n26 help for usage description.

Missing features

  • Improve MFA flow, for now it works but is not really informative
  • Make a transfer
  • Set card limit
  • API docs
  • Better error handling
  • A terminal UI could also be implemented
  • ?

References

n26's People

Contributors

guitmz avatar herver avatar hosackm avatar jellelicht avatar relistan avatar rots avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

n26's Issues

Transactions command not running

Hey, love this. Thank you! All of the commands are running for me expect Transactions.

When running it I get the following error:
panic: time: missing Location in call to Time.In

I saw this same issue reported #26 and closed, but the fix was merged, so I'm reporting this as a new issue.

Here's what happens after that:

panic: time: missing Location in call to Time.In

goroutine 1 [running]:
time.Time.In(...)
	/usr/local/go/src/time/time.go:1099
github.com/guitmz/n26.(*TimeStamp).UnmarshalJSON(0xc00046a878, 0xc0005a612b, 0xd, 0x1cd5, 0x40276bd900, 0xc00046a878)
	/go/src/github.com/guitmz/n26/timestamp.go:27 +0x2f0
encoding/json.(*decodeState).literalStore(0xc000088630, 0xc0005a612b, 0xd, 0x1cd5, 0x8133e0, 0xc00046a878, 0x199, 0x100, 0x1cc7, 0xc000088658)
	/usr/local/go/src/encoding/json/decode.go:860 +0x2acb
encoding/json.(*decodeState).value(0xc000088630, 0x8133e0, 0xc00046a878, 0x199, 0x8133e0, 0xc00046a878)
	/usr/local/go/src/encoding/json/decode.go:384 +0x1f1
encoding/json.(*decodeState).object(0xc000088630, 0x816480, 0xc00046a800, 0x199, 0x821226, 0xb)
	/usr/local/go/src/encoding/json/decode.go:765 +0x12fe
encoding/json.(*decodeState).value(0xc000088630, 0x816480, 0xc00046a800, 0x199, 0x816480, 0xc00046a800)
	/usr/local/go/src/encoding/json/decode.go:370 +0x6d
encoding/json.(*decodeState).array(0xc000088630, 0x793600, 0xc00000e050, 0x16, 0xc000088658, 0x5b)
	/usr/local/go/src/encoding/json/decode.go:558 +0x1aa
encoding/json.(*decodeState).value(0xc000088630, 0x793600, 0xc00000e050, 0x16, 0xc0000af4a0, 0x511079)
	/usr/local/go/src/encoding/json/decode.go:360 +0x105
encoding/json.(*decodeState).unmarshal(0xc000088630, 0x793600, 0xc00000e050, 0xc000088658, 0x0)
	/usr/local/go/src/encoding/json/decode.go:180 +0x1ea
encoding/json.Unmarshal(0xc0005a6000, 0x1cc7, 0x1e00, 0x793600, 0xc00000e050, 0xc0000af5b0, 0xc0005a6000)
	/usr/local/go/src/encoding/json/decode.go:107 +0x112
github.com/guitmz/n26.(*Client).GetTransactions(0xc00058c4e0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x81bb91, 0x2, 0x40274a51d0, ...)
	/go/src/github.com/guitmz/n26/api.go:378 +0x456
github.com/guitmz/n26.(*Client).GetLastTransactions(...)
	/go/src/github.com/guitmz/n26/api.go:361
main.main.func8(0xc000092b00, 0xc000010800, 0xc0000108d0)
	/go/src/github.com/guitmz/n26/cmd/n26/n26.go:278 +0x3ec
github.com/urfave/cli.HandleAction(0x7aa5e0, 0x83c8e8, 0xc000092b00, 0xc000092b00, 0x0)
	/go/pkg/mod/github.com/urfave/[email protected]/app.go:526 +0xfd
github.com/urfave/cli.Command.Run(0x821a4e, 0xc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x831574, 0x31, 0x0, ...)
	/go/pkg/mod/github.com/urfave/[email protected]/command.go:174 +0x58e
github.com/urfave/cli.(*App).Run(0xc0000f4000, 0xc00000c0a0, 0x2, 0x2, 0x0, 0x0)
	/go/pkg/mod/github.com/urfave/[email protected]/app.go:279 +0x7e8
main.main()
	/go/src/github.com/guitmz/n26/cmd/n26/n26.go:371 +0x5b8

I've done a bit of research and trying to figure out how to add an explicit timezone to the docker file but on a forked-version Error response from daemon: pull access denied so I'm out of ideas how to fix it.

Does the Transactions command work for you?

Thanks!

status reports wrong creation date

Hello there,

The status command returns the creation date of the N26 account, but the date is completely wrong:

+--------------------------------+
|            CREATED             |
+--------------------------------+
| 48828-01-13 19:47:38 +0100 CET |
+--------------------------------+

As far as I can tell, it's because the API returns timestamps in milliseconds where time.Unix expects "normal" timestamp in seconds.

PR coming to fix this "cosmetic" bug

Error to fetch transactions

Fetching balance is working like a charm, but when I tried to fetch the transactions I got this error:

➜ docker run -ti guitmz/n26 transactions
N26 username: [email protected]
N26 password: ********
panic: time: missing Location in call to Time.In

goroutine 1 [running]:
time.Time.In(...)
	/usr/local/go/src/time/time.go:1126
github.com/guitmz/n26.(*TimeStamp).UnmarshalJSON(0xc00038c878, 0xc00051212d, 0xd, 0x3cd3, 0x7f94571a6908, 0xc00038c878)
	/go/src/github.com/guitmz/n26/timestamp.go:27 +0x305
encoding/json.(*decodeState).literalStore(0xc0001ee370, 0xc00051212d, 0xd, 0x3cd3, 0x8378e0, 0xc00038c878, 0x199, 0x100, 0x2480, 0xc0001ee398)
	/usr/local/go/src/encoding/json/decode.go:918 +0x2b7b
encoding/json.(*decodeState).value(0xc0001ee370, 0x8378e0, 0xc00038c878, 0x199, 0x8378e0, 0xc00038c878)
	/usr/local/go/src/encoding/json/decode.go:443 +0x1de
encoding/json.(*decodeState).object(0xc0001ee370, 0x83af40, 0xc00038c800, 0x199, 0x846615, 0xb)
	/usr/local/go/src/encoding/json/decode.go:823 +0x1392
encoding/json.(*decodeState).value(0xc0001ee370, 0x83af40, 0xc00038c800, 0x199, 0x83af40, 0xc00038c800)
	/usr/local/go/src/encoding/json/decode.go:429 +0x6d
encoding/json.(*decodeState).array(0xc0001ee370, 0x79a240, 0xc0000920f8, 0x16, 0xc0001ee398, 0x5b)
	/usr/local/go/src/encoding/json/decode.go:616 +0x1ac
encoding/json.(*decodeState).value(0xc0001ee370, 0x79a240, 0xc0000920f8, 0x16, 0xc0000e5428, 0x501549)
	/usr/local/go/src/encoding/json/decode.go:419 +0xfd
encoding/json.(*decodeState).unmarshal(0xc0001ee370, 0x79a240, 0xc0000920f8, 0xc0001ee398, 0x0)
	/usr/local/go/src/encoding/json/decode.go:179 +0x1fb
encoding/json.Unmarshal(0xc000512000, 0x2480, 0x3e00, 0x79a240, 0xc0000920f8, 0xc0000e5538, 0xc000512000)
	/usr/local/go/src/encoding/json/decode.go:106 +0x112
github.com/guitmz/n26.(*Client).GetTransactions(0xc00026f110, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x841160, 0x2, 0x7f945739d178, ...)
	/go/src/github.com/guitmz/n26/api.go:377 +0x44b
github.com/guitmz/n26.(*Client).GetLastTransactions(...)
	/go/src/github.com/guitmz/n26/api.go:360
main.main.func8(0xc0000b89a0, 0x0, 0xc0000947b0)
	/go/src/github.com/guitmz/n26/cmd/n26/n26.go:273 +0x4da
github.com/urfave/cli.HandleAction(0x7bdb40, 0x8610c0, 0xc0000b89a0, 0xc0000b89a0, 0x0)
	/go/src/github.com/urfave/cli/app.go:523 +0xbe
github.com/urfave/cli.Command.Run(0x846e02, 0xc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x85645d, 0x31, 0x0, ...)
	/go/src/github.com/urfave/cli/command.go:174 +0x51c
github.com/urfave/cli.(*App).Run(0xc000118000, 0xc000088020, 0x2, 0x2, 0x0, 0x0)
	/go/src/github.com/urfave/cli/app.go:276 +0x725
main.main()
	/go/src/github.com/guitmz/n26/cmd/n26/n26.go:365 +0x58c

Add contact

Is it possible to add contacts?

This would make import of data possible and maybe also easy import via simple csv/excel/newline files.
Or it's just easy and fun to add contacts in my cli. :-)

More transactions?

Hello,

Is it possible to get all transactions and not only the last 20? Or filtering by date?

Thanks for this great initiative πŸ‘

401 Unauthorized

Hi, is this library still supposed to work?
I am asking since there weren’t that many updates in recent time and I am running into a 401 Unauthenticated (with empty body) response during initialization of an n26.Client object.
On my side I receive the following error

2023/11/22 02:18:50 Unexpected response from authentication request

I am trying to query data using the following code:

authInfo := n26.Auth{
		UserName:    "<username>",
		Password:    "<password>",
		DeviceToken: "<uuid>",
	}
	n26Client, _ := n26.NewClient(authInfo)
	n26Client.GetSpaces("")

Thanks in advance!
BR Dennis

Brew install not working

Screenshot 2022-01-07 at 21 24 16

Error: Invalid formula: /opt/homebrew/Library/Taps/guitmz/homebrew-tools/n26.rb
formulae require at least a URL
Error: Cannot tap guitmz/tools: invalid syntax in tap!

macos Monterey 12.1

Migrate to Graphql

Looks like N26 is migrating to Graphql, need to check and invest time on that in case they disable the current API.

Just a thank you

Pretty nice! Thanks for this. It's pretty interesting that N26 uses JAVA as their backend where Go would be way more secure and better in performance... nice wrapper, Go ftw πŸ—‘

How legal is it?

Hi! I would like to use your library in production for scraping data with the agreement of a bank client. But as far as I know PSD2 law explicitly prohibits screen scraping https://ec.europa.eu/commission/presscorner/detail/en/MEMO_17_4961. At the same time it says

PSD2 prohibits TPPs from accessing any other data from the customer payment account beyond those explicitly authorised by the customer. Customers will have to agree on the access, use and processing of these data

That's why I'm quite confused. It seems that if you have an agreement you may use it. Maybe you had an experience of using your library in production and could shed some light on legal aspects.

Authorizing transfers?

This n26 client is great! Do you plan to add a function to authorize payments? This would be very convenient as it would allow to fully use the N26 account without a smartphone.

Reusing token

After testing and try automating some collecting process, I received a "too many requests" response. Which most likely is caused because on every action there is a new login. Instead of login again all the time.

I could not find any option to reuse the given token.

Possible ways come initially in my mind:

  • local n26 config (not for the initial credentials, still security related for the amount of token time to live)
  • set a temporary environment variable
  • output the token with a copy string example like N26_TOKEN=xxx ... cmd

I like the first one more. Most likely users of this code will use it in a safer (local?) environment only. Nobody should use this at any risky environment anyway.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.