Skip to content

Pagination

Silent edited this page May 17, 2025 · 1 revision

Pagination is done via the request builders. Available methods will allow for #limit, #count, #offset.

Example

Here is an example of paginating through projects.

HangarClient client = HangarClient.builder().auth(new JWTAuthProvider("<TOKEN>")).build();

ProjectsResponse initialResponse = client.retrieveProjects().execute().join();
int count = initialResponse.getCount();
int limit = initialResponse.getLimit();
int pages = (int) Math.ceil((double) count / limit);

for (int i = 0; i < pages; i++) {
    int offset = i * limit;
    ProjectsResponse response = client.retrieveProjects().offset(offset).execute().join();
    List<Project> projects = response.getProjects();

    for (Project project : projects) {
        System.out.println("project: " + project.getName());
    }
}

Clone this wiki locally