• Developers
  • A simple Python-SDK example.

I'm not a developer. Decoding all the documentation and all other plentiful resources online like the unreadable 640p video on the Bunq youtube, the main bunq developer page steps, and even the full documentation and beta documentation, including the Python-Wrapper on Github were all not enough for me to figure out how to work the API and create a practical example to work from. Pretty certain this has been written strictly for professional developers but a simpler python example would have helped me greatly :)

Here's what I'm trying to get working:

`from bunq.sdk.context.bunq_context import ApiContext
from bunq import Pagination

apiContext = ApiContext.create("SANDBOX", "02381a10642000000000357f3f1455546624562400000000120ef3300555557ef", "D1")
apiContext.save("/api_context")

pagination = Pagination()
pagination.count = count
all_monetary_account_bank = endpoint.MonetaryAccountBank.list(
Pagination.url_params_count_only
).value

print(pagination)`

I'm only guessing PRODUCTION and SANDBOX are the types I can input because I can't find it anywhere. But this returns a str error. Could someone help me set up a simple example so I can work from there?

    Desterradum changed the title to A simple Python-SDK example..

      @Desterradum-Lime-Lynx#233520 You would need to use ApiEnvironmentType.SANDBOX in the Python SDK. (More info) Then you can call ensure_session_active() on your ApiContext to make sure the session is still valid. You can also see this in the example that is linked in the main Readme file. If you scroll a bit through that file there are little examples of many different API calls like returning all monetary accounts for a user.

      Hope that helps already, if you get stuck somewhere just complain here and I (or some other kind user) will give you a bit more fleshed out example to work with :)

        @Jakob-Y#233524 Hey thanks, I did read all those and more. I found some reference to the new import conventions on Github somewhere and I also downloaded the entire Tinker lib to see if I could make that work but I'm running into a lot of errors.

        My original test.py code now looks like this: https://bin.veracry.pt/?bbb7339a840f901e#9ooc1rNp9dpnzoApMHk3dDmewqs1ZRJ4SJ4f366YtwSV

        But it returns some errors that I don't really understand too well: https://bin.veracry.pt/?c6db676bf8b37c96#A4nGckg5jNi1YRPLPFqmuYqwsQexJ7S8jkpaaArzKCPD

        Not quite sure how to continue here.

        I don't like complaining much but the Bunq API has a steeper learning curve than I thought when I heard API :D

          @Desterradum-Lime-Lynx#233531 Hi Desterradum. By the way the three-backtick multiline code blocks don't work too well here on Together. At least it makes it impossible to reply/edit anything in a thread when using a desktop browser. I replaced your code blocks, hope that's fine!

          I also tested this little example: https://bin.veracry.pt/?9490636ab96eef2d#CtDni61sGkkWvwnRqTaqC2CKjRmy73QSZuwwAU7NNPLC Works fine for me. I modified the code from one of Bastian's examples.

          Also I noticed the link to the examples file in the Readme of the SDK repository is actually pointing to an older revision. Better to look at the most recent version: https://github.com/bunq/tinker_python/blob/develop/tinker/libs/bunq_lib.py You'll notice there are a few changes.

            19 days later

            @Jakob-Y#233532 Great thanks! This works for me. HNY.

            I can see that simplifying is not in the cards but I tried adding a simple function to read the payments and list them but I'm getting an encoded object back which doesn't appear to be JSON so it's hard to tell from just the object what type of descriptors it has. Trying to find out more by searching for "payments" or "endpoint.payment" in the SDK code yielded little elucidating info haha.

            https://bin.veracry.pt/?6a41ea5441b40fcd#5hHfUQFoQU4UKYPYnT9ArSaoeJLiBGm2v4c6v3kATDgy

            How or where can I find a list of all possible attributes?

            I'm trying to get somewhere, where I can eventually navigate my own accounts and payments but without the ability to return a block of JSON like in normal API situations it's pretty hard to find my way around. I'm also not too clear on the list API call and don't understand why it only returned one single invoice description.

              24 days later
              7 months later

              Hi there,
              I'm looking for other people trying to code something with the API in Python but the bin.veracry links are not working or have expired making this thread uninformative IMO for anyone beyond the people that were involved in this thread.

                Write a Reply...