Package: bunq-api-sdk
This project aims to have a complete Python wrapper for theBunq
API. It takes inspiration from the.NET
wrapperwritten by the greatMLowijs. Some functionality, especially
inApiClient, is based on or taken from the thinAPI
wrappercreated byMadEddie. Thanks MLowijs and MadEddie!This project is built inPython 3.6Getting startedFirst enter yourAPI Keyin theapiwrapper/config/parameters.inifile.Next,create a new Virtual
Environmentbased onPython 3.6Activate your Virtual Environment and install the requirements inrequirements.txtwithpip3.6 install-rrequirements.txtOpenget_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 InstallationIf you followed the scriptget_started.pymentioned above already,
you should have the following parameters saved somewhere:API KeyPrivate KeyInstallation Token (not needed if you have the Session Token)Installation ID (needed to create new session tokens)Server Public KeySession TokenNote: If you saved these parameters to the config file, they will be inapiwrapper/config/parameters.iniIf 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 inapiwrapper/config/parameters.ini, which is the ‘normal’ classAPIClient. Also, on request from OGKevin, I included an APIClient,
which does not load the parameters from a config file, called theAPIClientNonPersisting.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 inapiwrapper/config/parameters.ini, use the following code:fromapiwrapper.clients.api_client_persistingimportApiClientPersistingapi_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 therefromapiwrapper.clients.api_clientimportApiClientapi_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 theEndpointsController. I have included an example of how to get the
User ID from the API:fromapiwrapper.clients.api_clientimportApiClientfromapiwrapper.clients.api_client_persistingimportApiClientPersistingimportjsonapi="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 WrapperEach endpoint of theBunq APIhas its ownEndpointmodule. The existing ones are in theapiwrapper/endpointspackage. TheEndpointControllerinapiwrapper/endpoints/controllerhas an instance of each of these
endpoints. Any ApiClient will have an instance of this endpoint
controller calledendpoints. 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 Userimportjsonfromapiwrapper.clients.api_client_persistingimportApiClientPersistinguser_id=1234api=ApiClientPersisting()res=api.endpoints.monetary_account.get_all_accounts_for_user(user_id)print(json.dumps(res,indent=2))ContributeIf you want to contribute, fork this repository and start implementing
one of the following points: * AddPOST,PUT, and someDELETEcalls for all endpoints * Add Encryption/Decryption of/config/parameter.inifile using Password * Have a look at the
Issues of this repository