Filter
Select a subset of your data based on useful filters.
You can filter and customize your search results to find exactly what you want. Filtering helps you reduce the amount of data returned in search results by removing irrelevant content, or by allowing you to select a specific subset of your data.

By Custom Concepts

After you annotate inputs with custom concepts, you can filter by concepts.
Java
NodeJS
Python
cURL
Javascript (REST)
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
6
7
MultiSearchResponse postAnnotationsSearchesResponse = stub.postAnnotationsSearches(
8
PostAnnotationsSearchesRequest.newBuilder().addSearches(
9
Search.newBuilder().setQuery(
10
Query.newBuilder().addFilters(
11
Filter.newBuilder().setAnnotation(
12
Annotation.newBuilder().setData(
13
Data.newBuilder().addConcepts( // You can search by multiple concepts.
14
Concept.newBuilder()
15
.setId("people") // You could search by concept Name as well.
16
.setValue(1f) // Value of 0 will search for images that don't have the concept.
17
)
18
)
19
)
20
)
21
)
22
)
23
.build()
24
);
25
26
if (postAnnotationsSearchesResponse.getStatus().getCode() != StatusCode.SUCCESS) {
27
throw new RuntimeException("Post annotations searches failed, status: " + postAnnotationsSearchesResponse.getStatus());
28
}
29
30
System.out.println("Found inputs " + postAnnotationsSearchesResponse.getHitsCount() + ":");
31
for (Hit hit : postAnnotationsSearchesResponse.getHitsList()) {
32
System.out.printf("\tScore %.2f for annotation % of input %s\n", hit.getScore(), hit.getAnnotation().getId(), hit.getInput().getId())
33
}
Copied!
1
// Insert here the initialization code as outlined on this page:
2
// https://docs.clarifai.com/api-guide/api-overview
3
4
stub.PostAnnotationsSearches(
5
{
6
searches: [
7
{
8
query: {
9
filters: [
10
{
11
annotation: {
12
data: {
13
concepts: [ // You can search by multiple concepts.
14
{
15
id: "people", // You could search by concept Name as well.
16
value: 1 // Value of 0 will search for images that don't have the concept
17
}
18
]
19
}
20
}
21
}
22
]
23
}
24
}
25
]
26
},
27
metadata,
28
(err, response) => {
29
if (err) {
30
throw new Error(err);
31
}
32
33
if (response.status.code !== 10000) {
34
throw new Error("Post annotations searches failed, status: " + response.status.description);
35
}
36
37
console.log("Search result:");
38
for (const hit of response.hits) {
39
console.log("\tScore " + hit.score + " for annotation: " + hit.annotation.id + " of input: ", hit.input.id);
40
}
41
}
42
);
Copied!
1
from clarifai_grpc.grpc.api import service_pb2, resources_pb2
2
from clarifai_grpc.grpc.api.status import status_code_pb2
3
4
# Insert here the initialization code as outlined on this page:
5
# https://docs.clarifai.com/api-guide/api-overview
6
7
post_annotations_searches_response = stub.PostAnnotationsSearches(
8
service_pb2.PostAnnotationsSearchesRequest(
9
searches = [
10
resources_pb2.Search(
11
query=resources_pb2.Query(
12
filters=[
13
resources_pb2.Filter(
14
annotation=resources_pb2.Annotation(
15
data=resources_pb2.Data(
16
concepts=[ # You can search by multiple concepts.
17
resources_pb2.Concept(
18
id="people", # You could search by concept Name as well.
19
value=1 # Value of 0 will search for images that don't have the concept.
20
)
21
]
22
)
23
)
24
)
25
]
26
)
27
)
28
]
29
),
30
metadata=metadata
31
)
32
33
if post_annotations_searches_response.status.code != status_code_pb2.SUCCESS:
34
raise Exception("Post searches failed, status: " + post_annotations_searches_response.status.description)
35
36
print("Search result:")
37
for hit in post_annotations_searches_response.hits:
38
print("\tScore %.2f for annotation: %s off input: %s" % (hit.score, hit.annotation.id, hit.input.id))
Copied!
1
#
2
# Value of 0 will search for images that don't have the concept.
3
#
4
# Instead of "id" you can search by "name" as well.
5
6
curl -X POST \
7
-H "Authorization: Key YOUR_API_KEY" \
8
-H "Content-Type: application/json" \
9
-d '
10
{
11
"searches": [{
12
"query": {
13
"filters": [
14
{
15
"annotation": {
16
"data": {
17
"concepts": [
18
{
19
"id":"people",
20
"value": 1
21
}
22
]
23
}
24
}
25
}
26
]
27
}
28
}]
29
30
}'\
31
https://api.clarifai.com/v2/annnotations/searches
Copied!
1
const raw = JSON.stringify({
2
"user_app_id": {
3
"user_id": "{YOUR_USER_ID}",
4
"app_id": "{YOUR_APP_ID}"
5
},
6
"searches": [{
7
"query": {
8
"filters": [
9
{
10
"annotation": {
11
"data": {
12
"concepts": [
13
{
14
"id":"people",
15
"value": 1
16
}
17
]
18
}
19
}
20
}
21
]
22
}
23
}]
24
});
25
26
const requestOptions = {
27
method: 'POST',
28
headers: {
29
'Accept': 'application/json',
30
'Authorization': 'Key {YOUR_PERSONAL_TOKEN}'
31
},
32
body: raw
33
};
34
35
fetch(`https://api.clarifai.com/v2/annotations/searches`, requestOptions)
36
.then(response => response.text())
37
.then(result => console.log(result))
38
.catch(error => console.log('error', error));
Copied!

By User ID

If you have collaborators in your app and they helped you annotate your inputs, you can also filter annotations by user id.
Java
NodeJS
Python
cURL
Javascript (REST)
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
6
7
MultiSearchResponse postAnnotationsSearchesResponse = stub.postAnnotationsSearches(
8
PostAnnotationsSearchesRequest.newBuilder().addSearches(
9
Search.newBuilder().setQuery(
10
Query.newBuilder().addFilters(
11
Filter.newBuilder().setAnnotation(
12
Annotation.newBuilder().setUserId("{user_id}")
13
)
14
)
15
)
16
)
17
.build()
18
);
19
20
if (postAnnotationsSearchesResponse.getStatus().getCode() != StatusCode.SUCCESS) {
21
throw new RuntimeException("Post annotations searches failed, status: " + postAnnotationsSearchesResponse.getStatus());
22
}
23
24
System.out.println("Found inputs " + postAnnotationsSearchesResponse.getHitsCount() + ":");
25
for (Hit hit : postAnnotationsSearchesResponse.getHitsList()) {
26
System.out.printf("\tScore %.2f for annotation % of input %s\n", hit.getScore(), hit.getAnnotation().getId(), hit.getInput().getId())
27
}
Copied!
1
// Insert here the initialization code as outlined on this page:
2
// https://docs.clarifai.com/api-guide/api-overview
3
4
stub.PostAnnotationsSearches(
5
{
6
searches: [
7
{
8
query: {
9
filters: [
10
{
11
annotation: {
12
user_id: "{user_id}"
13
}
14
}
15
]
16
}
17
}
18
]
19
20
},
21
metadata,
22
(err, response) => {
23
if (err) {
24
throw new Error(err);
25
}
26
27
if (response.status.code !== 10000) {
28
throw new Error("Post annotations searches failed, status: " + response.status.description);
29
}
30
31
console.log("Search result:");
32
for (const hit of response.hits) {
33
console.log("\tScore " + hit.score + " for annotation: " + hit.annotation.id + " of input: ", hit.input.id);
34
}
35
}
36
);
Copied!
1
from clarifai_grpc.grpc.api import service_pb2, resources_pb2
2
from clarifai_grpc.grpc.api.status import status_code_pb2
3
4
# Insert here the initialization code as outlined on this page:
5
# https://docs.clarifai.com/api-guide/api-overview
6
7
post_annotations_searches_response = stub.PostAnnotationsSearches(
8
service_pb2.PostAnnotationsSearchesRequest(
9
searches = [
10
resources_pb2.Search(
11
query=resources_pb2.Query(
12
filters=[
13
resources_pb2.Filter(
14
annotation=resources_pb2.Annotation(
15
user_id="{user_id}"
16
)
17
)
18
]
19
)
20
)
21
]
22
),
23
metadata=metadata
24
)
25
26
if post_annotations_searches_response.status.code != status_code_pb2.SUCCESS:
27
print("There was an error with your request!")
28
print("\tCode: {}".format(post_annotations_searches_response.outputs[0].status.code))
29
print("\tDescription: {}".format(post_annotations_searches_response.outputs[0].status.description))
30
print("\tDetails: {}".format(post_annotations_searches_response.outputs[0].status.details))
31
raise Exception("Post searches failed, status: " + post_annotations_searches_response.status.description)
32
33
print("Search result:")
34
for hit in post_annotations_searches_response.hits:
35
print("\tScore %.2f for annotation: %s off input: %s" % (hit.score, hit.annotation.id, hit.input.id))
Copied!
1
#
2
# Value of 0 will search for images that don't have the concept.
3
#
4
# Instead of "id" you can search by "name" as well.
5
6
curl -X POST \
7
-H "Authorization: Key YOUR_API_KEY" \
8
-H "Content-Type: application/json" \
9
-d '
10
{
11
"searches": [{
12
"query": {
13
"filters": [
14
{
15
"annotation": {
16
"user_id": "{user_id}"
17
}
18
}
19
]
20
}
21
}]
22
}'\
23
https://api.clarifai.com/v2/annnotations/searches
Copied!
1
const raw = JSON.stringify({
2
"user_app_id": {
3
"user_id": "{YOUR_USER_ID}",
4
"app_id": "{YOUR_APP_ID}"
5
},
6
"searches": [{
7
"query": {
8
"filters": [
9
{
10
"annotation": {
11
"user_id": "{user_id}"
12
}
13
}
14
]
15
}
16
}]
17
});
18
19
const requestOptions = {
20
method: 'POST',
21
headers: {
22
'Accept': 'application/json',
23
'Authorization': 'Key {YOUR_PERSONAL_TOKEN}'
24
},
25
body: raw
26
};
27
28
fetch(`https://api.clarifai.com/v2/annotations/searches`, requestOptions)
29
.then(response => response.text())
30
.then(result => console.log(result))
31
.catch(error => console.log('error', error));
Copied!

By Annotation Status

Java
NodeJS
Python
cURL
Javascript (REST)
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
6
7
MultiSearchResponse postAnnotationsSearchesResponse = stub.postAnnotationsSearches(
8
PostAnnotationsSearchesRequest.newBuilder().addSearches(
9
Search.newBuilder().setQuery(
10
Query.newBuilder().addFilters(
11
Filter.newBuilder().setAnnotation(
12
Annotation.newBuilder()
13
.setStatus(
14
Status.newBuilder()
15
.setCodeValue(StatusCode.ANNOTATION_SUCCESS_VALUE)
16
.build()
17
)
18
)
19
)
20
)
21
)
22
.build()
23
);
24
25
if (postAnnotationsSearchesResponse.getStatus().getCode() != StatusCode.SUCCESS) {
26
throw new RuntimeException("Post annotations searches failed, status: " + postAnnotationsSearchesResponse.getStatus());
27
}
28
29
System.out.println("Found inputs " + postAnnotationsSearchesResponse.getHitsCount() + ":");
30
for (Hit hit : postAnnotationsSearchesResponse.getHitsList()) {
31
System.out.printf("\tScore %.2f for annotation % of input %s\n", hit.getScore(), hit.getAnnotation().getId(), hit.getInput().getId())
32
}
Copied!
1
// Insert here the initialization code as outlined on this page:
2
// https://docs.clarifai.com/api-guide/api-overview
3
4
stub.PostAnnotationsSearches(
5
{
6
searches: [
7
{
8
query: {
9
filters: [
10
{
11
annotation: {
12
status: {
13
code: 24150
14
}
15
}
16
}
17
]
18
}
19
}
20
]
21
},
22
metadata,
23
(err, response) => {
24
if (err) {
25
throw new Error(err);
26
}
27
28
if (response.status.code !== 10000) {
29
throw new Error("Post annotations searches failed, status: " + response.status.description);
30
}
31
32
console.log("Search result:");
33
for (const hit of response.hits) {
34
console.log("\tScore " + hit.score + " for annotation: " + hit.annotation.id + " of input: ", hit.input.id);
35
}
36
}
37
);
Copied!
1
from clarifai_grpc.grpc.api import service_pb2, resources_pb2
2
from clarifai_grpc.grpc.api.status import status_code_pb2
3
4
# Insert here the initialization code as outlined on this page:
5
# https://docs.clarifai.com/api-guide/api-overview
6
7
post_annotations_searches_response = stub.PostAnnotationsSearches(
8
service_pb2.PostAnnotationsSearchesRequest(
9
searches = [
10
resources_pb2.Search(
11
query=resources_pb2.Query(
12
filters=[
13
resources_pb2.Filter(
14
annotation=resources_pb2.Annotation(
15
status=status_pb2.Status(
16
code=status_code_pb2.ANNOTATION_SUCCESS
17
)
18
)
19
)
20
]
21
)
22
)
23
]
24
),
25
metadata=metadata
26
)
27
28
if post_annotations_searches_response.status.code != status_code_pb2.SUCCESS:
29
print("There was an error with your request!")
30
print("\tCode: {}".format(post_annotations_searches_response.outputs[0].status.code))
31
print("\tDescription: {}".format(post_annotations_searches_response.outputs[0].status.description))
32
print("\tDetails: {}".format(post_annotations_searches_response.outputs[0].status.details))
33
raise Exception("Post searches failed, status: " + post_annotations_searches_response.status.description)
34
35
print("Search result:")
36
for hit in post_annotations_searches_response.hits:
37
print("\tScore %.2f for annotation: %s off input: %s" % (hit.score, hit.annotation.id, hit.input.id))
Copied!
1
#
2
# Value of 0 will search for images that don't have the concept.
3
#
4
# Instead of "id" you can search by "name" as well.
5
6
curl -X POST \
7
-H "Authorization: Key YOUR_API_KEY" \
8
-H "Content-Type: application/json" \
9
-d '
10
{
11
"searches": [{
12
"query": {
13
"filters": [
14
{
15
"annotation": {
16
"status": {
17
"code": "ANNOTATION_SUCCESS"
18
}
19
}
20
}
21
]
22
}
23
}]
24
}'\
25
https://api.clarifai.com/v2/annnotations/searches
Copied!
1
const raw = JSON.stringify({
2
"user_app_id": {
3
"user_id": "{YOUR_USER_ID}",
4
"app_id": "{YOUR_APP_ID}"
5
},
6
"searches": [{
7
"query": {
8
"filters": [
9
{
10
"annotation": {
11
"status": {
12
"code": "ANNOTATION_SUCCESS"
13
}
14
}
15
}
16
]
17
}
18
}]
19
});
20
21
const requestOptions = {
22
method: 'POST',
23
headers: {
24
'Accept': 'application/json',
25
'Authorization': 'Key {YOUR_PERSONAL_TOKEN}'
26
},
27
body: raw
28
};
29
30
fetch(`https://api.clarifai.com/v2/annotations/searches`, requestOptions)
31
.then(response => response.text())
32
.then(result => console.log(result))
33
.catch(error => console.log('error', error));
Copied!

By Geo Location

Search by geo location allows you to restrict your search results to a bounding box based on longitude and latitude points. There are two ways you can provide longitude/latitude points. You can provide one point and a radius or you can provide two points.
It is important to note that a search by geo location acts as a filter and returns results ranked by any other provided search criteria, whether that is a visual search, concept search or something else. If no other criteria is provided, results will return in the order the inputs were created, NOT by their distance to center of the search area.
If you are providing one point and a radius, the radius can be in "mile", "kilometer", "degree", or "radian", marked by keywords withinMiles, withinKilometers, withinDegrees, withinRadians.
If you are providing two points, a box will be drawn from the uppermost point to the lowermost point and the leftmost point to the rightmost point.
Before you perform a search by geo location, make sure you have added inputs with longitude and latitude points.

Add inputs with longitude and latitude points

Provide a geo point to an input. The geo point is a JSON object consisting of a longitude and a latitude in GPS coordinate system (SRID 4326). There can be at most one single geo point associated with each input.
Java
NodeJS
Python
cURL
Javascript (REST)
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
6
7
MultiInputResponse postInputsResponse = stub.postInputs(
8
PostInputsRequest.newBuilder().addInputs(
9
Input.newBuilder().setData(
10
Data.newBuilder()
11
.setImage(
12
Image.newBuilder()
13
.setUrl("https://samples.clarifai.com/dog.tiff")
14
.setAllowDuplicateUrl(true)
15
)
16
.setGeo(
17
Geo.newBuilder().setGeoPoint(
18
GeoPoint.newBuilder()
19
.setLongitude(-30)
20
.setLatitude(40)
21
)
22
)
23
)
24
).build()
25
);
26
27
if (postInputsResponse.getStatus().getCode() != StatusCode.SUCCESS) {
28
throw new RuntimeException("Post inputs failed, status: " + postInputsResponse.getStatus());
29
}
Copied!
1
// Insert here the initialization code as outlined on this page:
2
// https://docs.clarifai.com/api-guide/api-overview
3
4
stub.PostInputs(
5
{
6
inputs: [
7
{
8
data: {
9
image: {url: "https://samples.clarifai.com/dog.tiff", allow_duplicate_url: true},
10
geo: {
11
geo_point: {
12
longitude: -30,
13
latitude: 40
14
}
15
}
16
}
17
}
18
]
19
},
20
metadata,
21
(err, response) => {
22
if (err) {
23
throw new Error(err);
24
}
25
26
if (response.status.code !== 10000) {
27
throw new Error("Post inputs failed, status: " + response.status.description);
28
}
29
}
30
);
Copied!
1
from clarifai_grpc.grpc.api import service_pb2, resources_pb2
2
from clarifai_grpc.grpc.api.status import status_code_pb2
3
4
# Insert here the initialization code as outlined on this page:
5
# https://docs.clarifai.com/api-guide/api-overview
6
7
post_inputs_response = stub.PostInputs(
8
service_pb2.PostInputsRequest(
9
inputs=[
10
resources_pb2.Input(
11
data=resources_pb2.Data(
12
image=resources_pb2.Image(
13
url="https://samples.clarifai.com/dog.tiff",
14
allow_duplicate_url=True
15
),
16
geo=resources_pb2.Geo(
17
geo_point=resources_pb2.GeoPoint(
18
longitude=-30.0,
19
latitude=40.0,
20
)
21
)
22
)
23
)
24
]
25
),
26
metadata=metadata
27
)
28
29
if post_inputs_response.status.code != status_code_pb2.SUCCESS:
30
print("There was an error with your request!")
31
print("\tCode: {}".format(post_inputs_response.outputs[0].status.code))
32
print("\tDescription: {}".format(post_inputs_response.outputs[0].status.description))
33
print("\tDetails: {}".format(post_inputs_response.outputs[0].status.details))
34
raise Exception("Post inputs failed, status: " + post_inputs_response.status.description)
Copied!
1
curl -X POST \
2
-H "Authorization: Key YOUR_API_KEY" \
3
-H "Content-Type: application/json" \
4
-d '
5
{
6
"inputs": [
7
{
8
"data": {
9
"image": {
10
"url": "https://samples.clarifai.com/dog.tiff",
11
"allow_duplicate_url": true
12
},
13
"geo": {
14
"geo_point": {
15
"longitude": -30,
16
"latitude": 40
17
}
18
}
19
}
20
}
21
]
22
}'\
23
https://api.clarifai.com/v2/inputs
Copied!
1
const raw = JSON.stringify({
2
"user_app_id": {
3
"user_id": "{YOUR_USER_ID}",
4
"app_id": "{YOUR_APP_ID}"
5
},
6
"inputs": [
7
{
8
"data": {
9
"image": {
10
"url": "https://samples.clarifai.com/dog.tiff",
11
"allow_duplicate_url": true
12
},
13
"geo": {
14
"geo_point": {
15
"longitude": -30,
16
"latitude": 40
17
}
18
}
19
}
20
}
21
]
22
});
23
24
const requestOptions = {
25
method: 'POST',
26
headers: {
27
'Accept': 'application/json',
28
'Authorization': 'Key {YOUR_PERSONAL_TOKEN}'
29
},
30
body: raw
31
};
32
33
fetch(`https://api.clarifai.com/v2/inputs`, requestOptions)
34
.then(response => response.text())
35
.then(result => console.log(result))
36
.catch(error => console.log('error', error));
Copied!

Perform a search with one geo point and radius in kilometers

Java
NodeJS
Python
cURL
Javascript (REST)
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
6
7
MultiSearchResponse postAnnotationsSearchesResponse = stub.postAnnotationsSearches(
8
PostAnnotationsSearchesRequest.newBuilder().addSearches(
9
Search.newBuilder().setQuery(
10
Query.newBuilder().addFilters(
11
Filter.newBuilder().setAnnotation(
12
Annotation.newBuilder().setData(
13
Data.newBuilder().setGeo(
14
Geo.newBuilder()
15
.setGeoPoint(
16
GeoPoint.newBuilder()
17
.setLongitude(-29)
18
.setLatitude(40)
19
)
20
.setGeoLimit(
21
GeoLimit.newBuilder()
22
.setType("withinKilometers")
23
.setValue(150.0f)
24
)
25
)
26
)
27
)
28
)
29
)
30
)
31
.build()
32
);
33
34
if (postAnnotationsSearchesResponse.getStatus().getCode() != StatusCode.SUCCESS) {
35
throw new RuntimeException("Post annotations searches failed, status: " + postAnnotationsSearchesResponse.getStatus());
36
}
37
38
System.out.println("Found inputs " + postAnnotationsSearchesResponse.getHitsCount() + ":");
39
for (Hit hit : postAnnotationsSearchesResponse.getHitsList()) {
40
System.out.printf("\tScore %.2f for annotation % of input %s\n", hit.getScore(), hit.getAnnotation().getId(), hit.getInput().getId())
41
}
Copied!
1
// Insert here the initialization code as outlined on this page:
2
// https://docs.clarifai.com/api-guide/api-overview
3
4
stub.PostAnnotationsSearches(
5
{
6
searches: [
7
{
8
query: {
9
filters: [
10
{
11
annotation: {
12
data: {
13
geo: {
14
geo_point: {
15
longitude: -29,
16
latitude: 40
17
},
18
geo_limit: {
19
type: "withinKilometers",
20
value: 150.0
21
}
22
}
23
}
24
}
25
}
26
]
27
}
28
}
29
]
30
},
31
metadata,
32
(err, response) => {
33
if (err) {
34
throw new Error(err);
35
}
36
37
if (response.status.code !== 10000) {
38
throw new Error("Post annotations searches failed, status: " + response.status.description);
39
}
40
41
console.log("Search result:");
42
for (const hit of response.hits) {
43
console.log("\tScore " + hit.score + " for annotation: " + hit.annotation.id + " of input: ", hit.input.id);
44
}
45
}
46
);
Copied!
1
from clarifai_grpc.grpc.api import service_pb2, resources_pb2
2
from clarifai_grpc.grpc.api.status import status_code_pb2
3
4
# Insert here the initialization code as outlined on this page:
5
# https://docs.clarifai.com/api-guide/api-overview
6
7
post_annotations_searches_response = stub.PostAnnotationsSearches(
8
service_pb2.PostAnnotationsSearchesRequest(
9
searches = [
10
resources_pb2.Search(
11
query=resources_pb2.Query(
12
filters=[
13
resources_pb2.Filter(
14
annotation=resources_pb2.Annotation(
15
data=resources_pb2.Data(
16
geo=resources_pb2.Geo(
17
geo_point=resources_pb2.GeoPoint(
18
longitude=-29.0,
19
latitude=40.0,
20
),
21
geo_limit=resources_pb2.GeoLimit(
22
type="withinKilometers",
23
value=150.0
24
)
25
)
26
)
27
)
28
)
29
]
30
)
31
)
32
]
33
),
34
metadata=metadata
35
)
36
37
if post_annotations_searches_response.status.code != status_code_pb2.SUCCESS:
38
print("There was an error with your request!")
39
print("\tCode: {}".format(post_annotations_searches_response.outputs[0].status.code))
40
print("\tDescription: {}".format(post_annotations_searches_response.outputs[0].status.description))
41
print("\tDetails: {}".format(post_annotations_searches_response.outputs[0].status.details))
42
raise Exception("Post searches failed, status: " + post_annotations_searches_response.status.description)
43
44
print("Search result:")
45
for hit in post_annotations_searches_response.hits:
46
print("\tScore %.2f for annotation: %s off input: %s" % (hit.score, hit.annotation.id, hit.input.id))
Copied!
1
#
2
# Value of 0 will search for images that don't have the concept.
3
#
4
# Instead of "id" you can search by "name" as well.
5
6
curl -X POST \
7
-H "Authorization: Key YOUR_API_KEY" \
8
-H "Content-Type: application/json" \
9
-d '
10
{
11
"searches": [
12
{
13
"query": {
14
"filters": [
15
{
16
"annotation": {
17
"data": {
18
"geo": {
19
"geo_point": {
20
"longitude": -29.0,
21
"latitude": 40.0
22
},
23
"geo_limit": {
24
"type": "withinKilometers",
25
"value": 150
26
}
27
}
28
}
29
}
30
}
31
]
32
}
33
}
34
]
35
}'\
36
https://api.clarifai.com/v2/annnotations/searches
Copied!
1
const raw = JSON.stringify({
2
"user_app_id": {
3
"user_id": "{YOUR_USER_ID}",
4
"app_id": "{YOUR_APP_ID}"
5
},
6
"searches": [
7
{
8
"query": {
9
"filters": [
10
{
11
"annotation": {
12
"data": {
13
"geo": {
14
"geo_point": {
15
"longitude": -29.0,
16
"latitude": 40.0
17
},
18
"geo_limit": {
19
"type": "withinKilometers",
20
"value": 150
21
}
22
}
23
}
24
}
25
}
26
]
27
}
28
}
29
]
30
});
31
32
const requestOptions = {
33
method: 'POST',
34
headers: {
35
'Accept': 'application/json',
36
'Authorization': 'Key {YOUR_PERSONAL_TOKEN}'
37
},
38
body: raw
39
};
40
41
fetch(`https://api.clarifai.com/v2/annnotations/searches`, requestOptions)
42
.then(response => response.text())
43