All Projects → femueller → Python N26

femueller / Python N26

Licence: mit
💵 Unofficial Python client for n26 (Number 26) - https://n26.com/

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Python N26

N26
API and CLI to get information of your N26 account
Stars: ✭ 107 (-7.76%)
Mutual labels:  api, command-line-tool, cli, bank
Freenom Dns Updater
A tool to update freenom's dns records
Stars: ✭ 117 (+0.86%)
Mutual labels:  api, command-line-tool, cli
Hopp Doc Gen
📔 API documentation generator CLI for https://hoppscotch.io
Stars: ✭ 70 (-39.66%)
Mutual labels:  api, command-line-tool, cli
Pypistats
Command-line interface to PyPI Stats API to get download stats for Python packages
Stars: ✭ 86 (-25.86%)
Mutual labels:  api, command-line-tool, cli
Rundeck Cli
CLI tool for Rundeck
Stars: ✭ 98 (-15.52%)
Mutual labels:  api, cli
Tooling
Advancing Node.js as a framework for writing great tools
Stars: ✭ 98 (-15.52%)
Mutual labels:  command-line-tool, cli
Ask Cli
Alexa Skills Kit Command Line Interface
Stars: ✭ 100 (-13.79%)
Mutual labels:  command-line-tool, cli
Schema Registry
A CLI and Go client for Kafka Schema Registry
Stars: ✭ 105 (-9.48%)
Mutual labels:  api, cli
Matrix Commander
simple but convenient CLI-based Matrix client app for sending and receiving
Stars: ✭ 90 (-22.41%)
Mutual labels:  command-line-tool, cli
Csv2db
The CSV to database command line loader
Stars: ✭ 102 (-12.07%)
Mutual labels:  command-line-tool, cli
Cli.fan
Blog about notable commandline tools
Stars: ✭ 106 (-8.62%)
Mutual labels:  command-line-tool, cli
Terminal layout
The project help you to quickly build layouts in terminal,cross-platform(一个跨平台的命令行ui布局工具)
Stars: ✭ 98 (-15.52%)
Mutual labels:  command-line-tool, cli
Awesome React Generator
No more clicking around to create files in your react project! Awesome React Generator is Command Line Tool that let's you scaffold your components without leaving your terminal.
Stars: ✭ 98 (-15.52%)
Mutual labels:  command-line-tool, cli
Cryptocurrency Cli
💰 Cryptocurrency Portfolio On The Command Line 💰
Stars: ✭ 99 (-14.66%)
Mutual labels:  api, cli
Blockshell
🎉 Minimal Blockchain Learning CLI
Stars: ✭ 1,348 (+1062.07%)
Mutual labels:  command-line-tool, cli
Awesome Cli
A curated list of awesome resources for building immersive CLI experiences.
Stars: ✭ 104 (-10.34%)
Mutual labels:  command-line-tool, cli
Src Cli
Sourcegraph CLI
Stars: ✭ 108 (-6.9%)
Mutual labels:  api, cli
Cjstoesm
A tool that can transform CommonJS to ESM
Stars: ✭ 109 (-6.03%)
Mutual labels:  api, cli
Httpcat
httpcat is a simple utility for constructing raw HTTP requests on the command line.
Stars: ✭ 109 (-6.03%)
Mutual labels:  api, cli
Run
⚡The resource runtime
Stars: ✭ 90 (-22.41%)
Mutual labels:  api, cli

N26 Python CLI/API

Build Status PyPI version PyPI version Downloads

asciicast

About

python-n26 is a Python 3.6+ library and Command Line Interface to request information from n26 bank accounts. You can use it to check your balance from the terminal or include it in your own Python projects.

Disclaimer: This is an unofficial community project which is not affiliated with N26 GmbH/N26 Inc.

Install

pip3 install n26
wget https://raw.githubusercontent.com/femueller/python-n26/master/n26.yml.example -O ~/.config/n26.yml
# configure username and password
vim ~/.config/n26.yml

Configuration

python-n26 uses container-app-conf to provide different options for configuration. You can place a YAML (n26.yaml or n26.yml) or TOML (n26.toml or n26.tml) configuration file in ./, ~/ or ~/.config/. Have a look at the YAML example and TOML example. If you want to use environment variables:

  • N26_USER: username
  • N26_PASSWORD: password
  • N26_DEVICE_TOKEN: random uuid to identify the device
  • N26_LOGIN_DATA_STORE_PATH: optional file path to store login data (recommended for cli usage)
  • N26_MFA_TYPE: app will use the paired app as 2 factor authentication, sms will use SMS to the registered number.

Note that when specifying both environment variables as well as a config file and a key is present in both locations the enviroment variable values will be preferred.

Authentication

Device Token

Since 17th of June 2020 N26 requires a device_token to differentiate clients. This requires you to specify the DEVICE_TOKEN config option with a UUID of your choice. To generate a UUID you can use f.ex. one of the following options:

Using python:

python -c 'import uuid; print(uuid.uuid4())'

Using linux built-in tools:

> uuidgen

Using a website: https://www.uuidgenerator.net/

2FA

Since 14th of September 2019 N26 requires a login confirmation (2 factor authentication).

There are two options here:

  1. Using the paired phone N26 app to approve login on devices that are not paired. This can be configured by setting app as the mfa_type. You will receive a notification on your phone when you start using this library to request data. python-n26 checks for your login confirmation every 5 seconds. If you fail to approve the login request within 60 seconds an exception is raised.
  2. Using a code delivered via SMS to your registered phone number as 2 factor authentication. This can be configured by setting sms as the mfa_type.

If you do not specify a login_data_store_path this login information is only stored in memory. In order to avoid that every CLI command requires a new confirmation, the login data retrieved in the above process can be stored on the file system. Please note that this information must be protected from the eyes of third parties at all costs. You can specify the location to store this data in the Configuration.

Usage

CLI example

> n26 balance
123.45 EUR

Or if using environment variables:

> N26_USER=user N26_PASSWORD=passwd N26_DEVICE_TOKEN=00000000-0000-0000-0000-000000000000 N26_MFA_TYPE=app n26 balance
123.45 EUR

JSON output

If you would like to work with the raw JSON rather than the pretty table layout you can use the global -json parameter:

> n26 -json balance
{
  "id": "12345678-1234-1234-1234-123456789012",
  "physicalBalance": null,
  "availableBalance": 123.45,
  "usableBalance": 123.45,
  "bankBalance": 123.45,
  "iban": "DE12345678901234567890",
  "bic": "NTSBDEB1XXX",
  "bankName": "N26 Bank",
  "seized": false,
  "currency": "EUR",
  "legalEntity": "EU",
  "users": [
    {
      "userId": "12345678-1234-1234-1234-123456789012",
      "userRole": "OWNER"
    }
  ],
  "externalId": {
    "iban": "DE12345678901234567890"
  }
}

API example

from n26.api import Api
api_client = Api()
print(api_client.get_balance())

This is going to use the same mechanism to load configuration as the CLI tool, to specify your own configuration you can use it as:

from n26.api import Api
from n26.config import Config

conf = Config(validate=False)
conf.USERNAME.value = "[email protected]"
conf.PASSWORD.value = "$upersecret"
conf.LOGIN_DATA_STORE_PATH.value = None
conf.MFA_TYPE.value = "app"
conf.validate()

api_client = Api(conf)
print(api_client.get_balance())

Projects using python-n26

The following projects are using python-n26:

Contribute

If there are any issues, bugs or missing API endpoints, feel free to contribute by forking the project and creating a Pull-Request.

Run locally

Prerequirements: Pipenv

git clone [email protected]:femueller/python-n26.git
cd python-n26
pipenv shell
pipenv install
python3 -m n26 balance

Creating a new release (only for maintainers)

# Increment version number in n26/__init__.py

# Create a new release using the Makefile
make git-release

Maintainers

Credits

Similar projects

Disclaimer

This project is not affiliated with N26 GmbH/N26 Inc. if you want to learn more about it, visit https://n26.com/.

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].