enablebanking-api 0.5.1
Single Python interface for many Open Banking / PSD2 APIs
Requires Python: >=3.4
Keywords: enable:Banking SDK,Open Banking,PSD2,API aggregation

# [Open Banking aggregation library](https://enablebanking.com/)

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](https://github.com/swagger-api/swagger-codegen) project.

The interfaces are based on [STET PSD2 specification](https://www.stet.eu/en/psd2/),
but have been modified and extended in order to support usage scenarious beyond
the original specification.

## Requirements

Python 3.4+

[certifi](https://pypi.org/project/certifi/)

[cryptography](https://pypi.org/project/cryptography/)

[python-dateutil](https://pypi.org/project/python-dateutil/)

## Installation

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

```sh
pip install enablebanking-api
```

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

```sh
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](https://enablebanking.com/docs/sdk/latest/?python#connectors-types).
*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.

```python
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](https://github.com/enablebanking/OpenBankingPythonExamples).

Feel free to send us your technical questions at
[openbanking@enablebanking.com](mailto:openbanking@enablebanking.com) or ask them
on [Stack Overflow](https://stackoverflow.com/).

## Documentation

The latest reference documentation for the Python library is available
[here](https://enablebanking.com/docs/sdk/latest/?python).

## Changelog

Changelog is available [here](https://enablebanking.com/docs/sdk/latest/#changelog).

## 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](mailto:hello@enablebanking.com), we'll be happy to help
you.

## Author

[Enable Banking Oy](mailto:hello@enablebanking.com)

For more information, please visit [https://enablebanking.com](https://enablebanking.com)