Skip to main content

This project aims to have a complete Python wrapper for the Bunq API. It takes inspiration from the .NET wrapper written by the great MLowijs. Some functionality, especially in ApiClient, is based on or taken from the thin API wrapper created by MadEddie. Thanks MLowijs and MadEddie!

This project is built in Python 3.6

Build Status BCH compliance Test Coverage Updates Python 3

Getting started

  1. First enter your API Key in the apiwrapper/config/parameters.ini file.

  2. Next, create a new Virtual Environment based on Python 3.6

  3. Activate your Virtual Environment and install the requirements in requirements.txt with pip3.6 install -r requirements.txt

  4. Open get_started.py, read through the comments and follow them. After doing this you will have a ready-to-go installation and can start using the API!

Reuse Installation

If you followed the script get_started.py mentioned above already, you should have the following parameters saved somewhere:

  • API Key

  • Private Key

  • Installation Token (not needed if you have the Session Token)

  • Installation ID (needed to create new session tokens)

  • Server Public Key

  • Session Token

Note: If you saved these parameters to the config file, they will be in apiwrapper/config/parameters.ini

If you have the above parameters, you can go ahead and create an APIClient, which is the connector to the Bunq API.

You will have to decide which APIClient to use. At the moment, I included one that uses the config file in apiwrapper/config/parameters.ini, which is the ‘normal’ class APIClient. Also, on request from OGKevin, I included an APIClient, which does not load the parameters from a config file, called the APIClientNonPersisting.

So, decide on whether to use the config file or not and uncomment one of the following lines:

If you want to use the parameters stored in apiwrapper/config/parameters.ini, use the following code:

from apiwrapper.clients.api_client_persisting import ApiClientPersisting

api_key = "YOUR API KEY HERE"
api = ApiClientPersisting(api_key)

Else, if you want to use your own parameters, use the following lines and enter your parameters there

from apiwrapper.clients.api_client import ApiClient

api_key = "YOUR API KEY HERE"
private_key = "YOUR PRIVATE KEY HERE"
session_token = "YOUR SESSION TOKEN HERE"
server_public_key = "THE SERVER PUBLIC KEY HERE"

api = ApiClient(api_key, privkey=private_key,
                                 session_token=session_token,
                                 server_pubkey=server_public_key)

Now, you are able to make calls to the Bunq API using the EndpointsController. I have included an example of how to get the User ID from the API:

from apiwrapper.clients.api_client import ApiClient
from apiwrapper.clients.api_client_persisting import ApiClientPersisting
import json

api = "MAKE SURE TO CREATE THE API CLIENT AS DESCRIBED ABOVE"

res = api.endpoints.user.get_logged_in_user()
print(json.dumps(res, indent=2))

How to use this API Wrapper

Each endpoint of the Bunq API has its own Endpoint module. The existing ones are in the apiwrapper/endpoints package. The EndpointController in apiwrapper/endpoints/controller has an instance of each of these endpoints. Any ApiClient will have an instance of this endpoint controller called endpoints. After creating an ApiClient you can simply make api calls with:

api_client.endpoints.ENDPOINT_OF_YOUR_CHOICE.CALL_OF_YOUR_CHOICE()

Endpoint functions simply return the response from the Bunq API.

[Example] Retrieve all Monetary Accounts for User

import json

from apiwrapper.clients.api_client_persisting import ApiClientPersisting

user_id = 1234

api = ApiClientPersisting()
res = api.endpoints.monetary_account.get_all_accounts_for_user(user_id)

print(json.dumps(res, indent=2))

Contribute

If you want to contribute, fork this repository and start implementing one of the following points: * Add POST, PUT, and some DELETE calls for all endpoints * Add Encryption/Decryption of /config/parameter.ini file using Password * Have a look at the Issues of this repository

Metadata

Release files for bunq-api-sdk 0.1.3

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

Source distribution (sdist)

Source distribution for bunq-api-sdk 0.1.3
File Size Uploaded
bunq-api-sdk-0.1.3.tar.gz 4.0 kB Details

Release files / bunq-api-sdk-0.1.3.tar.gz

Download URL bunq-api-sdk-0.1.3.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e4a6b1594128ac3fda34d18566b4313c4d0f6db60968c9ab258bc67b096ce565
BLAKE2b-256 checksum
How to use checksums
a663cd28d4f33fff5a5e9aa5dc4c1d61ee40d75ef278856347ee8211b30435fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.3 This release

1 release file

0.1.2

1 release file

0.1.0

1 release file

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