Clarifai Guide
Clarifai Home
v7.0
v7.0
  • Welcome
  • Getting Started
    • Quick Start
    • Applications
      • Create an Application
      • Application Settings
      • Collaboration
    • Authentication
      • App-Specific API Keys
      • Personal Access Tokens
      • Scopes
      • Authorize
      • 2FA
    • Glossary
  • How-To
    • Portal
      • Auto Annotation
      • Custom Models
      • Text Classification
      • Visual Text Recognition
    • API
      • Auto Annotation
      • Batch Predict CSV on Custom Text Model
      • Custom KNN Face Classifier Workflow
      • Custom Models
      • Custom Text Model
      • Visual Text Recognition
  • API Guide
    • API overview
      • API Clients
      • Using Postman with Clarifai APIs
      • Status Codes
      • Pagination
      • Patching
    • Data Mode
      • Supported Formats
      • Create, Get, Update, Delete
      • Collectors
    • Concepts
      • Create, Get, Update
      • Languages
      • Search by Concept
      • Knowledge Graph
    • Scribe Label
      • Annotations
      • Training Data
      • Positive and Negative Annotations
      • Tasks
      • Task Annotations
    • Enlight Train
      • Clarifai Models
      • Model Types
      • Create, Get, Update, Delete
      • Deep Training
      • Evaluate
        • Interpreting Evaluations
        • Improving Your Model
    • Mesh Workflows
      • Base Workflows
      • Create, Get, Update, Delete
      • Input Nodes
      • Workflow Predict
    • Armada Predict
      • Images
      • Video
      • Prediction Parameters
      • Multilingual Classification
    • Spacetime Search
      • Search Overview
      • Combine or Negate
      • Filter
      • Rank
      • Index Images for Search
      • Legacy Search
        • Combine or Negate
        • Filter
        • Rank
        • Saved Searches
  • Portal Guide
    • Portal Overview
    • Data Mode
      • Supported Formats
      • Bulk Labeling
      • CSV and TSV
      • Collectors
    • Concepts
      • Create, Get, Update, Delete
      • Knowledge Graph
      • Languages
    • Scribe Label
      • Create a Task
      • Label Types
      • Labeling Tools
      • AI Assist
      • Workforce Management
      • Review
      • Training Data
      • Positive and Negative Annotations
    • Enlight Train
      • Training Basics
      • Clarifai Models
      • Model Types
      • Deep Training
      • Evaluate
        • Interpreting Evaluations
        • Improving Your Model
    • Mesh Workflows
      • Base Workflows
      • Setting Up a Mesh Workflow
      • Input Nodes
    • Armada Predict
    • Spacetime Search
      • Rank
      • Filter
      • Combine or Negate
      • Saved Searches
      • Visual Search
  • Data Labeling Services
    • Scribe LabelForce
  • Product Updates
    • Upcoming API Changes
    • Changelog
      • Release 7.0
      • Release 6.11
      • Release 6.10
      • Release 6.9
      • Release 6.8
      • Release 6.7
      • Release 6.6
      • Release 6.5
      • Release 6.4
      • Release 6.3
      • Release 6.2
      • Release 6.1
      • Release 6.0
      • Release 5.11
      • Release 5.10
Powered by GitBook
On this page

Was this helpful?

  1. API Guide
  2. API overview

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.

import com.clarifai.grpc.api.*;
import com.clarifai.grpc.api.status.*;

// Insert here the initialization code as outlined on this page:
// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions

MultiInputResponse listInputsResponse = stub.listInputs(
    ListInputsRequest.newBuilder()
        .setPage(2)
        .setPerPage(20)
        .build()
);

if (listInputsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
    throw new RuntimeException("List inputs failed, status: " + listInputsResponse.getStatus());
}

for (Input input : listInputsResponse.getInputsList()) {
    System.out.println(input);
}
// Insert here the initialization code as outlined on this page:
// https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions

stub.ListInputs(
    {page: 2, per_page: 20},
    metadata,
    (err, response) => {
        if (err) {
            throw new Error(err);
        }

        if (response.status.code !== 10000) {
            throw new Error("List inputs failed, status: " + response.status.description);
        }

        for (const input of response.inputs) {
            console.log(JSON.stringify(input, null, 2));
        }
    }
);
# Insert here the initialization code as outlined on this page:
# https://docs.clarifai.com/api-guide/api-overview/api-clients#client-installation-instructions

list_inputs_response = stub.ListInputs(
    service_pb2.ListInputsRequest(page=2, per_page=20),
    metadata=metadata
)

if list_inputs_response.status.code != status_code_pb2.SUCCESS:
    raise Exception("List inputs failed, status: " + list_inputs_response.status.description)

for input_object in list_inputs_response.inputs:
    print(input_object)
app.inputs.list({page: 2, perPage: 20});
from clarifai.rest import ClarifaiApp
app = ClarifaiApp(api_key='YOUR_API_KEY')

app.inputs.get_by_page(page=2, per_page=20)
client.getInputs()
    .perPage(20) // OPTIONAL, to specify how many results should be on one page
    .getPage(2)
    .executeSync();
using System.Threading.Tasks;
using Clarifai.API;

namespace YourNamespace
{
    public class YourClassName
    {
        public static async Task Main()
        {
            var client = new ClarifaiClient("YOUR_API_KEY");

            await client.GetInputs()
                .PerPage(20) // OPTIONAL, to specify how many results should be on one page
                .Page(2)
                .ExecuteAsync();
        }
    }
}
[app getInputsOnPage:2 pageSize:20 completion:^(NSArray<ClarifaiInput *> *inputs, NSError *error) {
    NSLog(@"inputs: %@", inputs);
}];
use Clarifai\API\ClarifaiClient;
use Clarifai\DTOs\Inputs\ClarifaiInput;

$client = new ClarifaiClient('YOUR_API_KEY');

$response = $client->getInputs()
    ->withPerPage(20)  // OPTIONAL, to specify how many results should be on one page
    ->withPage(2)
    ->executeSync();

if ($response->isSuccessful()) {
    echo "Response is successful.\n";

    /** @var ClarifaiInput[] $inputs */
    $inputs = $response->get();
    foreach ($inputs as $input) {
        echo $input->id() . "\n";
    }
} else {
    echo "Response is not successful. Reason: \n";
    echo $response->status()->description() . "\n";
    echo $response->status()->errorDetails() . "\n";
    echo "Status code: " . $response->status()->statusCode();
}
curl -X GET \
  -H "Authorization: Key YOUR_API_KEY" \
  https://api.clarifai.com/v2/inputs?page=2&per_page=20
PreviousStatus CodesNextPatching

Last updated 4 years ago

Was this helpful?