Text Moderation
General:
API Endpoint:
http://api.open.tuputech.com/v3/recognition/text/your_secretId
NOTE: 'your_secretId' need to be replaced by your own secretId, please contact Tuputech to create a secretId.
Request Method:
POST
Request Header:
Content-Type: application/json
Request and Response Parameters:
Sample request
{
"text": [
{
"content": "32132131",
"contentId": "5bcf23077f532488c2ccd6a615414997698270",
"userId": "test",
"forumId": "car"
}
],
"timestamp": 1541499770,
"nonce": 0.8469537531104208,
"signature": "CsIMcHuWqn/QFEnHWcFEhrB7ydcg5xTKawpRpNqA9Nw2WlCVIDR5jDcyUF85"
}
Sample curl request
curl -X POST --header 'Content-Type: application/json' \
-d '{
"text": [
{
"content": "32132131",
"contentId": "5bcf23077f532488c2ccd6a615414997698270",
"userId": "test",
"forumId": "car"
}
],
"timestamp": 1541499770,
"nonce": 0.8469537531104208,
"signature": "CsIMcHuWqn/QFEnHWcFEhrB7ydcg5xTKawpRpNqA9Nw2WlCVIDR5jDcyUF85"
}' \
'http://api.open.tuputech.com/v3/recognition/text/your_secretId'
Request parameters
Parameter | Type | Required | Description |
---|---|---|---|
text | Array | Yes | The text to be moderated. For more details, see text. |
timestamp | Number | Yes | The current UNIX timestamp of the server. |
nonce | Number | Yes | Random number |
signature | String | Yes | The algorithm used for digital signature is "RSA-SHA256" , and the signature will be base64 encoded. Please follow the steps below for authentication: 1. All the parameters involving in the authentication process are secretId, timestamp, and nounce. Separate them with half-width comma, obtain sign string. 2. Use your private key to generate signature based on "RSA-SHA256" algorithm, encode in base64 , and obtain value of signature parameter. See Public Key Management to learn how to generate private key and upload your public for authentication. |
QPS Limits
- maximum 50 queries per second
- maximum 10 text files per query
To increase concurrency, please contact Tuputech team.
text
Parameter | Type | Required | Description |
---|---|---|---|
content | String | Yes | The text to be moderated. Text content can be in the form of word or sentence. |
contentId | String | No | User custom ID used for specific text searching. Suggested ID format: “secretId + current time + random number”. For more information, see Request Sample. |
userId | String | No | User ID |
forumId | String | No | Forum ID |
Response Parameters
Common structure of service response data
Parameter | Type | Required | Description |
---|---|---|---|
signature | String | Yes | The algorithm used for digital signature is "RSA-SHA256" , and the signature will be base64 encoded. Download Tuputech’s public key certificatefirst, and then follow the steps below for authentication: 1. JSON.parse() parses received JSON data, and return JSON object which is named“data”. 2. “data” consists of two fields: “signature”-digital signature; “json”- string format of valid data. 3. use signature to verify json based on RSA-SHA25 algorithm (output type: base64 ), and receive the authentication result. 4. After passing the authentication, JSON.parse() json, JSON data returned. For more information, see the description of json below. |
json | String | Yes | After parsing json by JSON.parse(json) , the result contains: message :text corresponding to code parameter.timestamp :The current UNIX timestamp of the server. nonce :random number |
Structure after JSON parsing
Parameter | Type | Required | Description |
---|---|---|---|
code | Number | Yes | Status code of the request, see Common Status Code Description. |
message | String | Yes | Status message of the request. |
timestamp | Number | Yes | The current UNIX timestamp of the server. |
nonce | Number | Yes | Random number |
summary | Array | No | Summary of the results. Disabled by default, please contact Tuputech to enable. |
[taskId] | Object | Yes | Result of tasks. Each task has its own taskID and [taskId] data structure. |
... | ... | No | Results of other tasks and requests. |
Sample
{
"signature": "signature_from_tupu_service",
"json": "{\"code\":0,\"message\":\"success\",\"nonce\":\"0.5442530125172196\",\"timestamp\":1595318082309}"
}
Task Result
taskId
57c4036c557603652aeeb222
Data structure of taskId object
Parameter | Type | Required | Description |
---|---|---|---|
texts | Array | Yes | Detailed results of moderation. See texts below. |
texts
Parameter | Type | Required | Description |
---|---|---|---|
content | String | Yes | Text content |
action | String | Yes | Moderation result. Valid values: 'pass': the text has passed moderation. 'block': the text is rejected due to potentially non-compliant content. 'review': the text requires human review. |
label | String | Yes | The category of the text moderated: 'Normal': normal content; 'Terror': violent, terrorist, bloody content; 'Porn': pornographic content; 'Politics': political content; 'Sensitive': sensitive or offensive content; 'Ads': ad; 'Abuse': abuse, profanity, cyberbullying; 'Nonsense': excessive junk content; 'UserDefine': custom label for specific content. |
review | Bool | Yes | Whether human review is required. Valid values: ture: yes false: no |
rate | Float | Yes | The score of the confidence level. Valid values: 0.0 to 1.0 or null. A greater value indicates a higher confidence level of the results. |
details | Array | Yes | The details of the objectionable content that the moderated text hits. If the action is “pass”, then the details will be an empty array. For more information about the structure, see details. |
contentId | String | No | User custom ID |
userId | String | No | User ID |
forumId | String | No | Forum ID |
details
Parameter | Type | Required | Description |
---|---|---|---|
keyword | String | No | The objectionable words in the moderated text. |
hint | String | No | The objectionable keywords the moderated text hits. |
mainLabel | String | No | The main label of the keywords: 'Normal': normal content; 'Terror': violent, terrorist, bloody content; 'Porn': pornographic content; 'Politics': political content; 'Sensitive': sensitive or offensive content; 'Ads': ad; 'Abuse': Abuse, profanity, cyberbullying; 'Nonsense': excessive junk content; 'UserDefine': custom label for specific content. |
subLabel | String | The subcategory of the moderation result. |
Sample results
{
"57c4036c557603652aeeb222":{
"texts":[
{
"contentId":"5c495dd6ca4faa03dafcb05215517048827110.9555874784367748",
"userId":"Test",
"forumId":"test",
"content":"morning",
"action":"pass",
"label":"Normal",
"review":false,
"rate":0.998047,
"details":[
]
},
{
"contentId":"5c495dd6ca4faa03dafcb05215517048827110.9555874784367748",
"userId":"Test",
"forumId":"test",
"content":"Barack Obama",
"action":"block",
"label":"Politics",
"review":false,
"rate":1,
"details":[
{
"keyword":"Barack Obama",
"hint":"Barack Obama",
"mainLabel":"Politics",
"subLabel":"National_Leader"
}
]
}
]
},
"code":0,
"message":"success",
"nonce":"0.9224814879136034",
"timestamp":1551704883139
}