Pagination
Paginate your data batches.
Many API calls are paginated. You can provide page and per_page params to the API. In the example below we are getting all inputs and specifying to start at page 2 and get back 20 results per page.
Java
NodeJS
Python
cURL
1
import com.clarifai.grpc.api.*;
2
import com.clarifai.grpc.api.status.*;
3
4
// Insert here the initialization code as outlined on this page:
5
// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
6
7
MultiInputResponse listInputsResponse = stub.listInputs(
8
ListInputsRequest.newBuilder()
9
.setPage(2)
10
.setPerPage(20)
11
.build()
12
);
13
14
if (listInputsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
15
throw new RuntimeException("List inputs failed, status: " + listInputsResponse.getStatus());
16
}
17
18
for (Input input : listInputsResponse.getInputsList()) {
19
System.out.println(input);
20
}
Copied!
1
// Insert here the initialization code as outlined on this page:
2
// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
3
4
stub.ListInputs(
5
{page: 2, per_page: 20},
6
metadata,
7
(err, response) => {
8
if (err) {
9
throw new Error(err);
10
}
11
12
if (response.status.code !== 10000) {
13
throw new Error("List inputs failed, status: " + response.status.description);
14
}
15
16
for (const input of response.inputs) {
17
console.log(JSON.stringify(input, null, 2));
18
}
19
}
20
);
Copied!
1
# Insert here the initialization code as outlined on this page:
2
# https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions
3
4
list_inputs_response = stub.ListInputs(
5
service_pb2.ListInputsRequest(page=2, per_page=20),
6
metadata=metadata
7
)
8
9
if list_inputs_response.status.code != status_code_pb2.SUCCESS:
10
raise Exception("List inputs failed, status: " + list_inputs_response.status.description)
11
12
for input_object in list_inputs_response.inputs:
13
print(input_object)
Copied!
1
curl -X GET \
2
-H "Authorization: Key YOUR_API_KEY" \
3
https://api.clarifai.com/v2/inputs?page=2&per_page=20
Copied!
Last modified 1mo ago
Copy link
Edit on GitHub