A Python package to interact with Nordigen API for bank account management.
Project description
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_idandsecret_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
BankAccountManagerclass.
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_idsecret_keyrefresh_tokenrequisition_id
Follow these steps to generate the credentials:
- Go to the Nordigen Bank Account Data API portal:
https://developer.gocardless.com/bank-account-data/overview - Sign up for an account and log in.
- Navigate to the API Keys section to generate your
secret_idandsecret_key. - Follow the API documentation steps to create a requisition and obtain a
requisition_id.
Therefresh_tokenis 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.
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, refresh_token = create_nordigen_client(secret_id, secret_key, refresh_token)
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.
The function will return a tuple containing the client instance and the latest refresh_token that you can use to update your credentials.
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:
- Account details
- currency
- status
- name
- 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
The code raises ValueError for:
- Expired requisition (status EX).
- No linked accounts, which suggests bank authorization has not been completed.
- Invalid token, which suggests the refresh token may have expired (status code 401).
If your requisition has expired or bank authorization has not been completed follow steps in the Nordigen official documentation to generate a new requisition or complete bank authorization.
If your refresh token has expired, instantiate the Nordigen Client again and don't pass in a refresh token or pass in an empty string. A new refresh token will be generated and returned during instantiation.
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:
-
Clone the repository:
git clone https://github.com/rahulpdev/nordigen_account.git cd nordigen_account
-
Install dependencies:
pip install -r requirements.txt
-
Run tests or explore the package functionality.
Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new feature branch.
- Commit your changes.
- 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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nordigen_account-0.1.0.tar.gz.
File metadata
- Download URL: nordigen_account-0.1.0.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cea51199403abfbed7fe3f620fd85191fb3681cb96f9baca9e2c77b1b6e16512
|
|
| MD5 |
c29851b7bca179ab556f9157f3ddb288
|
|
| BLAKE2b-256 |
1eb33fc2a11875a6c26414514830cd401c545dc49d50150bdde4927fc5ff3fe4
|
File details
Details for the file nordigen_account-0.1.0-py3-none-any.whl.
File metadata
- Download URL: nordigen_account-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ebd9ad3dc99d78f53e6102a495a567538cd2410f624df1f315160b1b72177448
|
|
| MD5 |
30f0da47f12d157cde1e30ce01f980cd
|
|
| BLAKE2b-256 |
19c42f1016305919c592f9ae507925bf17f84f048b313285be89093f7a3b804c
|