radiobrowser-api-rust icon indicating copy to clipboard operation
radiobrowser-api-rust copied to clipboard

When searching with offset, report total results count

Open onny opened this issue 4 years ago • 4 comments

Hey, in case I limit my search query like this: https://de1.api.radio-browser.info/json/stations/byname/npr?limit=10 How do I know the total results count without querying all stations?

Best regards, Jonas

onny avatar Nov 12 '20 09:11 onny

It would be nice to know. Most queries you can just load all the results, or just initially load with limit and then all the rest. Couple thousand stations is only 250kb.

erkkki avatar Jan 22 '21 12:01 erkkki

Here's an cool example of an API used in the Fyyd podcast database: https://api.fyyd.de/0.2/search/podcast?title=logbuch This query is searching for podcasts with the title "logbuch" and also shows some meta info about the query. Docu is here: https://github.com/eazyliving/fyyd-api

onny avatar Jan 22 '21 20:01 onny

Looks like only way to get count is to do another sql query whiteout limit. stackoverflow

erkkki avatar Jan 23 '21 11:01 erkkki

i am unsure how to handle this, i totally understand the need but i also do not want to double the load on the database ... :(

segler-alex avatar Apr 22 '21 16:04 segler-alex

As an alternative, would it be possible to also expose a COUNT endpoint? In theory, this could still be a doubling of load, but well-behaved clients can store the total count.

kgarner7 avatar Jan 22 '23 04:01 kgarner7