Git Product home page Git Product logo

nordigen-python's Introduction

Nordigen Python

This is official Python client library for GoCardless Bank Account Data API

For a full list of endpoints and arguments, see the docs.

Before starting to use API you will need to create a new secret and get your SECRET_ID and SECRET_KEY from the GoCardless Bank Account Data Portal.

Requirements

  • Python >= 3.8

Installation

Install library via pip package manager:

pip install nordigen

Example application

Example code can be found in main.py file and Flask application can be found in the example directory

Quickstart

from uuid import uuid4

from nordigen import NordigenClient

# initialize Nordigen client and pass SECRET_ID and SECRET_KEY
client = NordigenClient(
    secret_id="SECRET_ID",
    secret_key="SECRET_KEY"
)

# Create new access and refresh token
# Parameters can be loaded from .env or passed as a string
# Note: access_token is automatically injected to other requests after you successfully obtain it
token_data = client.generate_token()

# Use existing token
client.token = "YOUR_TOKEN"

# Exchange refresh token for new access token
new_token = client.exchange_token(token_data["refresh"])

# Get institution id by bank name and country
institution_id = client.institution.get_institution_id_by_name(
    country="LV",
    institution="Revolut"
)

# Get all institution by providing country code in ISO 3166 format
institutions = client.institution.get_institutions("LV")

# Initialize bank session
init = client.initialize_session(
    # institution id
    institution_id=institution_id,
    # redirect url after successful authentication
    redirect_uri="https://gocardless.com",
    # additional layer of unique ID defined by you
    reference_id=str(uuid4())
)

# Get requisition_id and link to initiate authorization process with a bank
link = init.link # bank authorization link
requisition_id = init.requisition_id

After successful authorization with a bank you can fetch your data (details, balances, transactions)


Fetching account metadata, balances, details and transactions

# Get account id after you have completed authorization with a bank
# requisition_id can be gathered from initialize_session response
accounts = client.requisition.get_requisition_by_id(
    requisition_id=init.requisition_id
)

# Get account id from the list.
account_id = accounts["accounts"][0]

# Create account instance and provide your account id from previous step
account = client.account_api(id=account_id)

# Fetch account metadata
meta_data = account.get_metadata()
# Fetch details
details = account.get_details()
# Fetch balances
balances = account.get_balances()
# Fetch transactions
transactions = account.get_transactions()
# Filter transactions by specific date range
transactions = account.get_transactions(date_from="2021-12-01", date_to="2022-01-21")

Premium endpoints

# Get premium transactions. Country and date parameters are optional
premium_transactions = account.get_premium_transactions(
    country="LV",
    date_from="2021-12-01",
    date_to="2022-01-21"
)
# Get premium details
premium_details = account.get_premium_details()

Support

For any inquiries please contact support at [email protected] or create an issue in repository.

nordigen-python's People

Contributors

andreykan1 avatar ekatvars-gc avatar janisgn avatar juhoen avatar mr-andersons avatar safriks avatar victory-sokolov avatar zippolyte avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nordigen-python's Issues

Incomplete API for POST /api/v2/requisitions/

https://bankaccountdata.gocardless.com/api/docs#/requisitions/Create%20requisition lists parameters including user_language and ssn.

{
"redirect": "string",
"institution_id": "string",
"agreement": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"reference": "string",
"user_language": "strin",
"ssn": "string",
"account_selection": false,
"redirect_immediate": false
}

create_requisition lacks the ssn parameter: https://github.com/nordigen/nordigen-python/blob/master/nordigen/api/requisitions.py#L46C9-L46C27

When using initialize_session as the README suggests it lacks both the user_language and the ssn parameters:

def initialize_session(

So at the moment the only option is to use the HTTP endpoints directly in order to have access to the features.

Auth flow

Hello, I have a question regarding the auth flow. I have two accounts integrated with a bank. Do I always have to go through the step of generating a link and authenticating through the browser window in order for the accounts to be filled out? Does the requisition id remain static or?

Transactions date range filter not working

Hi,
According to the example in the README it should be possible to fetch transactions for a specific date range.
However, when I try this I get the following error: get_transactions() got an unexpected keyword argument 'date_from'.
Could it be that this functionality is not yet available in the last released version (v 1.0.1)?

image

404 - Not Found on fetching account metadata

Line 59 fails with the following error:
meta_data = account.get_metadata()
requests.exceptions.HTTPError: {'response': {'summary': 'Not found.', 'detail': 'Not found.', 'status_code': 404}, 'status': 404}

Receiving a 401 response after authenticating

Not too sure if a bug or just incorrect usage of the API.

I have initialized a new session through the following code, clicked the link and authorized:

init = client.initialize_session(institution_id = "ING_INGBNL2A", redirect_uri = "https://nordigen.com", reference_id=str(uuid4()))
print(init.link)

requisition_id = init.requisition_id
print(requisition_id)

Then copied the requisition_id and pasted in the following code:

accounts = client.requisition.get_requisition_by_id(requisition_id = "PASTED HERE")
print(json.dumps(accounts, indent = 2))

If I understand correctly, I have authorized properly, and should not be getting a 401 response.

Type hints are incorrect according to the API schema

Hello, I've noticed that several type hints are incorrect. For reference, I checked the official API schema.
Below are some examples:


class EnduserAgreement(TypedDict):
id: str
created: str
enduser_id: str
institution_id: str
accepted: Optional[str]
access_scope: List[str]
max_historical_days: int
access_valid_for_days: int


class Requisition(TypedDict):
id: str
created: str
redirect: str
status: str
agreements: List[str]
accounts: List[str]
reference: str
enduser_id: str
user_language: Optional[str]
results: List[Dict[str, str]]

  • agreements isn't available in the API response, but instead agreement (string instead of list) is available
  • enduser_id is not available in the API response
  • link property is missing in type hints
  • ssn property is missing in type hints
  • account_selection property is missing in type hints
  • redirect_immediate property is missing in type hints
  • results isn't part of that object
    Ref to API Schema

exchange_token doesn't return correct information

Describe the bug
When calling the exchange token function, it only returns the new access token and access expiration date, and not the refresh token as said in the docstring.

To Reproduce
Steps to reproduce the behavior:

  1. Create Nordigen client
  2. call client.exchange_token

Expected behavior
I expected to receive a new TokenType with a new access and refresh token in it

Publish 1.4.0 to PyPI

I received an email today that the API URL will change in 7 days, on February 20. You already have the necessary changes in this GitHub repository. But the associated version 1.4.0 is not yet on PyPI. Would you please upload it there?

Failing to fetch account id

I have Nordigen setup with 1 account (bank : N26).
When executing line 52:
account_id = accounts["accounts"][0]
...I get the following error:
account_id = accounts["accounts"][0] IndexError: list index out of range

I had to correct the code in that line to the following to work around my issue:
account_id = accounts["id"]

Why does the agreement accept endpoint require user_agent + ip_address

Hi, this is more of a general question regarding the Nordigen API but I couldn't find any documentation describing why I need to provide a user agent and IP address in the request body when accepting an end user agreement via the API.

The route I am talking about: https://nordigen.com/en/docs/account-information/integration/parameters-and-responses/#/agreements/accept%20EUA

Is this a case of "user A with IP X communicates with backend B with IP Y, which communicates with the API" and therefore the backend would need to communicate IP X (and user agent of user A) to the API?

Also do the values of these parameters have any implications on anything?

Edit: Another question: in what case is it possible to use this accept endpoint? (I'm getting: "Your company doesn't have permission to accept EUA")

Use aiohttp for the HTTP requests instead of requests

Is your feature request related to a problem? Please describe.
Nordigen client uses requests library which makes blocking http calls. This creates bottlenecks when fetching data for multiple requisition ids.

Describe the solution you'd like
Use aiohttp library which is asycnio-native. This will enable concurrent work using asyncio.gather which will dramatically speed up execution when working with multiple requistion ids.

The codebase is fairly small and I'm happy to make the change if the owners are happy with the idea.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.