Batch Check
Update:
Parameter specification
- Request URL
https://tsafe.ilivedata.com/api/v1/text/batchCheck
- HTTP Request Header:
Header
Value
Property
Description
Content-Type
application/json;charset=UTF-8
Required
Request body type
Accept
application/json;charset=UTF-8
Required
Return type accepted
X-AppId
Required
The only identifier of the project or application.
X-TimeStamp
Required
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
Required
Signature value
- Request method
POST
- Request JSON body
Parameter
Property
Type
Description
contents
Required
JSON ARRAY
batch check content items,max count:100
- Content
Parameter
Property
Type
Description
id
Optional
String
Uniquely identifies for item
content
Required
String
The text to be detected. This text is UTF-8 encoded strings with no more than 2048 characters.
strategyId
Optional
String
Policy number. The default policy DEFAULT is used when not passed.
country
Optional
String
country The default policy DEFAUL is used when not passed.
userId
Optional
String
Unique end user ID. The userID should be no more than 64 characters.
userName
Optional
String
User name, nickname. The user name should be no more than 32 characters.
userLevel
Optional
Number
User level
userIp
Optional
String
User IP address
sessionId
Optional
String
sessionId,The sessionId should be no more than 64 characters.
receiverId
Optional
String
receiverId,The receiverId should be no more than 64 characters.
totalPay
Optional
Number
User total payment. Support up to 2 digits after the decimal point.
registrationDate
Optional
Number
User registration date. 10 digit timestamp.
msgCount
Optional
Number
Number of message sent
msgType
Optional
String
Message type
pkgChannel
Optional
String
Package channel
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
checkTags
Optional
array
the type you want to filter
- Example of request body
{
"contents": [
{
"id": "1",
"content": "测试语句1",
"strategyId": "DEFAULT"
},
{
"id": "2",
"content": "测试语句2",
"strategyId": "DEFAULT"
}
]
}
- Request signature:
When the user requests the Text Check API, the request can be signed with the appId and secretKey. 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
- 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))
-
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 HTTP RequestURI 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.
-
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.
-
Converting the results of the previous step to a BASE64 string
-
Put the BASE64 string into the Authorization of HTTP request Header
HTTP Response
Content-Type: application/json;charset=UTF-8
The result is in JSON format, please refer to the following example.
- Example of HTTP response:
Description of returning json field:
Field name
Type
Description
id
String
‘id’ which come from request
errorCode
Number
Error code: 0 means success
textSpam
JSON object
Resut message
taskId
String
Unique identifier to distinguish different calls
startTime
Number
Timestamp, representing the detection text call time
endTime
Number
Timestamp, representing the return time of the detected text result
textSpam:
Field name
Type
Description
content
String
After the detection is complete, sensitive words will change to asterisks if they contain sensitive words, and other content will be returned normally.
result
Number
0: Pass, 1: Recommended for review, 2: Fail
tages
Tag[]
Classified information
wordList
String array
List of sensitive words
Tag:
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,410:Irregular Emoticons, 420:Nickname,300:advertising law,220:private transaction,900: other, 999: customization
tagName
String
Detect first-level type names for text hits
tagNameEn
String
Detect first-level type names for text hits(English)
level
Number
Classification level,0:Normal,1:Suspected,2:Abnormal
confidence
Number
confidence,between 0 and 100,oney when tag=150,confidence is not null; The higher the value, the more likely to be an advertisement
subTags
SubTag[]
Secondary classification of sensitive information
SubTag:
Field name
Type
Describe
subTag
Number
Secondary classification information reference Classification Code
subTagName
String
Detect secondary type names for text hits
subTagNameEn
String
Detect secondary type names for text hits(English)
wordList
array of strings
hit details
- 响应示例
[
{
"errorCode": 0,
"textSpam": {
"content": "fuck",
"result": 0
},
"taskId": "367ef301-c627-4ae7-b23f-93d8219ade23",
"language": "en",
"startTime": 1699265265989,
"endTime": 1699265268714,
"id": "1"
},
{
"errorCode": 0,
"textSpam": {
"content": "caonima",
"result": 1,
"tags": [
{
"tag": 999,
"tagName": "用户自定义",
"level": 1,
"subTags": [
{
"subTag": 999001,
"subTagName": "用户自定义敏感词一类",
"wordList": [
"caonima"
]
}
]
}
],
"wordList": [
"caonima"
]
},
"taskId": "4967e9d1-f4ca-47de-aa52-6e6b0372ddcc",
"language": "Italian",
"companyId": "1",
"startTime": 1699265269127,
"endTime": 1699265269138,
"adRisk": 1,
"id": "2"
}
]
错误码
see text check Error Code
Parameter specification
- Request URL
https://tsafe.ilivedata.com/api/v1/text/batchCheck
- HTTP Request Header:
Header | Value | Property | Description |
---|---|---|---|
Content-Type | application/json;charset=UTF-8 | Required | Request body type |
Accept | application/json;charset=UTF-8 | Required | Return type accepted |
X-AppId | Required | The only identifier of the project or application. | |
X-TimeStamp | Required | 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 | Required | Signature value |
- Request method
POST
- Request JSON body
Parameter | Property | Type | Description |
---|---|---|---|
contents | Required | JSON ARRAY | batch check content items,max count:100 |
- Content
Parameter | Property | Type | Description |
---|---|---|---|
id | Optional | String | Uniquely identifies for item |
content | Required | String | The text to be detected. This text is UTF-8 encoded strings with no more than 2048 characters. |
strategyId | Optional | String | Policy number. The default policy DEFAULT is used when not passed. |
country | Optional | String | country The default policy DEFAUL is used when not passed. |
userId | Optional | String | Unique end user ID. The userID should be no more than 64 characters. |
userName | Optional | String | User name, nickname. The user name should be no more than 32 characters. |
userLevel | Optional | Number | User level |
userIp | Optional | String | User IP address |
sessionId | Optional | String | sessionId,The sessionId should be no more than 64 characters. |
receiverId | Optional | String | receiverId,The receiverId should be no more than 64 characters. |
totalPay | Optional | Number | User total payment. Support up to 2 digits after the decimal point. |
registrationDate | Optional | Number | User registration date. 10 digit timestamp. |
msgCount | Optional | Number | Number of message sent |
msgType | Optional | String | Message type |
pkgChannel | Optional | String | Package channel |
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 |
checkTags | Optional | array | the type you want to filter |
- Example of request body
{
"contents": [
{
"id": "1",
"content": "测试语句1",
"strategyId": "DEFAULT"
},
{
"id": "2",
"content": "测试语句2",
"strategyId": "DEFAULT"
}
]
}
- Request signature:
When the user requests the Text Check API, the request can be signed with the appId and secretKey. 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
- 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))
-
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 HTTP RequestURI 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.
-
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.
-
Converting the results of the previous step to a BASE64 string
-
Put the BASE64 string into the Authorization of HTTP request Header
HTTP Response
Content-Type: application/json;charset=UTF-8
The result is in JSON format, please refer to the following example.
- Example of HTTP response:
Description of returning json field:
Field name | Type | Description |
---|---|---|
id | String | ‘id’ which come from request |
errorCode | Number | Error code: 0 means success |
textSpam | JSON object | Resut message |
taskId | String | Unique identifier to distinguish different calls |
startTime | Number | Timestamp, representing the detection text call time |
endTime | Number | Timestamp, representing the return time of the detected text result |
textSpam:
Field name | Type | Description |
---|---|---|
content | String | After the detection is complete, sensitive words will change to asterisks if they contain sensitive words, and other content will be returned normally. |
result | Number | 0: Pass, 1: Recommended for review, 2: Fail |
tages | Tag[] | Classified information |
wordList | String array | List of sensitive words |
Tag:
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,410:Irregular Emoticons, 420:Nickname,300:advertising law,220:private transaction,900: other, 999: customization |
tagName | String | Detect first-level type names for text hits |
tagNameEn | String | Detect first-level type names for text hits(English) |
level | Number | Classification level,0:Normal,1:Suspected,2:Abnormal |
confidence | Number | confidence,between 0 and 100,oney when tag=150,confidence is not null; The higher the value, the more likely to be an advertisement |
subTags | SubTag[] | Secondary classification of sensitive information |
SubTag:
Field name | Type | Describe |
---|---|---|
subTag | Number | Secondary classification information reference Classification Code |
subTagName | String | Detect secondary type names for text hits |
subTagNameEn | String | Detect secondary type names for text hits(English) |
wordList | array of strings | hit details |
- 响应示例
[
{
"errorCode": 0,
"textSpam": {
"content": "fuck",
"result": 0
},
"taskId": "367ef301-c627-4ae7-b23f-93d8219ade23",
"language": "en",
"startTime": 1699265265989,
"endTime": 1699265268714,
"id": "1"
},
{
"errorCode": 0,
"textSpam": {
"content": "caonima",
"result": 1,
"tags": [
{
"tag": 999,
"tagName": "用户自定义",
"level": 1,
"subTags": [
{
"subTag": 999001,
"subTagName": "用户自定义敏感词一类",
"wordList": [
"caonima"
]
}
]
}
],
"wordList": [
"caonima"
]
},
"taskId": "4967e9d1-f4ca-47de-aa52-6e6b0372ddcc",
"language": "Italian",
"companyId": "1",
"startTime": 1699265269127,
"endTime": 1699265269138,
"adRisk": 1,
"id": "2"
}
]
错误码
see text check Error Code