Skip to content
Python SDK for bunq API
Python
Branch: develop
Clone or download
Latest commit e06520c Dec 30, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Imporved text by removing some typos. (#60) Jan 2, 2018
.idea Add unittests Aug 1, 2017
assets add v 0.9 Jul 31, 2017
bunq feature/python-sdk-refactor Code review fix. Oct 24, 2019
examples @ f37e987 Updated the python SDK core models to match that of the other SDKs. A… Sep 13, 2019
tests feature/python-sdk-refactor Merge Request fixes and code cleanup. Sep 23, 2019
.gitattributes Marked all files in generated dir as generated code. Sep 7, 2017
.gitignore Allow Python 3.5.3 as minimum. (#109) Oct 24, 2018
.gitmodules Added tinker as submodule for examples. (#68) Apr 7, 2018
.zappr.yaml Removed auto branch creation. Apr 7, 2018
CHANGELOG.md Regenerated changelog. Jun 17, 2019
CONTRIBUTING.md add readme introduction and contributing guide Jul 31, 2017
LICENSE.md first commit Jul 27, 2017
MANIFEST.in
README.md Updated the python SDK exceptions to match that of the other SDKs. Sep 12, 2019
VERSION Version bump to 1.10.2. May 22, 2019
requirements.txt add proxy support [#16] Aug 21, 2017
run.py add v 0.9 Jul 31, 2017
setup.cfg cleanup [#20] Sep 4, 2017
setup.py feature/python-sdk-refactor Updated Type Annotations for all the JSON… Oct 15, 2019

README.md

bunq Python SDK

Introduction

Hi developers!

Welcome to the bunq Python SDK! 👨‍💻

We're very happy to introduce yet another unique product: complete banking SDKs! Now you can build even bigger and better apps and integrate them with your bank of the free! 🌈

Before you dive into this brand new SDK, please consider:

  • Checking out our new developer’s page https://bunq.com/en/developer 🙌
  • Grabbing your production API key from the bunq app or generate a Sandbox API key using Tinker 🗝
  • Visiting together.bunq.com where you can share your creations, questions and experience 🎤

Give us your feedback, create pull requests, build your very own bunq apps and most importantly: have fun! 💪

This SDK is in beta. We cannot guarantee constant availability or stability. Thanks to your feedback we will make improvements on it.

Installation

pip install bunq_sdk --upgrade

Usage

Creating an API context

In order to start making calls with the bunq API, you must first register your API key and device, and create a session. In the SDKs, we group these actions and call it "creating an API context". The context can be created by using the following code snippet:

apiContext = context.ApiContext(ENVIRONMENT_TYPE, API_KEY,
  DEVICE_DESCRIPTION);
apiContext.save(API_CONTEXT_FILE_PATH)
context.BunqContext.loadApiContext(apiContext)

This code snippet, except for context.BunqContext.loadApiContext(apiContext) should be called once per API key.

Example

See tinker/setup_context

Safety considerations

The file storing the context details (i.e. bunq.conf) is a key to your account. Anyone having access to it is able to perform any Public API actions with your account. Therefore, we recommend choosing a truly safe place to store it.

Making API calls

There is a class for each endpoint. Each class has functions for each supported action. These actions can be create, get, update, delete and list.

Sometimes API calls have dependencies, for instance MonetaryAccount. Making changes to a monetary account always also needs a reference to a User. These dependencies are required as arguments when performing API calls. Take a look at doc.bunq.com for the full documentation.

Creating objects

Creating objects through the API requires an ApiContext, a requestMap and identifiers of all dependencies (such as User ID required for accessing a Monetary Account). Optionally, custom headers can be passed to requests.

payment_id = endpoint.Payment.create(
	amount=Amount(amount_string, self._CURRENCY_EURL),
    counterparty_alias=Pointer(self._POINTER_TYPE_EMAIL, recipient),
    description=description
    )
Example

See tinker/make_payment

Reading objects

Reading objects through the API requires an ApiContext, identifiers of all dependencies (such as User ID required for accessing a Monetary Account), and the identifier of the object to read (ID or UUID) Optionally, custom headers can be passed to requests.

This type of calls always returns a model.

monetary_account = generated.MonetaryAccountBank.get(
    _MONETARY_ACCOUNT_ITEM_ID
)
Example

See tinker/list_all_payment

Updating objects

Updating objects through the API goes the same way as creating objects, except that also the object to update identifier (ID or UUID) is needed.

endpoint.Card.update(
	card_id=int(card_id),
	monetary_account_current_id=int(account_id)
	)
Example

See tinker/update_card

Deleting objects

Deleting objects through the API requires an ApiContext, identifiers of all dependencies (such as User ID required for accessing a Monetary Account), and the identifier of the object to delete (ID or UUID) Optionally, custom headers can be passed to requests.

Session.delete(self._SESSION_ID)
Example

Listing objects

Listing objects through the API requires an ApiContext and identifiers of all dependencies (such as User ID required for accessing a Monetary Account). Optionally, custom headers can be passed to requests.

users = generated.User.list(api_context)
Example

See UserListExample.py

Running Samples

To get an indication on how the SDK works you can use the python tinker which is located at https://github.com/bunq/tinker_python

Running Tests

Information regarding the test cases can be found in the README.md located in test

Exceptions

The SDK can raise multiple exceptions. For an overview of these exceptions please take a look at EXCEPTIONS.md

You can’t perform that action at this time.