Skip to main content

Nordigen Account

A Python package to interact with the Nordigen Bank Account API, allowing users to retrieve and manage bank account details and balances.

Features

  • Secure connection to the Nordigen API using secret_id and secret_key.
  • Retrieve bank account details such as name, status, and currency.
  • Fetch account balances, including multiple balance types and currencies.
  • Manage multiple linked accounts via the BankAccountManager class.
  • Automatic retrieval of new refresh token when expired.
  • Unified error handling using a custom NordigenAPIError exception.

Installation

Ensure Python 3.7+ is installed. To install the package, use:

pip install nordigen

Generating Credentials

To use this package, you need to obtain credentials from Nordigen, which include:

  • secret_id
  • secret_key
  • refresh_token
  • requisition_id

Follow these steps to generate the credentials:

  1. Go to the Nordigen Bank Account Data API portal:
    https://developer.gocardless.com/bank-account-data/overview
  2. Sign up for an account and log in.
  3. Navigate to the API Keys section to generate your secret_id and secret_key.
  4. Follow the API documentation steps to create a requisition and obtain a requisition_id.
    The refresh_token is retrieved when you generate an access token via the API.

Once you have obtained these credentials, you can use them to connect to the API and fetch your bank account details.
The refresh_token will expire every 30 days and the requisition_id every 90 days and must be refreshed.

Usage

1. Instantiate the Nordigen Client

Use the create_nordigen_client function to instantiate the Nordigen client with the required credentials.
You can pass an optional refresh token, but if not provided, the function will attempt to generate a new one using the provided secret_id and secret_key.

from nordigen_account import create_nordigen_client

# Replace with your actual credentials
secret_id = "your-secret-id"
secret_key = "your-secret-key"
refresh_token = "your-refresh-token"  # Optional

client, new_refresh_token = create_nordigen_client(secret_id, secret_key, refresh_token)

If your refresh token has expired, the function will automatically generate a new one.
The function will return a tuple containing the client instance and a new refresh_token if generated, or None if the existing token is still valid.

Handling refresh tokens:
If a new refresh_token is generated, make sure to update your stored credentials for subsequent API requests.

client, new_refresh_token = create_nordigen_client(secret_id, secret_key, refresh_token)

if new_refresh_token:
    print("New refresh token generated:", new_refresh_token)
    # Store the new token securely for future API requests

2. Manage Multiple Accounts

The BankAccountManager class manages multiple bank accounts linked to a requisition ID.
When you instantiate BankAccountManager, it automatically initializes instances of the BankAccount class for each linked account.

from nordigen_account import BankAccountManager

requisition_id = "your-requisition-id"

# Instantiate account manager
manager = BankAccountManager(client, requisition_id, fetch_data=True)

# Access account details
for account in manager.accounts:
   print("Account ID:", account._account_id)
   print("Balances:", account.balances)

By default BankAccount data is not collected when you initialize BankAccountManager. To optionally collect account data, set the fetch_data flag to True.

3. Data Properties

Two data sets are currently supported:

  1. Account details
  • currency
  • status
  • name
  1. Account balances data
  • balanceType
  • currency
  • amount

To access / refresh each data set use the following commands:

for account in manager.accounts:
   account.update_account_data()
   account.update_balance_data()

4. Error handling

All errors related to the Nordigen API or account management are raised as a NordigenAPIError. This exception provides:

  • A descriptive error message.
  • The HTTP status code (if available).
  • The API response body for debugging.

Example:

from nordigen_account import NordigenAPIError

try:
    account.update_balance_data()
except NordigenAPIError as e:
    print(f"Error: {e.message}")
    if e.status_code:
        print(f"HTTP Status Code: {e.status_code}")
    if e.response_body:
        print(f"Response Body: {e.response_body}")

This unified error handling makes it easier to debug issues and ensures consistent error reporting throughout the library.

Project Structure

nordigen_account/
|-- nordigen_account/
|  |-- __init__.py        # Core functionality and class definitions
|-- setup.py              # Package configuration for distribution
|-- requirements.txt      # Dependencies
|-- LICENSE               # License information
|-- README.md             # Project documentation
|-- MANIFEST.in           # Package manifest

Dependencies

The package requires the following dependency:

  • nordigen – Python client for Nordigen API.

The dependency is listed in the requirements.txt file.

Setup for Development

To set up the project locally:

  1. Clone the repository:

    git clone https://github.com/rahulpdev/nordigen_account.git
    cd nordigen_account
    
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Run tests or explore the package functionality.

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new feature branch.
  3. Commit your changes.
  4. Push the branch and open a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Rahul Parmar
GitHub Profile


For more details on the Nordigen API, visit their official documentation.

Metadata

Release files for nordigen-account 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nordigen-account 0.3.1
File Size Uploaded
nordigen_account-0.3.1.tar.gz 6.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nordigen-account 0.3.1
File Interpreter ABI Platform
nordigen_account-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 13.4 kB

Release files / nordigen_account-0.3.1.tar.gz

Download URL nordigen_account-0.3.1.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c816ee19260009582bc925e444b303e006a0e6faaae52c69477b51185a18f230
BLAKE2b-256 checksum
How to use checksums
22e4ae37aab6778e9716967928be8a68854a0fcfd5230a2eb6eb6415f1bb9d12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.16

Release files / nordigen_account-0.3.1-py3-none-any.whl

Download URL nordigen_account-0.3.1-py3-none-any.whl
Size 6.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
004ee5e593e5d47df84acd0bf2ab9993ec8428cb6c8ca8119cfe6dbeb06ebc36
BLAKE2b-256 checksum
How to use checksums
c7c26b60be74e072d00c6cfd0c8f20a51326536c05e4b591e2efc77aa897f51c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.16

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page