Batch Add Audio Moderation Words
API Description
1、批量新增账号的音频审核词库词条(敏感词或严禁词),词库为账号级配置,账号下所有频道共用同一份词库
2、管理后台和开放API读写同一份词库,任一入口保存成功后,另一入口查询到相同结果
3、已开通直播音频消音的账号保存词库时,系统将敏感词和严禁词的合集同步到腾讯消音词库,同步成功后新增的词最迟在10分钟内对直播消音生效
4、接口支持https协议
API URL
http://api.polyv.net/live/v4/user/audio-moderation/word/add
Request Method
POST
API Constraints
The API supports both HTTP and HTTPS. HTTPS is recommended for security. API calls have a frequency limit. See details
The audio moderation feature must be enabled. If not, error code
1041is returned. The API determines the target account based onappIdin the signature. User ID or channel number is not accepted.Word limits: Each account can store up to 5,000 sensitive words and 5,000 prohibited words. A single word cannot exceed 20 Chinese characters. A single batch submission can contain up to 2,000 words. If the total exceeds 5,000 after addition, or if the request contains empty words, overly long words, or other non-compliant content, the entire batch request fails and the original word library remains unchanged.
The system trims leading and trailing spaces before saving words. Case is ignored when checking for duplicate words. Duplicate words within the same request are treated as a single word. Adding an existing word again is treated as successful and counted in
existedCount. Repeated requests with identical parameters will not create duplicate words.Set the request header
Content-Type: application/json. JSON request body parameters are not included in the signature. The signature only uses URL parameters.
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| appId | true | String | Account appId See details for obtaining key |
| timestamp | true | Long | Current 13-digit millisecond timestamp, valid for 3 minutes |
| sign | true | String | Signature, a 32-character uppercase MD5 value. The appSecret used to generate the signature is critical for communication data security. It must not be stored or used directly on the client side. All APIs must be called through your own server to relay requests to the POLYV server to obtain response data. See signature generation rules |
Request Body Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| wordType | true | String | Word typekeyword: Add to sensitive wordsbadword: Add to prohibited words |
| words | true | Array | Words to add, up to 2,000 |
Example
http://api.polyv.net/live/v4/user/audio-moderation/word/add?appId=frlr1zazn3&sign=49428741C1D7BEE8BE1EE545F066ECC7×tamp=1677167340447
Request body JSON parameters:
{
"wordType": "keyword",
"words": [
"示例敏感词一",
"示例敏感词二"
]
}
Response Parameter Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Status code, same as HTTP status code, used to determine basic response status |
| status | String | Response result, determined by business logic. Returns success on success, error on failure |
| success | Boolean | Whether the request was successful |
| requestId | String | Request ID, a unique UUID generated for each request. Only for troubleshooting and debugging, not for business logic |
| error | Object | Error information when status code is not 200 See Error parameter description |
| data | Object | Successful response data See data parameter description |
Error Parameter Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Error code, used to identify the specific error cause, e.g., 1041 indicates the account has not enabled audio moderation |
| desc | String | Error description, corresponding to error.code |
Data Parameter Description
| Parameter | Type | Description |
|---|---|---|
| wordType | String | Word type for this operationkeyword: Sensitive wordbadword: Prohibited word |
| requestedCount | Integer | Number of words after deduplication in the request |
| addedCount | Integer | Actual number of newly added words |
| existedCount | Integer | Number of words that already existed and were skipped |
| totalCount | Long | Total number of words in the current category after the operation |
| muteEffectiveWithinMinutes | Integer | Returns the maximum effective latency in minutes (10) when live audio muting is enabled. Not returned if muting is not enabled. |
| words | Array | Word details See words parameter description |
Words Parameter Description
| Parameter | Type | Description |
|---|---|---|
| word | String | Word content |
| id | Long | Word ID. Returns the original word ID for existing words, or a new ID for newly inserted words. |
| existed | Boolean | Whether the word already existed in the library at the time of the operation |
Java Request Example
For quick integration of basic code, please download the relevant dependency source code. Click here to download the source code. After downloading, add it to your own source project. The test cases include HttpUtil.java and LiveSignUtil.java in the downloaded file.
It is strongly recommended to use the Live Java SDK for API integration. The Live Java SDK provides unified encapsulation and optimization for API call logic, exception handling, data signing, and HTTP request thread pooling.
private static final Logger log = LoggerFactory.getLogger(getClass());
/**
* 批量新增音频审核词
* @throws IOException
* @throws NoSuchAlgorithmException
*/
@Test
public void testAudioModerationWordAdd() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId = super.appId;
String appSecret = super.appSecret;
String timestamp = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/live/v4/user/audio-moderation/word/add";
String wordType = "keyword";
List<String> words = Arrays.asList("示例敏感词一", "示例敏感词二");
//http 调用逻辑
Map<String, String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp", timestamp);
Map<String, Object> jsonMap = new HashMap<>();
jsonMap.put("wordType", wordType);
jsonMap.put("words", words);
requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
url = HttpUtil.appendUrl(url, requestMap);
String response = HttpUtil.postJsonBody(url, JSON.toJSONString(jsonMap), null);
log.info("测试批量新增音频审核词,返回值:{}", response);
//do somethings
}
Response Example
For global error descriptions, see Global Error Description
Success Example
{
"code": 200,
"status": "success",
"requestId": "414afeb28f1c4f0ca17e1c3c1e39d247.71.16771673423081591",
"data": {
"wordType": "keyword",
"requestedCount": 2,
"addedCount": 1,
"existedCount": 1,
"totalCount": 320,
"muteEffectiveWithinMinutes": 10,
"words": [
{
"word": "示例敏感词一",
"id": 10001,
"existed": false
},
{
"word": "示例敏感词二",
"id": 10002,
"existed": true
}
]
},
"success": true
}
Error Example
{
"code": 400,
"status": "error",
"requestId": "d310b70bc329403f87f77f9203d50f89.128.16360831552223589",
"error": {
"code": 1041,
"desc": "audio moderation is not enabled."
},
"success": false
}
