List Annotations
You can get a list of annotations within your app with a GET call. Annotations will be returned from oldest to newest.
These requests are paginated. By default each page will return 20 annotations.
List All User Created Annotations in Your App
Below is an example of how to list all your user labelled annotations.
This will not show annotations by models in your workflow. To include model created annotations, you need to set list_all_annotations
to True
.
- Python (gRPC)
- JavaScript (REST)
- Node.js (gRPC)
- Java (gRPC)
- PHP (gRPC)
- cURL
##################################################################
# In this section, we set the user authentication and app ID.
# Change these strings to run your own example.
##################################################################
USER_ID = 'YOUR_USER_ID_HERE'
# Your PAT (Personal Access Token) can be found in the Account's Security section
PAT = 'YOUR_PAT_HERE'
APP_ID = 'YOUR_APP_ID_HERE'
##########################################################################
# YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
##########################################################################
from clarifai_grpc.channel.clarifai_channel import ClarifaiChannel
from clarifai_grpc.grpc.api import resources_pb2, service_pb2, service_pb2_grpc
from clarifai_grpc.grpc.api.status import status_code_pb2
channel = ClarifaiChannel.get_grpc_channel()
stub = service_pb2_grpc.V2Stub(channel)
metadata = (('authorization', 'Key ' + PAT),)
userDataObject = resources_pb2.UserAppIDSet(user_id=USER_ID, app_id=APP_ID)
list_annotations_response = stub.ListAnnotations(
service_pb2.ListAnnotationsRequest(
user_app_id=userDataObject, # The userDataObject is created in the overview and is required when using a PAT
per_page=10
),
metadata=metadata
)
if list_annotations_response.status.code != status_code_pb2.SUCCESS:
print(list_annotations_response.status)
raise Exception("List annotations failed, status: " + list_annotations_response.status.description)
for annotation_object in list_annotations_response.annotations:
print(annotation_object)
<!--index.html file-->
<script>
/////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication and app ID.
// Change these strings to run your own example.
/////////////////////////////////////////////////////////////////////
const USER_ID = 'YOUR_USER_ID_HERE';
// Your PAT (Personal Access Token) can be found in the Account's Security section
const PAT = 'YOUR_PAT_HERE';
const APP_ID = 'YOUR_APP_ID_HERE';
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
const requestOptions = {
method: 'GET',
headers: {
'Accept': 'application/json',
'Authorization': 'Key ' + PAT
}
};
fetch(`https://api.clarifai.com/v2/users/${USER_ID}/apps/${APP_ID}/annotations?page=1&per_page=10`, requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
</script>
//index.js file
/////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication and app ID.
// Change these strings to run your own example.
/////////////////////////////////////////////////////////////////////
const USER_ID = 'YOUR_USER_ID_HERE';
// Your PAT (Personal Access Token) can be found in the Account's Security section
const PAT = 'YOUR_PAT_HERE';
const APP_ID = 'YOUR_APP_ID_HERE';
/////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
/////////////////////////////////////////////////////////////////////////////
const { ClarifaiStub, grpc } = require("clarifai-nodejs-grpc");
const stub = ClarifaiStub.grpc();
// This will be used by every Clarifai endpoint call
const metadata = new grpc.Metadata();
metadata.set("authorization", "Key " + PAT);
stub.ListAnnotations(
{
user_app_id: {
"user_id": USER_ID,
"app_id": APP_ID
},
page: 1,
per_page: 10
},
metadata,
(err, response) => {
if (err) {
throw new Error(err);
}
if (response.status.code !== 10000) {
throw new Error("List annotations failed, status: " + response.status.description);
}
for (const annotation of response.annotations) {
console.log(JSON.stringify(annotation, null, 2));
}
}
);
package com.clarifai.example;
import com.clarifai.grpc.api.*;
import com.clarifai.channel.ClarifaiChannel;
import com.clarifai.credentials.ClarifaiCallCredentials;
import com.clarifai.grpc.api.status.StatusCode;
public class ClarifaiExample {
///////////////////////////////////////////////////////////////////
// In this section, we set the user authentication and app ID.
// Change these strings to run your own example.
///////////////////////////////////////////////////////////////////
static final String USER_ID = "YOUR_USER_ID_HERE";
//Your PAT (Personal Access Token) can be found in the portal under Authentication
static final String PAT = "YOUR_PAT_HERE";
static final String APP_ID = "YOUR_APP_ID_HERE";
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
public static void main(String[] args) {
V2Grpc.V2BlockingStub stub = V2Grpc.newBlockingStub(ClarifaiChannel.INSTANCE.getGrpcChannel())
.withCallCredentials(new ClarifaiCallCredentials(PAT));
MultiAnnotationResponse listAnnotationsResponse = stub.listAnnotations(
ListAnnotationsRequest.newBuilder()
.setUserAppId(UserAppIDSet.newBuilder().setUserId(USER_ID).setAppId(APP_ID))
.setPerPage(10)
.setPage(1) // Pages start at 1
.build()
);
if (listAnnotationsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
throw new RuntimeException("List annotations failed, status: " + listAnnotationsResponse.getStatus());
}
for (Annotation annotation: listAnnotationsResponse.getAnnotationsList()) {
System.out.println(annotation);
}
}
}
<?php
require __DIR__ . "/vendor/autoload.php";
/////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication and app ID.
// Change these strings to run your own example.
/////////////////////////////////////////////////////////////////////
$USER_ID = "YOUR_USER_ID_HERE";
// Your PAT (Personal Access Token) can be found in the Account's Security section
$PAT = "YOUR_PAT_HERE";
$APP_ID = "YOUR_APP_ID_HERE";
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
use Clarifai\ClarifaiClient;
use Clarifai\Api\ListAnnotationsRequest;
use Clarifai\Api\Status\StatusCode;
use Clarifai\Api\UserAppIDSet;
$client = ClarifaiClient::grpc();
$metadata = ["Authorization" => ["Key " . $PAT]];
$userDataObject = new UserAppIDSet([
"user_id" => $USER_ID,
"app_id" => $APP_ID
]);
// Let's make a RPC call to the Clarifai platform. It uses the opened gRPC client channel to communicate a
// request and then wait for the response
[$response, $status] = $client->ListAnnotations(
// The request object carries the request along with the request status and other metadata related to the request itself
new ListAnnotationsRequest([
"user_app_id" => $userDataObject,
"per_page" => 10
]),
$metadata
)->wait();
// A response is returned and the first thing we do is check the status of it
// A successful response will have a status code of 0; otherwise, there is some error
if ($status->code !== 0) {
throw new Exception("Error: {$status->details}");
}
// In addition to the RPC response status, there is a Clarifai API status that reports if the operation was a success or failure
// (not just that the communication was successful)
if ($response->getStatus()->getCode() != StatusCode::SUCCESS) {
print $response->getStatus()->getDetails();
throw new Exception("Failure response: " . $response->getStatus()->getDescription());
}
foreach ($response->getAnnotations() as $annotation_object) {
echo $annotation_object->SerializeToJSONString() . "</br>";
}
?>
curl -X GET "https://api.clarifai.com/v2/users/YOUR_USER_ID_HERE/apps/YOUR_APP_ID_HERE/annotations?page=1&per_page=10" \
-H "Authorization: Key YOUR_PAT_HERE"
List All Annotations in Your App
Below is an example of how to list all annotations, including those created by models.
- Python (gRPC)
- JavaScript (REST)
- Node.js (gRPC)
- Java (gRPC)
- PHP (gRPC)
- cURL
##################################################################
# In this section, we set the user authentication and app ID.
# Change these strings to run your own example.
##################################################################
USER_ID = 'YOUR_USER_ID_HERE'
# Your PAT (Personal Access Token) can be found in the Account's Security section
PAT = 'YOUR_PAT_HERE'
APP_ID = 'YOUR_APP_ID_HERE'
##########################################################################
# YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
##########################################################################
from clarifai_grpc.channel.clarifai_channel import ClarifaiChannel
from clarifai_grpc.grpc.api import resources_pb2, service_pb2, service_pb2_grpc
from clarifai_grpc.grpc.api.status import status_code_pb2
channel = ClarifaiChannel.get_grpc_channel()
stub = service_pb2_grpc.V2Stub(channel)
metadata = (('authorization', 'Key ' + PAT),)
userDataObject = resources_pb2.UserAppIDSet(user_id=USER_ID, app_id=APP_ID)
list_annotations_response = stub.ListAnnotations(
service_pb2.ListAnnotationsRequest(
user_app_id=userDataObject, # The userDataObject is created in the overview and is required when using a PAT
per_page=10,
list_all_annotations=True
),
metadata=metadata
)
if list_annotations_response.status.code != status_code_pb2.SUCCESS:
print(list_annotations_response.status)
raise Exception("List annotations failed, status: " + list_annotations_response.status.description)
for annotation_object in list_annotations_response.annotations:
print(annotation_object)
<!--index.html file-->
<script>
/////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication and app ID.
// Change these strings to run your own example.
/////////////////////////////////////////////////////////////////////
const USER_ID = 'YOUR_USER_ID_HERE';
// Your PAT (Personal Access Token) can be found in the Account's Security section
const PAT = 'YOUR_PAT_HERE';
const APP_ID = 'YOUR_APP_ID_HERE';
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
const requestOptions = {
method: 'GET',
headers: {
'Accept': 'application/json',
'Authorization': 'Key ' + PAT
}
};
fetch(`https://api.clarifai.com/v2/users/${USER_ID}/apps/${APP_ID}/annotations?page=1&per_page=10&list_all_annotations=true`, requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
</script>
//index.js file
/////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication and app ID.
// Change these strings to run your own example.
/////////////////////////////////////////////////////////////////////
const USER_ID = 'YOUR_USER_ID_HERE';
// Your PAT (Personal Access Token) can be found in the Account's Security section
const PAT = 'YOUR_PAT_HERE';
const APP_ID = 'YOUR_APP_ID_HERE';
/////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
/////////////////////////////////////////////////////////////////////////////
const { ClarifaiStub, grpc } = require("clarifai-nodejs-grpc");
const stub = ClarifaiStub.grpc();
// This will be used by every Clarifai endpoint call
const metadata = new grpc.Metadata();
metadata.set("authorization", "Key " + PAT);
stub.ListAnnotations(
{
user_app_id: {
"user_id": USER_ID,
"app_id": APP_ID
},
list_all_annotations: true,
page: 1,
per_page: 10
},
metadata,
(err, response) => {
if (err) {
throw new Error(err);
}
if (response.status.code !== 10000) {
throw new Error("List annotations failed, status: " + response.status.description);
}
for (const annotation of response.annotations) {
console.log(JSON.stringify(annotation, null, 2));
}
}
);
package com.clarifai.example;
import com.clarifai.grpc.api.*;
import com.clarifai.channel.ClarifaiChannel;
import com.clarifai.credentials.ClarifaiCallCredentials;
import com.clarifai.grpc.api.status.*;
public class ClarifaiExample {
///////////////////////////////////////////////////////////////////
// In this section, we set the user authentication and app ID.
// Change these strings to run your own example.
///////////////////////////////////////////////////////////////////
static final String USER_ID = "YOUR_USER_ID_HERE";
//Your PAT (Personal Access Token) can be found in the portal under Authentication
static final String PAT = "YOUR_PAT_HERE";
static final String APP_ID = "YOUR_APP_ID_HERE";
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
public static void main(String[] args) {
V2Grpc.V2BlockingStub stub = V2Grpc.newBlockingStub(ClarifaiChannel.INSTANCE.getGrpcChannel())
.withCallCredentials(new ClarifaiCallCredentials(PAT));
MultiAnnotationResponse listAnnotationsResponse = stub.listAnnotations(
ListAnnotationsRequest.newBuilder()
.setUserAppId(UserAppIDSet.newBuilder().setUserId(USER_ID).setAppId(APP_ID))
.setPerPage(10)
.setListAllAnnotations(true)
.setPage(1) // Pages start at 1
.build()
);
if (listAnnotationsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
throw new RuntimeException("List annotations failed, status: " + listAnnotationsResponse.getStatus());
}
for (Annotation annotation: listAnnotationsResponse.getAnnotationsList()) {
System.out.println(annotation);
}
}
}
<?php
require __DIR__ . "/vendor/autoload.php";
/////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication and app ID.
// Change these strings to run your own example.
/////////////////////////////////////////////////////////////////////
$USER_ID = "YOUR_USER_ID_HERE";
// Your PAT (Personal Access Token) can be found in the Account's Security section
$PAT = "YOUR_PAT_HERE";
$APP_ID = "YOUR_APP_ID_HERE";
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
use Clarifai\ClarifaiClient;
use Clarifai\Api\ListAnnotationsRequest;
use Clarifai\Api\Status\StatusCode;
use Clarifai\Api\UserAppIDSet;
$client = ClarifaiClient::grpc();
$metadata = ["Authorization" => ["Key " . $PAT]];
$userDataObject = new UserAppIDSet([
"user_id" => $USER_ID,
"app_id" => $APP_ID
]);
// Let's make a RPC call to the Clarifai platform. It uses the opened gRPC client channel to communicate a
// request and then wait for the response
[$response, $status] = $client->ListAnnotations(
// The request object carries the request along with the request status and other metadata related to the request itself
new ListAnnotationsRequest([
"user_app_id" => $userDataObject,
"per_page" => 10,
"list_all_annotations" => true
]),
$metadata
)->wait();
// A response is returned and the first thing we do is check the status of it
// A successful response will have a status code of 0; otherwise, there is some error
if ($status->code !== 0) {
throw new Exception("Error: {$status->details}");
}
// In addition to the RPC response status, there is a Clarifai API status that reports if the operation was a success or failure
// (not just that the communication was successful)
if ($response->getStatus()->getCode() != StatusCode::SUCCESS) {
print $response->getStatus()->getDetails();
throw new Exception("Failure response: " . $response->getStatus()->getDescription());
}
foreach ($response->getAnnotations() as $annotation_object) {
echo $annotation_object->SerializeToJSONString() . "</br>";
}
?>
curl -X GET "https://api.clarifai.com/v2/users/YOUR_USER_ID_HERE/apps/YOUR_APP_ID_HERE/annotations?page=1&per_page=10&list_all_annotations=true" \
-H "Authorization: Key YOUR_PAT_HERE"
List User Created Annotations by Input IDs
Below is an example of how to list all user created annotations for certain input (one or several) by providing a list of input IDs.
This will not show annotations by models in your workflow. To include model created annotations, you need to set list_all_annotations
to True
.
- Python (gRPC)
- JavaScript (REST)
- Node.js (gRPC)
- Java (gRPC)
- PHP (gRPC)
- cURL
#########################################################################
# In this section, we set the user authentication, app ID, and input IDs
# Change these strings to run your own example.
#########################################################################
USER_ID = 'YOUR_USER_ID_HERE'
# Your PAT (Personal Access Token) can be found in the Account's Security section
PAT = 'YOUR_PAT_HERE'
APP_ID = 'YOUR_APP_ID_HERE'
# Change these to list your own annotations
INPUT_ID_1 = '53d0362a9dfa4e03b2293375e2d0db73'
INPUT_ID_2 = '00f6d742124147ac8ca7788f73736fb9'
##########################################################################
# YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
##########################################################################
from clarifai_grpc.channel.clarifai_channel import ClarifaiChannel
from clarifai_grpc.grpc.api import resources_pb2, service_pb2, service_pb2_grpc
from clarifai_grpc.grpc.api.status import status_code_pb2
channel = ClarifaiChannel.get_grpc_channel()
stub = service_pb2_grpc.V2Stub(channel)
metadata = (('authorization', 'Key ' + PAT),)
userDataObject = resources_pb2.UserAppIDSet(user_id=USER_ID, app_id=APP_ID)
list_annotations_response = stub.ListAnnotations(
service_pb2.ListAnnotationsRequest(
user_app_id=userDataObject, # The userDataObject is created in the overview and is required when using a PAT
input_ids=[INPUT_ID_1, INPUT_ID_2],
per_page=10
),
metadata=metadata
)
if list_annotations_response.status.code != status_code_pb2.SUCCESS:
print(list_annotations_response.status)
raise Exception("List annotations failed, status: " + list_annotations_response.status.description)
for annotation_object in list_annotations_response.annotations:
print(annotation_object)
<!--index.html file-->
<script>
////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and input IDs.
// Change these strings to run your own example.
////////////////////////////////////////////////////////////////////////////
const USER_ID = 'YOUR_USER_ID_HERE';
// Your PAT (Personal Access Token) can be found in the Account's Security section
const PAT = 'YOUR_PAT_HERE';
const APP_ID = 'YOUR_APP_ID_HERE';
// Change this to list your own annotations
const INPUT_ID = 'c9cbb1c90cf24bc98bfd2e529e744ca9';
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
const requestOptions = {
method: 'GET',
headers: {
'Accept': 'application/json',
'Authorization': 'Key ' + PAT
}
};
fetch(`https://api.clarifai.com/v2/users/${USER_ID}/apps/${APP_ID}/annotations?page=1&per_page=10&input_ids=${INPUT_ID}`, requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
</script>
//index.js file
////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and input IDs.
// Change these strings to run your own example.
////////////////////////////////////////////////////////////////////////////
const USER_ID = 'YOUR_USER_ID_HERE';
// Your PAT (Personal Access Token) can be found in the Account's Security section
const PAT = 'YOUR_PAT_HERE';
const APP_ID = 'YOUR_APP_ID_HERE';
// Change these to list your own annotations
const INPUT_ID_1 = 'c9cbb1c90cf24bc98bfd2e529e744ca9';
const INPUT_ID_2 = 'a8748df4938447e4844b2f505c8eaaef';
/////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
/////////////////////////////////////////////////////////////////////////////
const { ClarifaiStub, grpc } = require("clarifai-nodejs-grpc");
const stub = ClarifaiStub.grpc();
// This will be used by every Clarifai endpoint call
const metadata = new grpc.Metadata();
metadata.set("authorization", "Key " + PAT);
stub.ListAnnotations(
{
user_app_id: {
"user_id": USER_ID,
"app_id": APP_ID
},
input_ids: [INPUT_ID_1, INPUT_ID_2],
page: 1,
per_page: 10
},
metadata,
(err, response) => {
if (err) {
throw new Error(err);
}
if (response.status.code !== 10000) {
throw new Error("List annotations failed, status: " + response.status.description);
}
for (const annotation of response.annotations) {
console.log(JSON.stringify(annotation, null, 2));
}
}
);
package com.clarifai.example;
import com.clarifai.grpc.api.*;
import com.clarifai.channel.ClarifaiChannel;
import com.clarifai.credentials.ClarifaiCallCredentials;
import com.clarifai.grpc.api.status.*;
public class ClarifaiExample {
/////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and input IDs.
// Change these strings to run your own example.
/////////////////////////////////////////////////////////////////////////////
static final String USER_ID = "YOUR_USER_ID_HERE";
//Your PAT (Personal Access Token) can be found in the portal under Authentication
static final String PAT = "YOUR_PAT_HERE";
static final String APP_ID = "YOUR_APP_ID_HERE";
// Change these to list your own annotations
static final String INPUT_ID_1 = "c9cbb1c90cf24bc98bfd2e529e744ca9";
static final String INPUT_ID_2 = "a8748df4938447e4844b2f505c8eaaef";
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
public static void main(String[] args) {
V2Grpc.V2BlockingStub stub = V2Grpc.newBlockingStub(ClarifaiChannel.INSTANCE.getGrpcChannel())
.withCallCredentials(new ClarifaiCallCredentials(PAT));
MultiAnnotationResponse listAnnotationsResponse = stub.listAnnotations(
ListAnnotationsRequest.newBuilder()
.setUserAppId(UserAppIDSet.newBuilder().setUserId(USER_ID).setAppId(APP_ID))
.addInputIds(INPUT_ID_1)
.addInputIds(INPUT_ID_2)
.setPerPage(10)
.setPage(1) // Pages start at 1
.build()
);
if (listAnnotationsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
throw new RuntimeException("List annotations failed, status: " + listAnnotationsResponse.getStatus());
}
for (Annotation annotation: listAnnotationsResponse.getAnnotationsList()) {
System.out.println(annotation);
}
}
}
<?php
require __DIR__ . "/vendor/autoload.php";
////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and input IDs.
// Change these strings to run your own example.
////////////////////////////////////////////////////////////////////////////
$USER_ID = "YOUR_USER_ID_HERE";
// Your PAT (Personal Access Token) can be found in the Account's Security section
$PAT = "YOUR_PAT_HERE";
$APP_ID = "YOUR_APP_ID_HERE";
// Change these to list your own annotations
$INPUT_ID_1 = "c9cbb1c90cf24bc98bfd2e529e744ca9";
$INPUT_ID_2 = "a8748df4938447e4844b2f505c8eaaef";
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
use Clarifai\ClarifaiClient;
use Clarifai\Api\ListAnnotationsRequest;
use Clarifai\Api\Status\StatusCode;
use Clarifai\Api\UserAppIDSet;
$client = ClarifaiClient::grpc();
$metadata = ["Authorization" => ["Key " . $PAT]];
$userDataObject = new UserAppIDSet([
"user_id" => $USER_ID,
"app_id" => $APP_ID
]);
// Let's make a RPC call to the Clarifai platform. It uses the opened gRPC client channel to communicate a
// request and then wait for the response
[$response, $status] = $client->ListAnnotations(
// The request object carries the request along with the request status and other metadata related to the request itself
new ListAnnotationsRequest([
"user_app_id" => $userDataObject,
"input_ids" => [$INPUT_ID_1, $INPUT_ID_2],
"per_page" => 10
]),
$metadata
)->wait();
// A response is returned and the first thing we do is check the status of it
// A successful response will have a status code of 0; otherwise, there is some error
if ($status->code !== 0) {
throw new Exception("Error: {$status->details}");
}
// In addition to the RPC response status, there is a Clarifai API status that reports if the operation was a success or failure
// (not just that the communication was successful)
if ($response->getStatus()->getCode() != StatusCode::SUCCESS) {
print $response->getStatus()->getDetails();
throw new Exception("Failure response: " . $response->getStatus()->getDescription());
}
foreach ($response->getAnnotations() as $annotation_object) {
echo $annotation_object->SerializeToJSONString() . "</br>";
}
?>
curl -X GET "https://api.clarifai.com/v2/users/YOUR_USER_ID_HERE/apps/YOUR_APP_ID_HERE/annotations?page=1&per_page=10&input_ids=YOUR_INPUT_ID_HERE" \
-H "Authorization: Key YOUR_PAT_HERE"
List Annotations by Input IDs and Annotation IDs
You can list annotations by input IDs and their corresponding annotation IDs. Number of input IDs and annotation IDs should be the same. Since we are finding annotation by IDs, this will match any user or model created annotations.
Below is an example of how to do that.
-
When listing annotations, both input IDs and annotation IDs are optional. If you do not provide any input ID or annotation ID, we will return all annotations based on the creation time of each input.
-
You can also list annotations by providing input IDs only.
-
However, if you want to list annotations by providing annotation IDs, then input IDs are also required so that we know the inputs that correspond to the annotation IDs provided in the request. In this case, the number of input IDs should be equal to the number of annotation IDs.
- Python (gRPC)
- JavaScript (REST)
- Node.js (gRPC)
- Java (gRPC)
- PHP (gRPC)
- cURL
##########################################################################
# In this section, we set the user authentication, app ID, input IDs, and
# annotation IDs. Change these strings to run your own example.
##########################################################################
USER_ID = 'YOUR_USER_ID_HERE'
# Your PAT (Personal Access Token) can be found in the Account's Security section
PAT = 'YOUR_PAT_HERE'
APP_ID = 'YOUR_APP_ID_HERE'
# Change these to list your own annotations
INPUT_ID_1 = '53d0362a9dfa4e03b2293375e2d0db73'
INPUT_ID_2 = '00f6d742124147ac8ca7788f73736fb9'
ANNOTATION_ID_1 = '300b8e39a65e4f33ae4e15e86eaf4a3b'
ANNOTATION_ID_2 = 'fcd19d4ad96440e7b1fbda7279c19e44'
##########################################################################
# YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
##########################################################################
from clarifai_grpc.channel.clarifai_channel import ClarifaiChannel
from clarifai_grpc.grpc.api import resources_pb2, service_pb2, service_pb2_grpc
from clarifai_grpc.grpc.api.status import status_code_pb2
channel = ClarifaiChannel.get_grpc_channel()
stub = service_pb2_grpc.V2Stub(channel)
metadata = (('authorization', 'Key ' + PAT),)
userDataObject = resources_pb2.UserAppIDSet(user_id=USER_ID, app_id=APP_ID)
list_annotations_response = stub.ListAnnotations(
service_pb2.ListAnnotationsRequest(
user_app_id=userDataObject, # The userDataObject is created in the overview and is required when using a PAT
input_ids=[INPUT_ID_1, INPUT_ID_2],
ids=[ANNOTATION_ID_1, ANNOTATION_ID_2],
per_page=10
),
metadata=metadata
)
if list_annotations_response.status.code != status_code_pb2.SUCCESS:
print(list_annotations_response.status)
raise Exception("List annotations failed, status: " + list_annotations_response.status.description)
for annotation_object in list_annotations_response.annotations:
print(annotation_object)
<!--index.html file-->
<script>
///////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, input IDs, and
// annotation IDs. Change these strings to run your own example.
///////////////////////////////////////////////////////////////////////////////
const USER_ID = 'YOUR_USER_ID_HERE';
// Your PAT (Personal Access Token) can be found in the Account's Security section
const PAT = 'YOUR_PAT_HERE';
const APP_ID = 'YOUR_APP_ID_HERE';
// Change these to list your own annotations
const INPUT_ID_1 = 'c9cbb1c90cf24bc98bfd2e529e744ca9';
const INPUT_ID_2 = '1be923b967f148dbb4e588cf4a723da1';
const ANNOTATION_ID_1 = '55ccf4250ba34592ac48fd2b839652fe';
const ANNOTATION_ID_2 = '5a6dafa3864a4d768a4c32e514dd8da1';
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
const requestOptions = {
method: 'GET',
headers: {
'Accept': 'application/json',
'Authorization': 'Key ' + PAT
}
};
fetch(`https://api.clarifai.com/v2/users/${USER_ID}/apps/${APP_ID}/annotations?page=1&per_page=10&input_ids=${INPUT_ID_1}&input_ids=${INPUT_ID_2}&ids=${ANNOTATION_ID_1}&ids=${ANNOTATION_ID_2}`, requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
</script>
//index.js file
///////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, input IDs, and
// annotation IDs. Change these strings to run your own example.
///////////////////////////////////////////////////////////////////////////////
const USER_ID = 'YOUR_USER_ID_HERE';
// Your PAT (Personal Access Token) can be found in the Account's Security section
const PAT = 'YOUR_PAT_HERE';
const APP_ID = 'YOUR_APP_ID_HERE';
// Change these to list your own annotations
const INPUT_ID_1 = 'c9cbb1c90cf24bc98bfd2e529e744ca9';
const INPUT_ID_2 = '1be923b967f148dbb4e588cf4a723da1';
const ANNOTATION_ID_1 = '55ccf4250ba34592ac48fd2b839652fe';
const ANNOTATION_ID_2 = '5a6dafa3864a4d768a4c32e514dd8da1';
/////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
/////////////////////////////////////////////////////////////////////////////
const { ClarifaiStub, grpc } = require("clarifai-nodejs-grpc");
const stub = ClarifaiStub.grpc();
// This will be used by every Clarifai endpoint call
const metadata = new grpc.Metadata();
metadata.set("authorization", "Key " + PAT);
stub.ListAnnotations(
{
user_app_id: {
"user_id": USER_ID,
"app_id": APP_ID
},
input_ids: [INPUT_ID_1, INPUT_ID_2],
ids: [ANNOTATION_ID_1, ANNOTATION_ID_2],
page: 1,
per_page: 10
},
metadata,
(err, response) => {
if (err) {
throw new Error(err);
}
if (response.status.code !== 10000) {
throw new Error("List annotations failed, status: " + response.status.description);
}
for (const annotation of response.annotations) {
console.log(JSON.stringify(annotation, null, 2));
}
}
);
package com.clarifai.example;
import com.clarifai.grpc.api.*;
import com.clarifai.channel.ClarifaiChannel;
import com.clarifai.credentials.ClarifaiCallCredentials;
import com.clarifai.grpc.api.status.*;
public class ClarifaiExample {
/////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, input IDs, and
// annotation IDs. Change these strings to run your own example.
/////////////////////////////////////////////////////////////////////////////
static final String USER_ID = "YOUR_USER_ID_HERE";
//Your PAT (Personal Access Token) can be found in the portal under Authentication
static final String PAT = "YOUR_PAT_HERE";
static final String APP_ID = "YOUR_APP_ID_HERE";
// Change these to list your own annotations
static final String INPUT_ID_1 = "c9cbb1c90cf24bc98bfd2e529e744ca9";
static final String INPUT_ID_2 = "1be923b967f148dbb4e588cf4a723da1";
static final String ANNOTATION_ID_1 = "55ccf4250ba34592ac48fd2b839652fe";
static final String ANNOTATION_ID_2 = "5a6dafa3864a4d768a4c32e514dd8da1";
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
public static void main(String[] args) {
V2Grpc.V2BlockingStub stub = V2Grpc.newBlockingStub(ClarifaiChannel.INSTANCE.getGrpcChannel())
.withCallCredentials(new ClarifaiCallCredentials(PAT));
MultiAnnotationResponse listAnnotationsResponse = stub.listAnnotations(
ListAnnotationsRequest.newBuilder()
.setUserAppId(UserAppIDSet.newBuilder().setUserId(USER_ID).setAppId(APP_ID))
.setPerPage(10)
.addInputIds(INPUT_ID_1)
.addInputIds(INPUT_ID_2)
.addIds(ANNOTATION_ID_1)
.addIds(ANNOTATION_ID_2)
.build()
);
if (listAnnotationsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
throw new RuntimeException("List annotations failed, status: " + listAnnotationsResponse.getStatus());
}
for (Annotation annotation: listAnnotationsResponse.getAnnotationsList()) {
System.out.println(annotation);
}
}
}
<?php
require __DIR__ . "/vendor/autoload.php";
///////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, input IDs, and
// annotation IDs. Change these strings to run your own example.
///////////////////////////////////////////////////////////////////////////////
$USER_ID = "YOUR_USER_ID_HERE";
// Your PAT (Personal Access Token) can be found in the Account's Security section
$PAT = "YOUR_PAT_HERE";
$APP_ID = "YOUR_APP_ID_HERE";
// Change these to list your own annotations
$INPUT_ID_1 = 'c9cbb1c90cf24bc98bfd2e529e744ca9';
$INPUT_ID_2 = '1be923b967f148dbb4e588cf4a723da1';
$ANNOTATION_ID_1 = '55ccf4250ba34592ac48fd2b839652fe';
$ANNOTATION_ID_2 = '5a6dafa3864a4d768a4c32e514dd8da1';
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
use Clarifai\ClarifaiClient;
use Clarifai\Api\ListAnnotationsRequest;
use Clarifai\Api\Status\StatusCode;
use Clarifai\Api\UserAppIDSet;
$client = ClarifaiClient::grpc();
$metadata = ["Authorization" => ["Key " . $PAT]];
$userDataObject = new UserAppIDSet([
"user_id" => $USER_ID,
"app_id" => $APP_ID
]);
// Let's make a RPC call to the Clarifai platform. It uses the opened gRPC client channel to communicate a
// request and then wait for the response
[$response, $status] = $client->ListAnnotations(
// The request object carries the request along with the request status and other metadata related to the request itself
new ListAnnotationsRequest([
"user_app_id" => $userDataObject,
"input_ids" => [$INPUT_ID_1, $INPUT_ID_2],
"ids" => [$ANNOTATION_ID_1, $ANNOTATION_ID_2],
"per_page" => 10
]),
$metadata
)->wait();
// A response is returned and the first thing we do is check the status of it
// A successful response will have a status code of 0; otherwise, there is some error
if ($status->code !== 0) {
throw new Exception("Error: {$status->details}");
}
// In addition to the RPC response status, there is a Clarifai API status that reports if the operation was a success or failure
// (not just that the communication was successful)
if ($response->getStatus()->getCode() != StatusCode::SUCCESS) {
print $response->getStatus()->getDetails();
throw new Exception("Failure response: " . $response->getStatus()->getDescription());
}
foreach ($response->getAnnotations() as $annotation_object) {
echo $annotation_object->SerializeToJSONString() . "</br>";
}
?>
curl -X GET "https://api.clarifai.com/v2/users/YOUR_USER_ID_HERE/apps/YOUR_APP_ID_HERE/annotations?page=1&per_page=10&input_ids=YOUR_INPUT_ID_1_HERE&input_ids=YOUR_INPUT_ID_2_HERE&ids=YOUR_ANNOTATION_ID_1_HERE&ids=YOUR_ANNOTATION_ID_2_HERE" \
-H "Authorization: Key YOUR_PAT_HERE"
List Annotations by User IDs
An annotation is created by either a user or a model. You can list annotations created by specific user(s) by providing their user IDs.
Below is an example of how to do that.
- Python (gRPC)
- JavaScript (REST)
- Node.js (gRPC)
- Java (gRPC)
- PHP (gRPC)
- cURL
#########################################################################
# In this section, we set the user authentication, app ID, and user IDs.
# Change these strings to run your own example.
#########################################################################
USER_ID = 'YOUR_USER_ID_HERE'
# Your PAT (Personal Access Token) can be found in the Account's Security section
PAT = 'YOUR_PAT_HERE'
APP_ID = 'YOUR_APP_ID_HERE'
# Insert the user IDs
USER_ID_1 = 'USER_ID_1_HERE'
USER_ID_2 = 'USER_ID_2_HERE'
##########################################################################
# YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
##########################################################################
from clarifai_grpc.channel.clarifai_channel import ClarifaiChannel
from clarifai_grpc.grpc.api import resources_pb2, service_pb2, service_pb2_grpc
from clarifai_grpc.grpc.api.status import status_code_pb2
channel = ClarifaiChannel.get_grpc_channel()
stub = service_pb2_grpc.V2Stub(channel)
metadata = (('authorization', 'Key ' + PAT),)
userDataObject = resources_pb2.UserAppIDSet(user_id=USER_ID, app_id=APP_ID)
list_annotations_response = stub.ListAnnotations(
service_pb2.ListAnnotationsRequest(
user_app_id=userDataObject, # The userDataObject is created in the overview and is required when using a PAT
user_ids=[USER_ID_1, USER_ID_2],
per_page=10
),
metadata=metadata
)
if list_annotations_response.status.code != status_code_pb2.SUCCESS:
print(list_annotations_response.status)
raise Exception("List annotations failed, status: " + list_annotations_response.status.description)
for annotation_object in list_annotations_response.annotations:
print(annotation_object)
<!--index.html file-->
<script>
///////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and user IDs.
// Change these strings to run your own example.
///////////////////////////////////////////////////////////////////////////////
const USER_ID = 'YOUR_USER_ID_HERE';
// Your PAT (Personal Access Token) can be found in the Account's Security section
const PAT = 'YOUR_PAT_HERE';
const APP_ID = 'YOUR_APP_ID_HERE';
// Insert the user IDs
const USER_ID_1 = 'USER_ID_1_HERE';
const USER_ID_2 = 'USER_ID_2_HERE';
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
const requestOptions = {
method: 'GET',
headers: {
'Accept': 'application/json',
'Authorization': 'Key ' + PAT
}
};
fetch(`https://api.clarifai.com/v2/users/${USER_ID}/apps/${APP_ID}/annotations?page=1&per_page=10&user_ids=${USER_ID_1}&user_ids=${USER_ID_2}`, requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
</script>
//index.js file
///////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and user IDs.
// Change these strings to run your own example.
///////////////////////////////////////////////////////////////////////////////
const USER_ID = 'YOUR_USER_ID_HERE';
// Your PAT (Personal Access Token) can be found in the Account's Security section
const PAT = 'YOUR_PAT_HERE';
const APP_ID = 'YOUR_APP_ID_HERE';
// Insert the user IDs
const USER_ID_1 = 'USER_ID_1_HERE';
const USER_ID_2 = 'USER_ID_2_HERE';
/////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
/////////////////////////////////////////////////////////////////////////////
const { ClarifaiStub, grpc } = require("clarifai-nodejs-grpc");
const stub = ClarifaiStub.grpc();
// This will be used by every Clarifai endpoint call
const metadata = new grpc.Metadata();
metadata.set("authorization", "Key " + PAT);
stub.ListAnnotations(
{
user_app_id: {
"user_id": USER_ID,
"app_id": APP_ID
},
user_ids: [USER_ID_1, USER_ID_2],
page: 1,
per_page: 10
},
metadata,
(err, response) => {
if (err) {
throw new Error(err);
}
if (response.status.code !== 10000) {
throw new Error("List annotations failed, status: " + response.status.description);
}
for (const annotation of response.annotations) {
console.log(JSON.stringify(annotation, null, 2));
}
}
);
package com.clarifai.example;
import com.clarifai.grpc.api.*;
import com.clarifai.channel.ClarifaiChannel;
import com.clarifai.credentials.ClarifaiCallCredentials;
import com.clarifai.grpc.api.status.StatusCode;
public class ClarifaiExample {
//////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and user IDs.
// Change these strings to run your own example.
//////////////////////////////////////////////////////////////////////////////
static final String USER_ID = "YOUR_USER_ID_HERE";
//Your PAT (Personal Access Token) can be found in the portal under Authentication
static final String PAT = "YOUR_PAT_HERE";
static final String APP_ID = "YOUR_APP_ID_HERE";
// Insert the user IDs
static final String USER_ID_1 = "USER_ID_1_HERE";
static final String USER_ID_2 = "USER_ID_2_HERE";
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
public static void main(String[] args) {
V2Grpc.V2BlockingStub stub = V2Grpc.newBlockingStub(ClarifaiChannel.INSTANCE.getGrpcChannel())
.withCallCredentials(new ClarifaiCallCredentials(PAT));
MultiAnnotationResponse listAnnotationsResponse = stub.listAnnotations(
ListAnnotationsRequest.newBuilder()
.setUserAppId(UserAppIDSet.newBuilder().setUserId(USER_ID).setAppId(APP_ID))
.addUserIds(USER_ID_1)
.addUserIds(USER_ID_2)
.setPerPage(10)
.build()
);
if (listAnnotationsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
throw new RuntimeException("List annotations failed, status: " + listAnnotationsResponse.getStatus());
}
for (Annotation annotation: listAnnotationsResponse.getAnnotationsList()) {
System.out.println(annotation);
}
}
}
<?php
require __DIR__ . "/vendor/autoload.php";
///////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and user IDs.
// Change these strings to run your own example.
//////////////////////////////////////////////////////////////////////////////
$USER_ID = "YOUR_USER_ID_HERE";
// Your PAT (Personal Access Token) can be found in the Account's Security section
$PAT = "YOUR_PAT_HERE";
$APP_ID = "YOUR_APP_ID_HERE";
// Insert the user IDs
$USER_ID_1 = "USER_ID_1_HERE";
$USER_ID_2 = "USER_ID_2_HERE";
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
use Clarifai\ClarifaiClient;
use Clarifai\Api\ListAnnotationsRequest;
use Clarifai\Api\Status\StatusCode;
use Clarifai\Api\UserAppIDSet;
$client = ClarifaiClient::grpc();
$metadata = ["Authorization" => ["Key " . $PAT]];
$userDataObject = new UserAppIDSet([
"user_id" => $USER_ID,
"app_id" => $APP_ID
]);
// Let's make a RPC call to the Clarifai platform. It uses the opened gRPC client channel to communicate a
// request and then wait for the response
[$response, $status] = $client->ListAnnotations(
// The request object carries the request along with the request status and other metadata related to the request itself
new ListAnnotationsRequest([
"user_app_id" => $userDataObject,
"user_ids" => [$USER_ID_1, $USER_ID_2],
"per_page" => 10
]),
$metadata
)->wait();
// A response is returned and the first thing we do is check the status of it
// A successful response will have a status code of 0; otherwise, there is some error
if ($status->code !== 0) {
throw new Exception("Error: {$status->details}");
}
// In addition to the RPC response status, there is a Clarifai API status that reports if the operation was a success or failure
// (not just that the communication was successful)
if ($response->getStatus()->getCode() != StatusCode::SUCCESS) {
print $response->getStatus()->getDetails();
throw new Exception("Failure response: " . $response->getStatus()->getDescription());
}
foreach ($response->getAnnotations() as $annotation_object) {
echo $annotation_object->SerializeToJSONString() . "</br>";
}
?>
curl -X GET "https://api.clarifai.com/v2/users/YOUR_USER_ID_HERE/apps/YOUR_APP_ID_HERE/annotations?page=1&per_page=10&user_ids=USER_ID_1_HERE&user_ids=USER_ID_2_HERE" \
-H "Authorization: Key YOUR_PAT_HERE"
List Annotations by Model Version IDs
An annotation is created by either a user or a model. For example, if your workflow has a detection model, when you add an input, the model will detect objects in your input. You can see these detected objects by listing the annotations created in the detection model.
You can also label these regions by using Post annotation
with the region ID returned from this call.
Below is an example of how to list annotations by model version IDs.
- Python (gRPC)
- JavaScript (REST)
- Node.js (gRPC)
- Java (gRPC)
- PHP (gRPC)
- cURL
##################################################################################
# In this section, we set the user authentication, app ID, and model version IDs.
# Change these strings to run your own example.
##################################################################################
USER_ID = 'YOUR_USER_ID_HERE'
# Your PAT (Personal Access Token) can be found in the Account's Security section
PAT = 'YOUR_PAT_HERE'
APP_ID = 'YOUR_APP_ID_HERE'
# Insert the model version IDs
MODEL_VERSION_ID_1 = 'MODEL_VERSION_ID_1_HERE'
MODEL_VERSION_ID_2 = 'MODEL_VERSION_ID_2_HERE'
##########################################################################
# YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
##########################################################################
from clarifai_grpc.channel.clarifai_channel import ClarifaiChannel
from clarifai_grpc.grpc.api import resources_pb2, service_pb2, service_pb2_grpc
from clarifai_grpc.grpc.api.status import status_code_pb2
channel = ClarifaiChannel.get_grpc_channel()
stub = service_pb2_grpc.V2Stub(channel)
metadata = (('authorization', 'Key ' + PAT),)
userDataObject = resources_pb2.UserAppIDSet(user_id=USER_ID, app_id=APP_ID)
list_annotations_response = stub.ListAnnotations(
service_pb2.ListAnnotationsRequest(
user_app_id=userDataObject, # The userDataObject is created in the overview and is required when using a PAT
model_version_ids=[MODEL_VERSION_ID_1, MODEL_VERSION_ID_2],
per_page=10
),
metadata=metadata
)
if list_annotations_response.status.code != status_code_pb2.SUCCESS:
print(list_annotations_response.status)
raise Exception("List annotations failed, status: " + list_annotations_response.status.description)
for annotation_object in list_annotations_response.annotations:
print(annotation_object)
<!--index.html file-->
<script>
////////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and model version IDs.
// Change these strings to run your own example.
////////////////////////////////////////////////////////////////////////////////////
const USER_ID = 'YOUR_USER_ID_HERE';
// Your PAT (Personal Access Token) can be found in the Account's Security section
const PAT = 'YOUR_PAT_HERE';
const APP_ID = 'YOUR_APP_ID_HERE';
// Insert the model version IDs
const MODEL_VERSION_ID_1 = 'MODEL_VERSION_ID_1_HERE';
const MODEL_VERSION_ID_2 = 'MODEL_VERSION_ID_2_HERE';
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
const requestOptions = {
method: 'GET',
headers: {
'Accept': 'application/json',
'Authorization': 'Key ' + PAT
}
};
fetch(`https://api.clarifai.com/v2/users/${USER_ID}/apps/${APP_ID}/annotations?page=1&per_page=10&model_version_ids=${MODEL_VERSION_ID_1}&model_version_ids=${MODEL_VERSION_ID_2}`, requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
</script>
//index.js file
////////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and model version IDs.
// Change these strings to run your own example.
////////////////////////////////////////////////////////////////////////////////////
const USER_ID = 'YOUR_USER_ID_HERE';
// Your PAT (Personal Access Token) can be found in the Account's Security section
const PAT = 'YOUR_PAT_HERE';
const APP_ID = 'YOUR_APP_ID_HERE';
// Insert the model version IDs
const MODEL_VERSION_ID_1 = 'MODEL_VERSION_ID_1_HERE';
const MODEL_VERSION_ID_2 = 'MODEL_VERSION_ID_2_HERE';
/////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
/////////////////////////////////////////////////////////////////////////////
const { ClarifaiStub, grpc } = require("clarifai-nodejs-grpc");
const stub = ClarifaiStub.grpc();
// This will be used by every Clarifai endpoint call
const metadata = new grpc.Metadata();
metadata.set("authorization", "Key " + PAT);
stub.ListAnnotations(
{
user_app_id: {
"user_id": USER_ID,
"app_id": APP_ID
},
model_version_ids: [MODEL_VERSION_ID_1, MODEL_VERSION_ID_2],
page: 1,
per_page: 10
},
metadata,
(err, response) => {
if (err) {
throw new Error(err);
}
if (response.status.code !== 10000) {
throw new Error("List annotations failed, status: " + response.status.description);
}
for (const annotation of response.annotations) {
console.log(JSON.stringify(annotation, null, 2));
}
}
);
package com.clarifai.example;
import com.clarifai.grpc.api.*;
import com.clarifai.channel.ClarifaiChannel;
import com.clarifai.credentials.ClarifaiCallCredentials;
import com.clarifai.grpc.api.status.StatusCode;
public class ClarifaiExample {
/////////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and model version IDs.
// Change these strings to run your own example.
////////////////////////////////////////////////////////////////////////////////////
static final String USER_ID = "YOUR_USER_ID_HERE";
//Your PAT (Personal Access Token) can be found in the portal under Authentication
static final String PAT = "YOUR_PAT_HERE";
static final String APP_ID = "YOUR_APP_ID_HERE";
// Insert the model version IDs
static final String MODEL_VERSION_ID_1 = "MODEL_VERSION_ID_1_HERE";
static final String MODEL_VERSION_ID_2 = "MODEL_VERSION_ID_2_HERE";
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
public static void main(String[] args) {
V2Grpc.V2BlockingStub stub = V2Grpc.newBlockingStub(ClarifaiChannel.INSTANCE.getGrpcChannel())
.withCallCredentials(new ClarifaiCallCredentials(PAT));
MultiAnnotationResponse listAnnotationsResponse = stub.listAnnotations(
ListAnnotationsRequest.newBuilder()
.setUserAppId(UserAppIDSet.newBuilder().setUserId(USER_ID).setAppId(APP_ID))
.addModelVersionIds(MODEL_VERSION_ID_1)
.addModelVersionIds(MODEL_VERSION_ID_2)
.setPerPage(10)
.build()
);
if (listAnnotationsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
throw new RuntimeException("List annotations failed, status: " + listAnnotationsResponse.getStatus());
}
for (Annotation annotation: listAnnotationsResponse.getAnnotationsList()) {
System.out.println(annotation);
}
}
}
<?php
require __DIR__ . "/vendor/autoload.php";
////////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and model version IDs.
// Change these strings to run your own example.
////////////////////////////////////////////////////////////////////////////////////
$USER_ID = "YOUR_USER_ID_HERE";
// Your PAT (Personal Access Token) can be found in the Account's Security section
$PAT = "YOUR_PAT_HERE";
$APP_ID = "YOUR_APP_ID_HERE";
// Insert the model version IDs
$MODEL_VERSION_ID_1 = "MODEL_VERSION_ID_1_HERE";
$MODEL_VERSION_ID_2 = "MODEL_VERSION_ID_2_HERE";
///////////////////////////////////////////////////////////////////////////////////
// YOU DO NOT NEED TO CHANGE ANYTHING BELOW THIS LINE TO RUN THIS EXAMPLE
///////////////////////////////////////////////////////////////////////////////////
use Clarifai\ClarifaiClient;
use Clarifai\Api\ListAnnotationsRequest;
use Clarifai\Api\Status\StatusCode;
use Clarifai\Api\UserAppIDSet;
$client = ClarifaiClient::grpc();
$metadata = ["Authorization" => ["Key " . $PAT]];
$userDataObject = new UserAppIDSet([
"user_id" => $USER_ID,
"app_id" => $APP_ID
]);
// Let's make a RPC call to the Clarifai platform. It uses the opened gRPC client channel to communicate a
// request and then wait for the response
[$response, $status] = $client->ListAnnotations(
// The request object carries the request along with the request status and other metadata related to the request itself
new ListAnnotationsRequest([
"user_app_id" => $userDataObject,
"model_version_ids" => [$MODEL_VERSION_ID_1, $MODEL_VERSION_ID_2],
"per_page" => 10
]),
$metadata
)->wait();
// A response is returned and the first thing we do is check the status of it
// A successful response will have a status code of 0; otherwise, there is some error
if ($status->code !== 0) {
throw new Exception("Error: {$status->details}");
}
// In addition to the RPC response status, there is a Clarifai API status that reports if the operation was a success or failure
// (not just that the communication was successful)
if ($response->getStatus()->getCode() != StatusCode::SUCCESS) {
print $response->getStatus()->getDetails();
throw new Exception("Failure response: " . $response->getStatus()->getDescription());
}
foreach ($response->getAnnotations() as $annotation_object) {
echo $annotation_object->SerializeToJSONString() . "</br>";
}
?>
curl -X GET "https://api.clarifai.com/v2/users/YOUR_USER_ID_HERE/apps/YOUR_APP_ID_HERE/annotations?page=1&per_page=10&model_version_ids=MODEL_VERSION_ID_1_HERE&model_version_ids=MODEL_VERSION_ID_2_HERE" \
-H "Authorization: Key YOUR_PAT_HERE"