https://developers.google.com/admin-sdk/directory/v1/limits
The API returns:
Chrome and mobile devices – A default and a maximum of 100 entries per page.
Groups and group members – A default and maximum of 200 entries per page.
Users – A default of 100 entries and a maximum of 500 entries per page.
The user alias and organization unit resources do not use response pagination. All user primary emails are returned in alphabetical order and the response order is case insensitive.
According to the limit here, you can get maxResults query string for 100 users by default and 500 as the absolute maximum. I believe anything above 500, you will get an error. The best way to do it is to retrieve 500 entries at a time. If you detect a pageToken in the response, keep retrieving the entries by using the token until you finished retrieving all users.
There is no way to just get all 5000 users at once if that's what you are looking for...