API Endpoint Access URL
https://api.pixlab.io/tagimg
Get Your API Key & Try TAGIMG Now ↗Description
Generate human-readable, comma-separated image descriptions. This API endpoint uses advanced image labeling to produce multiple English descriptions, each with a confidence score. Ideal for developers and creators, TAGIMG analyzes visual content using a state-of-the-art algorithm and returns ranked descriptions based on their confidence scores.
HTTP Methods
GET, POST
HTTP Parameters
Required
Fields | Type | Description |
---|---|---|
img |
URL | Input media URL. If you want to upload your image directly from your app, then submit a multipart/form-data POST request. |
key |
String | Your PixLab API Key ↗. You can also embed your key in the WWW-Authenticate: HTTP header and omit this parameter if you want to. |
POST Request Body
Use this if you plan to use POST instead of a simple GET request.
Allowed Content-Types:
multipart/form-data
application/json
Use multipart/form-data
if you want to upload your media file directly (refer to the REST API code samples or The PixLab Github Repository↗ for a working example). If you are using JSON, then the media file must be already uploaded somewhere. Call store if you want to upload an image before invoking this endpoint.
HTTP Response
application/json
This endpoint returns a JSON response containing image tag data. The
tags
array contains detected tags with their name & confidence
scores. Response fields include:Fields | Type | Description |
---|---|---|
status |
Integer | HTTP 200 indicates success. Any other code indicates failure. |
tags |
Array | Contains detected tags with name & confidence values. |
error |
String | Error description when status != 200. |
Code Samples
import requests
import json
# Tag an image based on detected visual content which mean running a CNN on top of it.
# Target Image: Change to any link or switch to POST if you want to upload your image directly, refer to the REST API code samples for more info.
img = 'https://pixlab.io/assets/images/nature31.jpg'
key = 'PIXLAB_API_KEY' # Get your API key from https://console.pixlab.io/
req = requests.get('https://api.pixlab.io/tagimg',params={'img':img,'key':key})
reply = req.json()
if reply['status'] != 200:
print (reply['error'])
else:
total = len(reply['tags']) # Total tags
print(f"Total tags: {total}")
for tag in reply['tags']:
print(f"Tag: {tag['name']} - Confidence: {tag['confidence']}")
// Tag an image based on detected visual content which mean running a CNN on top of it.
// https://pixlab.io/endpoints/tagimg for more info.
// Target Image: Change to any link or switch to POST if you want to upload your image directly, refer to the REST API code samples for more info.
const img = 'https://pixlab.io/assets/images/nature31.jpg';
// Your PixLab key
const key = 'PIXLAB_API_KEY';
fetch(`https://api.pixlab.io/tagimg?img=${encodeURIComponent(img)}&key=${encodeURIComponent(key)}`)
.then(response => response.json())
.then(reply => {
if (reply.status !== 200) {
console.log(reply.error);
} else {
const total = reply.tags.length; // Total tags
console.log(`Total tags: ${total}`);
reply.tags.forEach(tag => {
console.log(`Tag: ${tag.name} - Confidence: ${tag.confidence}`);
});
}
})
.catch(error => console.error('Error:', error));
<?php
$img = 'https://pixlab.io/assets/images/nature31.jpg';
$key = 'PIXLAB_API_KEY';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.pixlab.io/tagimg?img=' . urlencode($img) . '&key=' . urlencode($key));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$reply = json_decode($response, true);
if ($reply['status'] != 200) {
echo $reply['error'];
} else {
$total = count($reply['tags']);
echo "Total tags: " . $total . "\n";
foreach ($reply['tags'] as $tag) {
echo "Tag: " . $tag['name'] . " - Confidence: " . $tag['confidence'] . "\n";
}
}
require 'net/http'
require 'uri'
require 'json'
# Tag an image based on detected visual content which means running a CNN on top of it.
# https://pixlab.io/endpoints/tagimg for more info.
# Target Image: Change to any link or switch to POST if you want to upload your image directly, refer to the REST API code samples for more info.
img = 'https://pixlab.io/assets/images/nature31.jpg'
# Your PixLab key
key = 'PIXLAB_API_KEY'
uri = URI.parse('https://api.pixlab.io/tagimg')
params = { img: img, key: key }
uri.query = URI.encode_www_form(params)
response = Net::HTTP.get_response(uri)
reply = JSON.parse(response.body)
if reply['status'] != 200
puts reply['error']
else
total = reply['tags'].length # Total tags
puts "Total tags: #{total}"
reply['tags'].each do |tag|
puts "Tag: #{tag['name']} - Confidence: #{tag['confidence']}"
end
end
Similar API Endpoints
bg-remove, nsfw, sfw, docscan, describe, docscan, crop, mogrify, facelookup ↗, faceverify ↗, screencapture