BookStackApp / BookStack

A platform to create documentation/wiki content built with PHP & Laravel
https://www.bookstackapp.com/
MIT License
15.02k stars 1.88k forks source link

API: Attempting to retrieve more than 500 pages #5094

Closed ShajeeAmjad closed 2 months ago

ShajeeAmjad commented 3 months ago

Attempted Debugging

Searched GitHub Issues

Describe the Scenario

I'm using the API to get a list of all pages from my bookstack site. It currently has over 650 pages, but the limit from the listing endpoints (from what I saw on the API docs) is 500. I wanted to know if there is any way I can set a custom limit to whatever I want

Exact BookStack Version

Bookstack latest version

Log Content

No response

Hosting Environment

PHP8.1, Ubuntu 22.04

ssddanbrown commented 3 months ago

Hi @ShajeeAmjad, Technically there is a API_MAX_ITEM_COUNT option, but I don't recommend increasing this as a solution to your scenario. It would be better to handle paging in your application, to properly cycle through pages of API data so that you're keeping to reasonable sizes of data handling, and to be flexible in regards to counts.

If you need an example, here's a PHP function that gets all books via paging over the API:

https://github.com/BookStackApp/api-scripts/blob/8e94a530b0dfb5caebab8b410a893f960f79e089/php-export-all-books/export-books.php#L47-L64

ssddanbrown commented 2 months ago

Since an answer was provided I'll go ahead and close this off.