Support pagination of API requests. Improve error handling.