
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
The official JavaScript client for interacting with the Clarifai API.
To start, install the SDK via NPM: npm install clarifai
and initialize with your clientId and
clientSecret:
This will work in node.js and browsers via Browserify
var Clarifai = require('clarifai');
Clarifai.initialize({
'clientId': '{clientId}',
'clientSecret': '{clientSecret}'
});
You can also use the SDK by adding this script to your HTML:
<script type="text/javascript" src="https://sdk.clarifai.com/js/clarifai-1.2.1.js"></script>
<script>
Clarifai.initialize({
'clientId': '{clientId}',
'clientSecret': '{clientSecret}'
});
</script>
Clarifai.getTagsByUrl('https://samples.clarifai.com/wedding.jpg').then(
handleResponse,
handleError
);
Clarifai.getTagsByUrl([
'https://samples.clarifai.com/wedding.jpg',
'https://samples.clarifai.com/cookies.jpeg'
]).then(
handleResponse,
handleError
);
Clarifai.getTagsByImageBytes('R0lGODlhZAHIAPcAAKeno6Oinc3Do6iVeMe7o1ZEM...').then(
handleResponse,
handleError
);
Clarifai.getTagsByUrl('https://samples.clarifai.com/wedding.jpg', {
'model': 'nsfw-v0.1'
}).then(
handleResponse,
handleError
);
Clarifai.getTagsByUrl('https://samples.clarifai.com/wedding.jpg', {
'language': 'es'
}).then(
handleResponse,
handleError
);
Clarifai.getTagsByUrl('https://samples.clarifai.com/wedding.jpg', {
'localId': 'myLocalId'
}).then(
handleResponse,
handleError
);
Clarifai.getTagsByUrl(
'https://samples.clarifai.com/wedding.jpg',
{
'selectClasses': ['people', 'dress', 'wedding']
}
).then(
handleResponse,
handleError
);
Clarifai.getInfo().then(
handleResponse,
handleError
);
Clarifai.getLanguages().then(
handleResponse,
handleError
);
Clarifai.getColorsByUrl('https://samples.clarifai.com/wedding.jpg').then(
handleResponse,
handleError
);
Clarifai.getColorsByImageBytes('R0lGODlhZAHIAPcAAKeno6Oinc3Do6iVeMe7o1ZEM...').then(
handleResponse,
handleError
);
Clarifai.getUsage().then(
handleResponse,
handleError
);
Clarifai.createFeedback('https://samples.clarifai.com/wedding.jpg', {
'addTags': ['family', 'friends',],
'removeTags': ['military', 'protest'],
}).then(
handleResponse,
handleError
);
Note: You should not have to call this directly in most cases. Any method that needs a token will call it for you.
Clarifai.getToken().then(
function(response) {
console.log(response);
},
function(err){
console.log(err);
}
);
var tokenSetBoolean = Clarifai.setToken('some-token-string');
Clarifai.deleteToken();
All methods return promises. If you'd rather user callbacks, just pass in a callback function as the last
param to any method. If there are multiple params and some are optional, you'll need to pass in null
for
those.
FAQs
Official Clarifai Javascript SDK
The npm package clarifai receives a total of 1,953 weekly downloads. As such, clarifai popularity was classified as popular.
We found that clarifai demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.