The concept is called "pagination". For most people that has to do with database queries, but with your API calls it's still very similar in execution.
You need to get the desired page number from the form; if you want Prev and Next buttons then you could include the page number in the form and know which button means -1 or +1, but easier would be to make the buttons have the actual page number as their values.
Processing the form to get the page number has to happen before you use the API, of course. Your $page > 1 and $page < $result->pages checks are good for deciding whether to show the Prev and Next buttons, but since you need the page number before you use the API, you can't use the results of that API call to decide what to do.
My suggestion is:
1. Get the $page from the form data (if it is >=1) or use 1 if there wasn't a valid number given
2. Call the API with the page number
3. Show the results like normal
4. In the form, if $page > 1 then show the Prev button, and if $page < number of pages then show the Next button
5. For the two buttons, give them a name of "page" and a value of $page - 1/$page + 1 appropriately: when someone clicks either button then that will submit a "page" in the form data for your code to use