Here's an example of how to call clarifai V1 APIs (URL) from a Windows batch file. You'll need to install curl
and jq
. jq is like xpath
for json. This example demonstrates general-v1.3
and nsfw-v1.0
models. I use curl
to test new APIs.
set client_id=<your client id>
set client_secret=<your client secret>
curl -X POST "https://api.clarifai.com/v1/token/" -d "client_id=%client_id%" -d "client_secret=%client_secret%" -d "grant_type=client_credentials" > curl-oauth-result.txt
jq -r ".access_token" curl-oauth-result.txt > bearer.txt
set /p bearer= < bearer.txt
curl "https://api.clarifai.com/v1/tag/?model=nsfw-v1.0&url=%1" -H "Authorization: Bearer %bearer%" > curl-nsfw-result.txt
jq -r ".results[0].result.tag.probs[0]" < curl-nsfw-result.txt
curl "https://api.clarifai.com/v1/tag/?model=general-v1.3&url=%1" -H "Authorization: Bearer %bearer%" > curl-general-result.txt
jq -r ".results[0].result.tag.classes" < curl-general-result.txt