TAGIMG API Endpoint

Version 2.197 (Release Notes ↗)

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']}")
← Return to API Endpoint Listing