Result Obtaining Interface

Request specification

  • Request URL:

https://asafe.ilivedata.com/api/v1/liveaudio/check/result

  • Interface description:

The interface is used to obtain the results of live audio detection which include screenshot evidence, prohibited content and its classification.After the detection result is obtained through taskId, the next time it is called, the result data obtained before will not be returned again.

  • HTTP Request Header:
Header Value Description
Content-Type application/json;charset=UTF-8 Request body type
Accept application/json;charset=UTF-8 Accepted return type
X-AppId The only identifier of the project or application.
X-TimeStamp UTC Timestamp of the request, which needs to be normalized in accordance with 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 Necessity Type Description
taskId Required String The taskId to which we return after calling successfully the live audio submission interface
  • Example of request body:

    JSON response

      {
      "taskId": "f67fee0890de4c118d4f672b7c8ee304"
      }
    
  • Request signature:

When the user requests the Live Audio result API, the request can be signed with the appId and secretKey (obtained from the “Console - Service Configuration”). When the API receives the request with 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 will return 401 error.

  • Send signatures via HTTP Request Headers

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

 Authorization: Njl86M/jY6zZaZoGhZdGO+GI/8+yGFECusGH1yQHUFE=
  • 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 + “\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.

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

    For more information about HMAC, see: https://tools.ietf.org/html/rfc2104。
    
  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 & taskId.

appId=1000
secrectKey=d9e23d93053f49ade2f8fce185acedd4
taskId=f67fee0890de4c118d4f672b7c8ee304

Below is an example of request body.

{
 "taskId": "f67fee0890de4c118d4f672b7c8ee304"
  }

   

Generate CanonicalizedQueryString

b3ad8e9d16439ccd5e91924d2516bf9592975003f69beff44e56cddf47bd3118

Generate StringToSign

 POST
 asafe.ilivedata.com
 /api/v1/audio/check/result
 b3ad8e9d16439ccd5e91924d2516bf9592975003f69beff44e56cddf47bd3118
 X-AppId:1000
 X-TimeStamp:2020-07-31T07:59:03Z

Signatures from HMAC calculations

H0ZXsKUaiRotpxSiXW6+RgKRwnxHXy3qwlVzavs9iHo=

HTTP Response

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

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

  • HTTP response

Description of returning json field:

Field name Type Description
errorCode Number Error code: 0 means success
errorMessage String Error message
audioSpams json array result information of Live audio detection (if there is no result,the array is empty

audioSpams:

Field name Type Description
code Number 状态码:0:successful detection,1:failed detection,2:detecting
taskId String taskid when requested
result Number 0: Passed, 1: recommended for review, 2: not passed
startTime Number The start time of the hit audio segment, in milliseconds
endTime Number The end time of the hit audio segment, in milliseconds
tags json array Classified information

tags:

Field name Type Description
tag Number Classified information:
100: politics, 110: violence, 120: prohibited, 130: eroticism, 150: advertisement, 160: insults,
170: Hate speech, 180: Minor protection, 190: sensitive hot spots,
220:private transaction,900: other, 999: customization
tagName String Detect first-level type names
tagNameEn String Detect first-level type names (English)
level Numeber Classification level,0:normal,1:suspected,2:abnormal
subTags json array details

subTags:

Field name Type Description
subTag Number Secondary classification information reference Classification Code
subTagName String Detect secondary type names
subTagNameEn String Detect secondary type names (English)
wordList array of strings hit details
  • 响应示例:

    JSON response

      {
          "errorCode": 0,
          "audioSpams": [{
          "code": 2,
          "result": 1,
          "taskId": "nxtest_live_c06304b5-ddfa-4110-8811-410f815f383b_1598848305027",
              "startTime": 1598848711002,
              "endTime": 1598848711482,
              "startTime":6,
              "url": "https://rcs-test.s3.cn-northwest-1.amazonaws.com.cn/rcs/91100001/liveaudio/2022/07/27/Telnet-test_c1178693-8133-4b1c-bb3f-9e85c99935ff_1658910064584/live_audio_segment-82.ts",
              "language":"zh-CN",
              "tags": [{
              "tag": 900,
              "level": 1,
              "details": ["有病"]
          }]
          }]
      }
    

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