1. API
  2. getLabels (image file)

API

getLabels (image file)

Get Labels from a raw image file.

📝 Notes

🌐 - Endpoint : https://name.pulsr.ai/v1/getLabels

🔑 - Your API key may be passed either via Header X-PULSR-API-KEY or by URL parameter ?key=. If you need an API key, please use our developer dashboard to set one up.

🖼️ - Supported image file-types include:

        ("image/jpeg", "image/png", "image/gif", "image/bmp", "image/webp", "image/tiff", "image/apng", "video/png", "image/avif")

      

🚀 How To

Make a POST request to the endpoint https://name.pulsr.ai/v1/getLabels where:

  • Your image file is passed into the raw request body (as a buffer).
  • Your API key is supplied via either X-PULSR-API-KEY request header or in the ?=key query parameter.

💻 Code Example

        Node-JS

import fetch from 'node-fetch';
import fs from 'fs';
import { fileTypeFromBuffer } from 'file-type' ;

const imageFile = fs.readFileSync('./pretty-image.jpg') // Loads a file in as a buffer
const fileType = await fileTypeFromBuffer(imageFile) // To procedurally determine image's mime-type

const url = 'https://name.pulsr.ai/v1/getLabels';
const options = {
  method: 'POST',
  headers: {
    'accept': 'application/json',
    'X-PULSR-API-KEY': 'a479a23e-0ab8-4d8f-92a6-6c6f7abc8ec8',
    'Content-Type':fileType.mime
  },
  body:imageFile
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error('error:' + err));

/* Example Response:
{
  status: 'Found [10] labels',
  labels: [
    { label: 'Painting', confidence: 0.8551178574562073 },
    { label: 'Art', confidence: 0.840040922164917 },
    { label: 'Moon', confidence: 0.8284549713134766 },
    { label: 'Font', confidence: 0.7884792685508728 },
    { label: 'Building', confidence: 0.7527179718017578 },
    { label: 'Illustration', confidence: 0.7186647653579712 },
    { label: 'Event', confidence: 0.7184750437736511 },
    { label: 'Drawing', confidence: 0.716280460357666 },
    { label: 'Monochrome', confidence: 0.7114292979240417 },
    { label: 'Visual arts', confidence: 0.6705154180526733 }
  ],
  labelsFound: true
}
*/