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
apiwrapper/config/parameters.ini
file.requirements.txt
with pip3.6 install -r requirements.txt
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!If you followed the script get_started.py
mentioned above already, you should have the following parameters saved somewhere:
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))
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.
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))
If you want to contribute, fork this repository and start implementing one of the following points:
POST
, PUT
, and some DELETE
calls for all endpoints/config/parameter.ini
file using Password