Image Tagging API

Filestack provides a simple interface for getting image tags from the Google Vision API. You can auto-analyze the content of an image and find out what's in the image, or find out whether an image contains any offensive material (whether the image is safe for work or not). Note: A valid Filestack security policy and signature is required in order to request tags or SFW status.

Auto-tagging URL Format:
https://cdn.filestackcontent.com/tags/security=policy:policy,signature:signature/Filestack_FileLink_Handle
tags
String

The root task cannot be abbreviated.

This task specifies that you want to get the tags for an image.

security=policy:your_base64_encoded_policy
String

Can be abbreviated as p:your_base64_encoded_policy

Filestack file policies are URL safe, Base64, JSON parseable strings. To generate a policy, create a json object with the appropriate key value pairs. Then base64 encode it. URL safe is achieved by replacing '+' with '-' and '/' with '_'. Base64 also includes a trailing '=' as padding. You will need to leave this character in the string in order for it to be valid.policy:eyJoYW5kbGUiOiJLVzlFSmhZdFM2eTQ4V2htMlM2RCIsImV4cGlyeSI6MTUwODE0MTUwNH0=

security=signature:your_HMAC-SHA256_hex_encoded_signature
String

Can be abbreviated as s:your_HMAC-SHA256_hex_encoded_signature

The signature is a hex encoded string with lowercase letters. There are common libraries for calculating HMAC-SHA256 on a variety of languages. It is advisable to use a well tested and vetted library as opposed to writing your own. You can also generate policies and signatures in the Filestack developer portal in the Security section with the debugging tool.signature:4098f262b9dba23e4766ce127353aaf4f37fde0fd726d164d944e031fd862c18.

Tagging Example

Original image

Photo to analyze for Auto-tagging

photo taken by jok2000 [GFDL or CC-BY-SA-3.0], via Wikimedia Commons


The first method for submitting a request to get the tags for an image is to pass the image with the /tags/ task as well as the security task accompanied by valid policy and signature.

Request Tags with Policy and Signature:
>>> curl -X GET "https://cdn.filestackcontent.com/tags/security=policy:eyJoYW5kbGUiOiJ1Q2FmTmxscFNBU2VkZlVCdDNiZCIsImV4cGlyeSI6MTU5ODE0MTUwNCwiY2FsbCI6WyJyZWFkIiwic3RhdCIsImNvbnZlcnQiXX0=,signature:2177099fa0fe5fa6c2f2c97aca096003b6b4580b533b4f70b6dcd90dc2f242d9/uCafNllpSASedfUBt3bd"

The second method for submitting a request to get the tags for an image is to pass the image with the tags task and include a "user", which is the word "app" and a "password" which is the "App Secret" that can be found in the Security section of the developer portal under App Secret. Be careful when using this method, as the APP Secret should be secret and not known publicly.

Request Tags with APP Secret Key:
>>> curl -X GET -u "app:TN6MAIP4XZHLFLX7RO2D77X4JU" 'https://cdn.filestackcontent.com/tags/uCafNllpSASedfUBt3bd'

The response you receive will be a JSON Object containing the tag information of the image.

Returned JSON tag object:

{
  "tags": {
    "auto": {
      "accipitriformes": 58,
      "beak": 90,
      "bird": 97,
      "bird of prey": 95,
      "fauna": 84,
      "great grey owl": 89,
      "hawk": 66,
      "owl": 97,
      "vertebrate": 92,
      "wildlife": 81
    },
    "user": null
  }
}
        

SFW Detection

Filestack's SFW detection will tell you whether an image is safe for work, true or false.

Get Safe For Work Status URL Format:
https://cdn.filestackcontent.com/sfw/security=policy:policy,signature:signature/Filestack_FileLink_Handle
sfw
String

The root task cannot be abbreviated.

This task specifies you want to know whether the image contains any offensive content. If the image is safe, the response will be true, if it is not safe for work, the response will be false.

security=policy:your_base64_encoded_policy
String

Can be abbreviated as p:your_base64_encoded_policy

Filestack file policies are URL safe, Base64, JSON parseable strings. To generate a policy, create a json object with the appropriate key value pairs. Then base64 encode it. URL safe is achieved by replacing '+' with '-' and '/' with '_'. Base64 also includes a trailing '=' as padding. You will need to leave this character in the string in order for it to be valid.policy:eyJoYW5kbGUiOiJLVzlFSmhZdFM2eTQ4V2htMlM2RCIsImV4cGlyeSI6MTUwODE0MTUwNH0=

security=signature:your_HMAC-SHA256_hex_encoded_signature
String

Can be abbreviated as s:your_HMAC-SHA256_hex_encoded_signature

The signature is a hex encoded string with lowercase letters. There are common libraries for calculating HMAC-SHA256 on a variety of languages. It is advisable to use a well tested and vetted library as opposed to writing your own. You can also generate policies and signatures in the Filestack developer portal in the Security section with the debugging tool.signature:4098f262b9dba23e4766ce127353aaf4f37fde0fd726d164d944e031fd862c18.

SFW Status Example

Original image

Photo to analyze for Auto-tagging

The same as with the tags task you must pass the image with the /sfw/ task as well as the security task accompanied by valid policy and signature.

Request Tags with Policy and Signature:
>>> curl -X GET "https://cdn.filestackcontent.com/sfw/security=policy:eyJoYW5kbGUiOiJ1Q2FmTmxscFNBU2VkZlVCdDNiZCIsImV4cGlyeSI6MTU5ODE0MTUwNCwiY2FsbCI6WyJyZWFkIiwic3RhdCIsImNvbnZlcnQiXX0=,signature:2177099fa0fe5fa6c2f2c97aca096003b6b4580b533b4f70b6dcd90dc2f242d9/uCafNllpSASedfUBt3bd"

The second method for submitting a request to get the tags for an image is to pass the image with the tags task and include a "user", which is the word "app" and a "password" which is the "App Secret" that can be found in the Security section of the developer portal under App Secret. Be careful when using this method, as the APP Secret should be secret and not known publicly.

Request Tags with APP Secret Key:
>>> curl -X GET -u "app:TN6MAIP4XZHLFLX7RO2D77X4JU" 'https://cdn.filestackcontent.com/sfw/uCafNllpSASedfUBt3bd'

The response you receive will be a JSON Object that states whether the image is safe, true or false. Since the image we tested with is an owl, the response is true.

Returned JSON SFW object:

{
  "sfw": true
}