How to pull a large report

I’d like to pull a standard report ( https://vdl.farmos.net/logs/transplanting?page=0 ), only going back a few years to include 1799 transplants : looks like some 36 pages, at the standard load rate of 50 records per screen, which mean more clicks (next page, “select all”) than i wanna do right now.

I expect there must be a simple modification of the arg in that URL above; i tried a few obvious args after the ‘?’ (0-36, 0:36, all), but no joy.

Can someone give me the magic incantation for this one?

/walt

If you open the “Filters” box, the very last option is “Items per page”. It allows up to 500 items. There isn’t an “All” option.

The main limitation is that this page is built on-the-fly by the web server, so it has a maximum amount of memory it is allowed to use. Depending on the data being retrieved, allowing “All” could lead to an OOM (out of memory) error.

For 1799 transplants, you can get it down to 4 pages, which is better than 36.

The best solution might be an API script that loads logs across multiple pages (API requests are hard-limited to 50 per page) and then assemble a final “report” for you (in whatever format you need).

1 Like

Got it (the hard way), thanks Mike… But yeah: an API script that can pull the mutli-page report sounds like the better way. Can you tell me how to do that?

NB: it has been a long time since i did anything w/ the API (version 2.x, IIRC, accessed via Postman) so i guess the schema will be changed since then… And i don’t any longer use Postman, so… Any API access points, tips for using them, would be most appreciated!

1 Like

The API hasn’t changed a whole lot since version 2 - just some minor data model changes, but the basic JSON:API structure is all the same.

What are you comfortable developing in? Python is a good option and we have a library for it: GitHub - farmOS/farmOS.py: A Python library for interacting with farmOS over API. · GitHub

API documentation is here: API | farmOS

And farmOS.py documentation is here: Introduction | farmOS

Also check out @Symbioquine’s blog post! Introduction to Python Scripting with farmOS | farmOS

Hope that helps!

1 Like

Thanks Mike: that was just the pointer i needed. We (i.e. Claude Code & i -the “Royal We” :slight_smile: set up a separate read-only user (Farm Viewer) for the script, and with farmOS.py paging through 50 at a time it pulls all 1,799 of our transplanting logs, with their quantities, in about a minute. Checked it against the CSV export i’d stitched together by hand, and it matches.

i also asked it for only the fields the report uses, so it’s a light touch on your server: 36 requests for the lot. Presuming that to be OK (?), i may do a bit more scripting to pull some more such reports; if you have any guidance to issue about such useage, please do advise.

2 Likes

That’s great @walt! Glad to hear you got what you needed, and hopefully you ended up with something reusable (and some new skills) for future reports!

Don’t worry about API usage - that’s what it’s there for! If it ever becomes too much for my servers I’ll figure out some kind of rate limiting, but I’m not worried about it.

If you end up with something that might be generally useful, or just want to share your experience for the benefit of others, feel free to write up a post for the community blog! GitHub - farmOS/farmOS-community-blog: Community blog posts hosted on the farmOS.org website · GitHub

2 Likes