Batch Image Synchronous Moderation

Parameter Specification

  • Request URL:

https://isafe.ilivedata.com/api/v1/image/batchCheck

  • Image requirements:

    • Supported types: URL, BASE64
    • Supported formats: jpg, png, bmp, gif, webp, tiff, heic;
    • Supported image size: <10M;
    • Description of gif/long image: Automatically cut gif/long image into frame and check, up to 5 images. Gif/long images are billed according to the actual number of screenshots; Definition of long image: images whose ratio of length and width is greater than 5.
  • HTTP request Header:

Header Value Description
Content-Type application/json;charset=UTF-8 Request body type
Accept application/json;charset=UTF-8 Return type accepted
X-AppId The only identifier of the project or application.
X-TimeStamp The UTC timestamp of the request. Timestamps need to be formatted according to W3C standards, for example: 2010-01-31T23:59:59Z. (http://www.w3.org/TR/xmlschema-2/#dateTime)
Authorization Signature value
  • Request method:POST

  • Request body JSON object:

Parameter Required Type Description
images Required json array array length does not exceed 20
Subparameter Required Type Description
type Required Number 1: Image URL 2: Image BASE64 value
image Required String Image content, if type=1, then the value is the image URL, if type=2, then the value is the image BASE64 value.
strategyId Optional String Strategy ID, if empty, use DEFAULT Strategy
referImage Optional String Used for face comparison. The referImage type needs to be the same as image type. If image is a url, referImage must also be a url. Supported formats: jpg, png;Supported image size: <10M;
userId Optional String nique end user ID. The user ID should be no more than 32 characters.
userIP Optional String User IP address
did Optional String User device ID
dtype Optional String User device type:1:iPhone 2:android 3: ipad 4:wphone 5: pc 6:web 7:wap
id Optional String Extended field, can be used as identifier and transparently transmitted.
extra Optional json Extended fields, can pass multiple keys and values transparently. For example, pass two parameters: game server and game version: “extra” : {“server”: “123”,“version”:“456”}
  • Example of request body:

      {
      "images": [
        {
        "type":2,
        "image":"T2dnUwACAAAAAAAAAAAd8pVTAAAAAGsIvpMBE...",
        "strategyId": "123",  //非必传,如为空,则调用默认策略
        "userId": "testUser1",
        "did": "868034031518269",
        "dtype": "1"
        },
        {
        "type":2,
        "image":"T2dnUwACAAAAAAAAAAAd8pVTAAAAAGsIvpMBE...",
        "strategyId": "456",  //非必传,如为空,则调用默认策略
        "userId": "testUser2",
        "did": "868034031518267",
        "dtype": "2"
        }
       ]
      }
    
  • Request signature:

When the user requests the Image Check API, the request can be signed with the appId and secretKey (obtained from the Console - Service Configuration). When the API receives the request with the signature information, it will verify the signature using the same algorithm, and if the signature is found to be inconsistent, the API will return 401 error to the user.

If the API validation signature is consistent and the user corresponding to the appId has permission to operate the requested resource, the request succeeds, otherwise the API returns 401 error.

  • Request Header to send a signature via HTTP

Method: Add a header named Authorization in the request, whose value is the signature value. For example:

 Authorization: ****
  • Signature calculation method
  1. Canonicalized Query String:

Convert the request body JSON string to a hexadecimal string (not Base64) by doing sha256 encoding with UTF-8 character encoding.

CanonicalizedQueryString = hex(sha256(jsonBody))

  1. Constructs the signed string StringToSign ("\n" stands for ASCII newline character):

    StringToSign = HTTPMethod + “\n” + HostHeaderInLowercase + “\n” + HTTPRequestURI + “\n” + CanonicalizedQueryString < Get from previous step> + “\n” + “X-AppId:” + SAME_APPID_IN_HEADER + “\n” + “X-TimeStamp:” + SAME_TIMESTAMP_IN_HEADER

The HTTPRequestURI is the absolute path to the request URI, without the request string. If the HTTPRequestURI is empty, also keep a forward slash (/).

The hash-based message authentication code (HMAC) is created using the HMAC-SHA256 protocol and the signature is calculated.

For more information about HMAC, see: https://tools.ietf.org/html/rfc2104

  1. StringToSign as the signature string, secretKey as the secret key and SHA256 as the hash algorithm.

  2. Converting the results of the previous step to a BASE64 string.

  3. Put the BASE64 string into the Authorization of HTTP request Header.

  • Example of signature

Below is an example of appId & secretKey & image.

appId=***
secrectKey=****
image_base64="T2dnUwACAAAAAAAAAAAd8pVTAAAAAGsIvpMBE..."

Below is an example of request type.

{
 "type": 2,
 "userId": "12345678",
 "image": "T2dnUwACAAAAAAAAAAAd8pVTAAAAAGsIvpMBE..."
}

Generate CanonicalizedQueryString

b3ad8e9d16439ccd5e91924d2516bf9592975003f69beff44e56cddf47bd3118

Generate StringToSign

POST
isafe.ilivedata.com
/api/v1/image/check
b3ad8e9d16439ccd5e91924d2516bf9592975003f69beff44e56cddf47bd3118
X-AppId:***
X-TimeStamp:2020-07-31T07:59:03Z

Signatures from HMAC calculations

****

HTTP Response

Content-Type: application/json;charset=UTF-8

The result is in JSON format, please refer to the following example.

Description of returning json field: A json array consisting of a single image result json object.

Parameter
Type
Description
errorCode Number Error code: 0 means success
errorMessage String Error message
imageSpam json array Resut message
code Number Status code, defined as: 0: successful detection, 1: image download failed, 2: image format error, 3: other
result Number 0: Pass, 1: Recommended for review, 2: Fail
taskId String Task ID

imageSpams:

Parameter
Type
Description
code Number Status code, defined as: 0: successful detection, 1: image download failed, 2: image format error, 3: other
result Number 0: Pass, 1: Recommended for review, 2: Fail
tags json array Classified information

extraInfo:

Parameter Type Description
cartoonScore Number Score for cartoon style, 0-100, the higher the score, the closer to the cartoon style
genderResult json array Gender and its confidence
Subparameter Type Description
gender String male/female
confidence Number Gender confidence
numHuman Number Number of human
numFace Number Number of face

tags:

Parameter
Type
Description
tag Number Tags meaning:
100:Politics, 110:Violence, 120:Prohibited, 130:porn, 140:sexy, 150:ad, 160:values, 180:minor, 190:tamper, 200:QR code, 230:no human face, 232:picture quality, 300:logo, 400:ocr, 666:disgust, 800:label, 900:others, 999:customize
level Number Classification level, 0: normal, 1: suspected, 2: abnormal
confidence Number Confidence score: values between 0-100. 100 is the highest confidence level, and 0 is the lowest confidence level. If the level is suspected or abnormal, the greater the confidence level, the higher the possibility of spam
tagName String Detect first-level type names for image hits
tagNameEn String Detect first-level type names for image hits(English)
subTags json object Secondary classification of sensitive information

subTags:

Parameter
Type
Description
subTag Number Secondary classification information reference Classification Code
subTagName String Detect secondary type names for iamge hits
subTagNameEn String Detect secondary type names for image hits(English)
level Number Classification level, 0: normal, 1: suspected, 2: abnormal
confidence Number Confidence score: values between 0-100. 100 is the highest confidence level, and 0 is the lowest confidence level. If the level is suspected or abnormal, the greater the confidence level, the higher the possibility of spam
wordList array of strings OCR only (tag=400)
  • Example of response:

      [{
      "errorCode": 0,
      "code": 0,
      "result": 2,
      "imageSpams": [{
              "code": 0,
              "result": 2,
              "tags": [{
                      "tag": 232,
                      "level": 2,
                      "confidence": 100,
                      "tagName": "图片质量",
                      "tagNameEn": "",
                      "subTags": [{
                              "subTag": 232003,
                              "subTagName": "是否上半身",
                              "subTagNameEn": "is portrait",
                              "level": 2,
                              "confidence": 100
                      }]
              }]
      }],
      "ocr": ["K+A", "", ""],
      "gender": [],
      "labels": [],
      "taskId": "nxtest_f39c3e4ba3f6433696b080e91c99afdf_1699441805955",
      "extraInfo": {
              "cartoonScore": 9,
              "genderResult": [],
              "numHuman": 0,
              "numFace": 0
      },
      "isOcr": 1
      }, {
      "errorCode": 0,
      "code": 0,
      "result": 2,
      "grade": 4,
      "imageSpams": [{
              "code": 0,
              "result": 2,
              "tags": [{
                      "tag": 130,
                      "level": 2,
                      "confidence": 100,
                      "tagName": "色情",
                      "tagNameEn": "",
                      "subTags": [{
                              "subTag": 130001,
                              "subTagName": "女胸裸露",
                              "subTagNameEn": "bare breasts",
                              "level": 2,
                              "confidence": 100
                      }, {
                              "subTag": 130003,
                              "subTagName": "男下体",
                              "subTagNameEn": "dick",
                              "level": 2,
                              "confidence": 99
                      }]
              }, {
                      "tag": 232,
                      "level": 2,
                      "confidence": 85,
                      "tagName": "图片质量",
                      "tagNameEn": "",
                      "subTags": [{
                              "subTag": 232003,
                              "subTagName": "是否上半身",
                              "subTagNameEn": "is portrait",
                              "level": 2,
                              "confidence": 85
                      }]
              }]
      }],
      "ocr": [""],
      "gender": [],
      "labels": [{
              "nameEn": "female",
              "name": "女性"
      }],
      "taskId": "nxtest_a868a01f9d8a45648df79a03cfa25bcb_1699441805955",
      "extraInfo": {
              "cartoonScore": 4,
              "genderResult": [],
              "numHuman": 1,
              "numFace": 4
      },
      "isOcr": 1
      }]
    

Error Code

Http Status code Error code Error message
200 0 This field is omitted
405 1004 Method Not Allowed
411 1007 Not Content Length
400 1002 API Not Found
400 1003 Bad Request
401 1102 Unauthorized Client
401 1106 Missing Access Token
401 1107 Invalid Token
401 1108 Expired Token
401 1110 Invalid Client
401 2000 Missing Parameter
401 2001 Invalid Parameter