hledger Web API /accounttransactions filtering options?

5 views
Skip to first unread message

André Fincato

unread,
Jul 7, 2025, 4:05:42 PMJul 7
to hle...@googlegroups.com
hi Simon and everybody!

i was dabbing at the hledger's web APIs by checking what hledger web does / allow and while i could successfully load all the endpoints described in the docs (<https://hledger.org/dev/hledger-web.html?highlight=api#json-api>), when testing in particular the `/accounttransactions` endpoint, i did not figure out how to pass extra query params — for instance a date range. is this possible?

in the hledger web app you can filter by date using the search query form:

inacct:Expenses:Personal:Bike date:2022

which produces this GET HTTP request:

http://127.0.0.1:5000/register?q=inacct:Expenses:Personal:Bike date:2022

i imagine this is talking to the same hledger web API interface we get access to, right?

i browsed through the hledger web app codebase and thought maybe in this file there should be a hint how this is done, but can't read Haskell code much and it seems there's no hint of what i am looking for?

<https://github.com/simonmichael/hledger/blob/master/hledger-web/Hledger/Web/Handler/RegisterR.hs>

thanks for any hint!

André


Simon Michael

unread,
Jul 8, 2025, 8:14:20 PMJul 8
to hle...@googlegroups.com
Hi André,

> is this possible?

Certainly, by passing extra query terms in the q request parameter.

> in the hledger web app you can filter by date using the search query form:
>
> inacct:Expenses:Personal:Bike date:2022
>
> which produces this GET HTTP request:
>
> http://127.0.0.1:5000/register?q=inacct:Expenses:Personal:Bike date:2022

Normally I'd see a + before date there, not a space. But maybe it's equivalent.
Here's a working example (in this one the : is %3A, but it's equivalent):

https://demo.hledger.org/register?q=inacct%3AAssets%3AUS%3ABofA%3AChecking+date%3A2013

Try + instead of space in your url ?

> i imagine this is talking to the same hledger web API interface we get
> access to, right?

Yup

> i browsed through the hledger web app codebase and thought maybe in
> this file there should be a hint how this is done, but can't read
> Haskell code much and it seems there's no hint of what i am looking for?
>
> <https://github.com/simonmichael/hledger/blob/master/hledger-web/Hledger/Web/Handler/RegisterR.hs>

The "gui" apps (hledger-web and hledger-ui both) are notably fragmented. I think it's the nature of GUIs and/or haskell - you have to jump around a lot to follow the flow, which can be challenging. I believe that q parameter is handled in the getViewData helper in App.hs.
Reply all
Reply to author
Forward
0 new messages