Result Query

Function

This API queries the result of a batch image moderation job. If the batch job is executed successfully, the detailed moderation result of each image is returned. The batch job will not fail upon the failure of a single image.

The jobs will be stored on the cloud for a maximum of 30 minutes. You are advised to perform a periodic query every 30 seconds after the batch job is submitted.

Prerequisites

Before using Text Moderation, you need to apply for the service and complete authentication. For details, see Getting Started with Moderation (Image).

URI

URI format

GET /v1.0/moderation/image/batch?job_id={job_id}

Request Message

Table 1 describes the request parameters.

Table 1 Request parameters

Parameter

Mandatory

Type

Description

job_id

Yes

String

Indicates the job ID.

Response Message

Table 2 describes the response parameters.

Table 2 Response parameters

Parameter

Type

Description

result

Object

Indicates the calling result when the API is successfully called. For details about the parameters in the result and their formats, see Table 3.

This parameter is not included when the API fails to be called.

items

Array

Indicates the list of image moderation results. For details about the parameters in the result and their formats, see Table 4.

error_code

String

Indicates the error code returned when the API fails to be called. For details about the error code, see Error Codes.

This parameter is not included when the API is successfully called.

error_msg

String

Indicates the error message of a failed API call.

This parameter is not included when the API is successfully called.

Table 3 result parameters

Parameter

Type

Description

job_id

String

Indicates the job ID.

status

String

Indicates the job status. Possible values are as follows:

created: indicates that a job is created.

running: indicates that a job is being processed.

finish: indicates that a job is completed.

failed: indicates that a job fails to be processed.

create_time

String

Indicates the time when a job is created. For example, 2018-01-02T15:03:04Z.

update_time

String

Indicates the time when a job is updated. For example, 2018-01-02T15:03:04Z.

Table 4 items parameters

Parameter

Type

Description

url

String

Indicates the URL of an image.

suggestion

String

For details, see the suggestion parameter in Table 2.

detail

Object

For details, see the detail parameter in Table 2.

confidence

Number

For details, see the confidence parameter in Table 2.

face_detail

List

For details, see the face_detail parameter in Table 2.

label

String

For details, see the label parameter in Table 2.

Examples

  • Example request
    GET https://moderation.cn-north-1.myhuaweicloud.com/v1.0/moderation/image/batch?job_id={job_id} 
    
    Request Header:   
    Content-Type:application/json 
    X-Auth-Token: MIINRwYJKoZIhvcNAQcCoIINODCCDTQCAQExDTALBglghkgBZQMEAgEwgguVBgkqhkiG...
  • Example successful response (processing)
    {
       "result":{
          "job_id": "53ba32e2-c96a-4d0a-a1df-6ddc75f40aed",
          "status": "running",
          "create_time": "2018-11-22T06:17:09Z",
          "update_time": "2018-11-22T06:17:16Z"
        }
    }
  • Example successful response (processed)
    {
       "result": {
          "job_id": "44d93b70-db01-4f96-a618-2a79c964c4b2",
          "status": "finish",
          "create_time": "2018-01-02T15:03:04Z",
          "update_time": "2018-01-02T15:03:04Z",
          "items": [
          {
            "url": "https://obs-test-llg.obs.myhuaweicloud.com/terrorism",
            "suggestion": "pass",
            "detail": {
              "politics": [],
              "terrorism": [
                {
                  "confidence": 0,
                  "label": "fire"
                },
                {
                  "confidence": 0.0268,
                  "label": "normal"
                }
              ]
            }
          },
          {
            "url": "https://obs-test-llg.obs.myhuaweicloud.com/clarity-detect",
            "suggestion": "pass",
            "detail": {
              "politics": [],
              "terrorism": [
                {
                  "confidence": 0,
                  "label": "knife"
                },
                {
                  "confidence": 0,
                  "label": "terrorist"
                },
                {
                  "confidence": 0.3086,
                  "label": "bloody"
                },
                {
                  "confidence": 0.6914,
                  "label": "normal"
                }
              ]
            }
          }
        ]
       }
    }
  • Example failed response
    {
        "error_code": "AIS.0005",
        "error_msg": "The service does not exist."
    }

Status Code

  • Normal

    200

  • Abnormal
    Table 5

    Return Value

    Description

    400

    • The request cannot be understood by the server due to malformed syntax. The client should not repeat the request without modifications.
    • The request parameter is incorrect.

    401

    The request requires user authentication.

    403

    No operation permission.

    404

    The server has not found anything matching the Request-URI.

    500

    The server encountered an unexpected condition which prevented it from fulfilling the request.