Manage Concepts | Clarifai Docs
Learn how to get, update, and delete concepts
Delete Concepts
We currently do not support deleting concepts solitarily since they have such an integral tie across almost all other data structures in the platform, like inputs, models, searches, etc.
Via the API
Get
Get Concept by ID
Below is an example of how to get a single concept by its ID.
- Python (gRPC)
- JavaScript (REST)
- Node.js (gRPC)
- Java (gRPC)
- PHP (gRPC)
- cURL
###########################################################################
# In this section, we set the user authentication, app ID, and concept 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'
# Change this to whatever concept you want to retrieve
CONCEPT_ID = 'cat'
##########################################################################
# 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)
get_concepts_response = stub.GetConcept(
service_pb2.GetConceptRequest(
user_app_id=userDataObject,
concept_id=CONCEPT_ID
),
metadata=metadata
)
if get_concepts_response.status.code != status_code_pb2.SUCCESS:
print(get_concepts_response.status)
raise Exception("Get concept failed, status: " + get_concepts_response.status.description)
print(get_concepts_response)
<!--index.html file-->
<script>
////////////////////////////////////////////////////////////////////////////////////
// In this section, we set the user authentication, app ID, and concept 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';
// Change these to whatever concepts you want to process
const CONCEPT_ID = 'cat';
///////////////////////////////////////////////////////////////////////////////////
// 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 + "/concepts/" + CONCEPT_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 concept 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';
// Change these to whatever concepts you want to process
const CONCEPT_ID = 'cat';
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.GetConcept(
{
user_app_id: {
"user_id": USER_ID,
"app_id": APP_ID
},
concept_id: CONCEPT_ID
},
metadata,
(err, response) => {
if (err) {
throw new Error(err);
}
if (response.status.code !== 10000) {
throw new Error("Get concepts failed, status: " + response.status.description);
}
const concept = response.concept;
console.log(JSON.stringify(concept, 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 concept 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";
// Change this to whatever concept you want to retrieve
static final String CONCEPT_ID = "charlie";
public static void main(String[] args) {
V2Grpc.V2BlockingStub stub = V2Grpc.newBlockingStub(ClarifaiChannel.INSTANCE.getGrpcChannel())
.withCallCredentials(new ClarifaiCallCredentials(PAT));
SingleConceptResponse getConceptResponse = stub.getConcept(
GetConceptRequest.newBuilder()
.setUserAppId(UserAppIDSet.newBuilder().setUserId(USER_ID).setAppId(APP_ID))
.setConceptId(CONCEPT_ID)
.build()
);
if (getConceptResponse.getStatus().getCode() != StatusCode.SUCCESS) {
throw new RuntimeException("Get concepts failed, status: " + getConceptResponse.getStatus());
}
Concept concept = getConceptResponse.getConcept();
System.out.println(concept);
}
}
<?php
require __DIR__ . "/vendor/autoload.php";
$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 this to whatever concept you want to retrieve
$CONCEPT_ID = "cat";
use Clarifai\