Oh, I misread your post. I thought you were looking for a way to return ALL posts from a topic at once.
Here’s a script example using the API pagination (not exactly the same query, as it returns posts from a user and each page contains 50 posts, not 20):