• Developers
  • Retrieve all payments by date

Hi all, I'm currently using the payments API to retrieve all payments. I want to do this every day, but I don't see an option with the python Bunq SDK to use pagination. As it only returns the list of payments and not the pagination object.

What parameter should I use to just retrieve payments from today? I tried "start_date": "2022-11-28 00:00:00.000000", but that didn't work.

    @New-Navy-Butterfly-2076733687#272275 Haven't used the Python SDK myself, as I have written my own implementation, but I would think you first do: from bunq import Pagination and then you get get a new Pagination instance, let's say pagination = Pagination(), then set pagination.count, pagination.newer_id and/or pagination.older_id to some fitting values and then you can pass it like Payment.list(params=pagination.url_params_count_only) or Payment.list(params=pagination.url_params_next_page) depending on what you want to do.

    Basically take a look at https://github.com/bunq/sdk_python/blob/develop/bunq/sdk/http/pagination.py

      Hi Jakob, thanks for helping out. I understand the pagination part, except the Bunq SDK doesn't return the pagination object when you call it. It will only return the payments returned from the API, in the screenshot I pasted the source code of the bunq SDK which returns the payments. In the .value are the actual payments, while in .pagination is the pagination object. So there's no way to know the newer_id, when retrieving payments with the Bunq SDK.

      Do you perhaps know what the value of newer_id actually is? Is it the payment_id, if that's the case I could just get the last known payment in my database and pass that as newer_id and then I'm able to set pagination.count to a big number as it will only retrieve the newest payments.

        I resorted to retrieving the latest payment in my database ordered by date and time. With that payment I set "newer_id": latest_payment.id_, it looks like that does actually work like it's supposed to, it returns 0 payments, which is to be expected as I know there are no new payments since that last payment.

          @New-Navy-Butterfly-2076733687#272319 Feel free to open a GitHub issue for the Python SDK, this seems like an oversight to me. It should be possible to work around this by implementing a bit more logic on your own, though. If we go by what https://beta.doc.bunq.com/basics/pagination says, then you can also use the payment IDs of the current output's first/last payment and use them for older_id/newer_id.

          In your database, it should be fine to order the payments by their ID, IIRC they're incrementing.

            Write a Reply...