Skip to main content

Single Python interface for many Open Banking / PSD2 APIs

Project description

Open Banking aggregation library

This Python library is designed for connecting to a number of Open Banking APIs directly from your code without intermediate aggregation services. The library provides unified interface for interacting with ASPSPs (banks), harmonize data and implements cryptographic functionality needed for interaction with PSD2 APIs, such as mTLS connection using eIDAS QWAC and request signing using eIDAS QSeal certificate.

The library offers 4 API classes:

  • enablebanking.MetaApi provides information about available connectors;
  • enablebanking.AuthApi provides PSU (bank user) authentication and token creation functionality;
  • enablebanking.AispApi provides methods for accessing account information, such as transactions and balances, on behalf of a PSU;
  • enablebanking.PispApi provides methods for initiating and conforming payment requests.

The same calls and data structures are used for interacting with different banks, but for each bank enablebanking.ApiClient shall be initialised with own settings and connectors' meta information shall be used to assure appropriate use of the methods.

Please note that the connector modules are not included into this package and shall be downloaded separately. For more information refer to the Installation section.

This Python package is generated by the enable:Banking SDK generator using Swagger Codegen project.

The interfaces are based on STET PSD2 specification, but have been modified and extended in order to support usage scenarious beyond the original specification.

Requirements

Python 3.4+

certifi

cryptography

python-dateutil

Installation

It's the easiest to install the package using the Python Package Installer:

pip install enablebanking-api

In order to download a connector module you have to submit the following request to enablebanking.com website.

curl -X POST \
    -F 'connector=Nordea' \
    -F 'environment=sandbox' \
    -F 'language=python' \
    -F 'email=name@company.com' \
    https://enablebanking.com/connectors/

List of connectors is available here. Do not use ConnectorSetting postfix in the connector field when submitting the request, i.e. use just Nordea instead of NordeaConnectorSettings.

Download link will be sent to the email address you provide.

Usage

The following code shows how to initialize API client for Nordea, authenticate user and retrieve list of user's accounts.

import enablebanking
from enablebanking.connectors import NordeaConnector


# Creating API client for Nordea
client = enablebanking.ApiClient(
    NordeaConnector,
    {
        'sandbox': True,
        'consentId': None,
        'accessToken': None,
        'refreshToken': None,
        'redirectUri': 'https://your.domain/callback',
        'country': 'FI',
        'clientId': 'your-nordea-api-client-id',
        'clientSecret': 'your-nordea-api-client-secret',
        'signKeyPath': '/path/to/eidas-key.pem',
    })

# Creating authentication API accessor
auth_api = enablebanking.AuthApi(client)

# Getting authentication URL, which the user shall visit
auth = auth_api.get_auth(
    state='test', # state to pass to redirect URL
)

print('User authentication URL:', auth.url)

# Extracting authorization code from the redirect URL
code = auth_api.parse_redirect_url(
    # Using hardcoded value here. In reality redirect URL shall be read
    'https://your.domain/callback?query-params#hash-params')

# Making user token
token = auth_api.make_token(
    'authorization_code',
    code,
    auth.env
)

# Creating account information API accessor. Using same client instance already
# holding user token. In stateless web app client likely needs to be re-created
# with a token from the previous step.
aisp_api = enablebanking.AispApi(client)

# Retrieving list of user's accounts
acc_data = aisp_api.get_accounts()

for acc in acc_data.accounts:
    print('Account IBAN:', acc.account_id.iban)

The complete code sample is available in this Github repository.

Feel free to send us your technical questions at openbanking@enablebanking.com or ask them on Stack Overflow.

Documentation

The latest reference documentation for the Python library is available here.

Changelog

Changelog is available here.

License

If you have a license agreement with Enable Banking Oy covering this software, it supercedes any other license bundled with this package.

If you don't have such a license agreement, you may use this software only if the following conditions are met:

  • You do not modify or alter any of the files included into this software package;
  • You do not distribute the software on its own, nor as part of other application;
  • You do not sell or receive any consideration for this software, nor for other software where this software package is used;
  • You are solely responsible for determining the appropriateness of using the software and assume any risks associated with your exercise of permissions to use this software (i.e. the software is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND).

Enable Banking Oy provides commercial licenses for purchase for various usage scenarios that are not covered by the above conditions. Please contact us at hello@enablebanking.com, we'll be happy to help you.

Author

Enable Banking Oy

For more information, please visit https://enablebanking.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

enablebanking_api-0.5.1-py3-none-any.whl (295.5 kB view details)

Uploaded Python 3

File details

Details for the file enablebanking_api-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: enablebanking_api-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 295.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for enablebanking_api-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e9ad93ffa49575622a945c181a24af0e62f7c793a96ad428778beb13aa250ecf
MD5 be614e48f7b7ed3e358b79a6a423f904
BLAKE2b-256 3a34895bb16a4d06fc379e650360bfd9fc5105efe2ad86edbc582c6f660831c6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page