If you describe your use case we might be able to provide more detailed suggestions.
If you are trying to crawl discussion on a forum you don't control, the best solution is to go through the /api/discussions
paginated results. By default it's 20 discussions but you can ask more with ?filter[limit]=50
. Unless the forum admin did some advanced modifications to Flarum the maximum will be 50 discussions. Then follow the next page URL in the response for the next, etc.
If you control the forum, you might want to use the PHP extension API to perform your work directly or expose a better API endpoint.
If your use case is read only, maybe you could also directly query the database with SQL.