Batch Add Channel Products
Interface Description
1、批量添加频道商品库商品
2、(channelId, timestamp, appId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
3、接口支持https协议
Interface URL
http://api.polyv.net/live/v3/channel/product/batch-add
<a href="/req.html?api=http://api.polyv.net/live/v3/channel/product/batch-add"" target="_blank">Online API Call
Request Method
POST
Interface Constraints
The interface supports both HTTP and HTTPS. HTTPS is recommended to ensure interface security. Interface calls are subject to frequency limits. For details, please refer to
When the product type is a regular product, the product name, product cover link, actual product price, product listing status, and product link type are required, and the corresponding link must be provided based on the product link type. When the product type is a financial product, the product name, product listing status, and product link type are required, and the corresponding link must be provided based on the product link type.
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| appId | true | String | Account appId see Get Secret Key |
| timestamp | true | Long | Current 13-digit millisecond timestamp, valid within 3 minutes |
| sign | true | String | Signature, a 32-character uppercase MD5 value. The appSecret key used to generate the signature is critical for communication data security. It must never be saved or used directly on the client side. All APIs must be called through the customer's own server to relay requests to the POLYV server and retrieve response data. see Signature Generation Rules |
| channelId | true | String | Channel ID |
Request Body Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| true | array | Product JSON array |
Request Body Parameter Description
| Parameter Name | Required | Type | Description |
|---|---|---|---|
| productType | false | String | Product type. Optional values: normal: General product finance: Financial product position: Job listing Defaults to normal if not provided. |
| cover | false | String | For general products (productType is normal): Product cover URL, required, length range: 1-500 For financial products (productType is finance): Product cover, optional For job listings (productType is position): Job cover, optional Choose either cover or ext to pass; if both are passed, ext takes precedence. |
| name | true | String | For general products (productType is normal): Product name, required For financial products (productType is finance): Product name, required For job listings (productType is position): Job title, required Note: The API supports 1-100 characters, but the live streaming backend only supports 1-50 characters. |
| status | true | Integer | Product listing status 1: Listed 2: Unlisted |
| linkType | true | Integer | Product link type 10: Universal link 11: Multi-platform link |
| link | false | String | Universal link, product link. Link address length: 1-500 Required when linkType=10 Optional when linkType=11 |
| pcLink | false | String | Multi-platform link, PC redirect link. Link address length: 1-500 |
| mobileLink | false | String | Multi-platform link, mobile web link |
| wxMiniprogramLink | false | String | Multi-platform link, mini-program page path and parameters (for the path attribute, the declared page path must include the .html suffix, e.g., pages/home/index.html) |
| wxMiniprogramOriginalId | false | String | Multi-platform link, mini-program original ID |
| mobileAppLink | false | String | Multi-platform link, mobile app link |
| androidLink | false | String | Multi-platform link, mobile app - Android native page link |
| iosLink | false | String | Multi-platform link, mobile app - iOS native page link |
| params | false | String | Custom parameters. Received as a JSON object string; must be escaped in the request. See the request body parameter example below. For general products (productType is normal): Example: {"id":21,"color":"blue","level":1}, optionalFor financial products (productType is finance): Example: {"id":21,"color":"blue","level":1}, optionalFor job listings (productType is position): Required and must include the treatment (salary/benefits) parameter, e.g., {"treatment":"7~8k"} |
| productDesc | false | String | For general products (productType is normal): Product description, optional For financial products (productType is finance): Product description, optional For job listings (productType is position): Job description, required |
| features | false | String | Received as a JSON object string; must be escaped in the request. See the request body parameter example below. For general products (productType is normal): Product tags, JSON array, e.g., ["tab1", "tab2"]For financial products (productType is finance): Product tags, JSON array, e.g., ["tab1", "tab2"]For job listings (productType is position): Job tags, JSON array, e.g., ["tab1", "tab2", "tab3"]. If there are fewer than three tags, use empty strings as placeholders. |
| btnShow | true | String | Button display text |
| yield | false | String | Financial product (productType is finance) parameter: Product yield/price |
| productDetail | false | String | Product details |
| ext | false | String | JSON object string: {"coverList":["Cover image URLs, max 15"], "videoList":[{"videoSource":"Video source", "videoId":"Video ID"}]} See details in EXT Choose either cover or ext to pass; if both are passed, ext takes precedence. |
| tagIds | false | String | Product tag ID list: JSON array string, format: [100,102,103] |
| - | - | - | Parameters specific to general products (productType=normal) |
| priceType | false | String | Actual product price type. Optional values: AMOUNT: Amount CUSTOM: Custom Defaults to AMOUNT if not provided. |
| realPrice | false | Float | Actual product price - amount. Required when priceType=AMOUNT. Maximum precision of two decimal places, e.g., 12.34 |
| customPrice | false | String | Actual product price - custom. Required when priceType=CUSTOM. Maximum 20 characters. |
| originalPriceType | false | String | Original product price (strikethrough price) type. Optional values: AMOUNT: Amount CUSTOM: Custom Defaults to AMOUNT. |
| price | false | Float | Original product price (strikethrough price) - amount. Effective when originalPriceType=AMOUNT. Maximum precision of two decimal places, e.g., 12.34 |
| customOrignalPrice | false | String | Original product price (strikethrough price) - custom. Effective when originalPriceType=CUSTOM. Maximum 20 characters. Note: If both price and customOriginalPrice are empty, the original price (strikethrough price) is not enabled. |
| - | - | - | End of parameters specific to general products (productType=normal) |
EXT
| Parameter | Required | Type | Description |
|---|---|---|---|
| coverList | true | Array | Array of cover image URLs, up to 15 |
| videoList | false | Array | Array of videos, up to 1 See ChannelProductExtVideo Requires the material library to be enabled |
| jumpWay | false | String | Jump method for external link purchase - universal link: POP_UP - open in popup, NEW_WINDOW - open in new window, CURRENT_WINDOW - open in current window |
ChannelProductExtVideo
| Parameter | Required | Type | Description |
|---|---|---|---|
| videoId | true | String | Video ID |
| videoSource | true | String | Video source: MATERIAL_LIBRARY - Material library |
Example
http://api.polyv.net/live/v3/channel/product/batch-add?appId=frlr1zazn3&sign=8C89A574637594B0CB524039FC6D66C9&channelId=2288633×tamp=1622177434141
Request Body Parameters
[
{
"name": "测试添加金融产品1",
"status": "1",
"linkType": 10,
"link": "http://live.polyv.net",
"btnShow": "测试按钮显示",
"productDesc": "测试产品描述",
"yield": "10.01%",
"features": "[\"tab1\", \"tab2\"]",
"params": "{\"id\":21,\"color\":\"blue\",\"level\":1}",
"productType": "finance",
"productDetail" : "<p>这是商品详情!</p>"
},
{
"name": "测试添加金融产品1",
"status": "1",
"linkType": 10,
"link": "http://live.polyv.net",
"btnShow": "测试按钮显示",
"productDesc": "测试产品描述",
"yield": "10.01%",
"features": "[\"tab1\", \"tab2\"]",
"params": "{\"id\":21,\"color\":\"blue\",\"level\":1}",
"productType": "finance",
"productDetail" : "<p>这是商品详情!</p>"
}
]
Response Parameter Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Response status code. 200 indicates success; non-200 indicates failure [see Global Error Description] |
| status | String | Response status text |
| message | String | Response description. When code is 400 or 500, it provides additional error details |
| data | Array | On success, contains product information [see Data Parameter Description]; on failure, it is empty |
Data parameter description
| Parameter Name | Type | Description |
|---|---|---|
| productId | Integer | Product ID |
| userId | String | POLYV user ID, consistent with the POLYV official website. Retrieval path: Official website -> Login -> Live (Development Settings) |
| channelId | String | Channel number |
| name | String | Product name |
| productType | String | Product type. Possible values: normal: General product finance: Financial product position: Job product |
| cover | String | Product cover image URL |
| link | String | Product link for general product type |
| status | Integer | Product listing status. 1: Listed 2: Unlisted |
| createdTime | Long | Product creation time, 13-digit millisecond timestamp |
| lastModified | Long | Product update time, 13-digit millisecond timestamp |
| rank | Integer | Product sort order number |
| type | String | Platform identifier, default is "live", others are invalid |
| linkType | Integer | Product link type. 10: General link 11: Multi-platform link |
| pcLink | String | Multi-platform link, PC redirect URL |
| mobileLink | String | Multi-platform link, Mobile web redirect URL |
| wxMiniprogramLink | String | Multi-platform link, WeChat Mini Program redirect URL |
| wxMiniprogramOriginalId | String | Multi-platform link, WeChat Mini Program ID |
| mobileAppLink | String | Multi-platform link, Mobile app redirect URL |
| androidLink | String | Multi-platform link, Mobile app - Android native page URL |
| iosLink | String | Multi-platform link, Mobile app - iOS native page URL |
| params | String | Custom parameters, JSON object |
| btnShow | String | Button display text |
| features | String | For general products (productType is normal): Product tags, JSON array, e.g., ["tab1", "tab2"]For financial products (productType is finance): Product tags, JSON array, e.g., ["tab1", "tab2"]For job products (productType is position): Job tags, JSON array, e.g., ["tab1", "tab2"] |
| productDesc | String | Product description, supports special characters |
| yield | String | Product yield/price |
| productDetail | String | Product details, returns a content storage address, e.g., https://liveimages.videocc.net/product-info/product-detail/4d57ea01de/704007d1fdfd4cb2a5b3d3a842418831.json URL stores the product detail content |
| ext | String | JSON object string: {"coverList":["Cover image URLs, up to 15"], "videoList":[{"videoSource":"Video source", "videoId":"Video ID"}]} See details in EXT |
| - | - | The following are parameters specific to general products (productType=normal) |
| priceType | String | Actual product price type. Possible values: AMOUNT: Amount CUSTOM: Custom |
| realPrice | Float | Actual product price - amount, with a maximum precision of two decimal places, e.g., 12.34 |
| customPrice | String | Actual product price - custom |
| originalPriceType | String | Original product price (strikethrough price) type. Possible values: AMOUNT: Amount CUSTOM: Custom |
| price | Float | Original product price (strikethrough price) - amount, with a maximum precision of two decimal places, e.g., 12.34 |
| customOrignalPrice | String | Original product price (strikethrough price) - custom note: If both price and customOriginalPrice are empty, the original price (strikethrough price) is not enabled. |
| - | - | The above are parameters specific to general products (productType=normal) |
Example of content stored in the productDetail URL
{
"productDetail": "<p>这是商品详情</p>"
}
Java Request Example
Quick Start 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 HttpUtil.java and LiveSignUtil.java are both included in the downloaded file.
It is strongly recommended that you use the Live Java SDK to complete 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(ChannelOperateTest.class);
/**
* 添加商品
* @throws IOException
*/
@Test
public void testAddChannelProduct() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId = super.appId;
String appSecret = super.appSecret;
String userId = super.userId;
String timestamp = String.valueOf(System.currentTimeMillis());
//业务参数
String channelId = "2288633";
String url = "http://api.polyv.net/live/v3/channel/product/batch-add";
//http 调用逻辑
Map<String, String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp", timestamp);
requestMap.put("channelId", channelId);
requestMap.put("sign",LiveSignUtil.getSign(requestMap, appSecret));
url=HttpUtil.appendUrl(url,requestMap);
String json = "[{\"name\":\"测试添加金融产品1\",\"status\":\"1\",\"linkType\":10,\"link\":\"http://live.polyv.net\",\"btnShow\":\"测试按钮显示\",\"productDesc\":\"测试产品描述\",\"yield\":\"10.01%\",\"features\":\"[\\\"tab1\\\", \\\"tab2\\\"]\",\"productType\":\"finance\"}]";
String response = HttpUtil.postJsonBody(url, json,null);
log.info("测试添加商品:{}",response);
//do somethings
}
Response Example
For system-wide error descriptions, see Global Error Descriptions.
Successful Example
{
"code": 200,
"status": "success",
"message": "",
"data": [
{
"productId": 134827,
"userId": "1b448be323",
"channelId": 2272655,
"name": "测试添加金融产品1",
"price": null,
"cover": "",
"link": "http://live.polyv.net",
"status": 1,
"createdTime": 1661390909000,
"lastModified": 1661390909000,
"rank": 55,
"realPrice": 0,
"type": "live",
"linkType": 10,
"pcLink": "",
"mobileLink": "",
"androidLink": null,
"iosLink": null,
"otherLink": null,
"wxMiniprogramLink": "",
"wxMiniprogramOriginalId": "",
"mobileAppLink": "",
"params": "{\"id\": 21, \"color\": \"blue\", \"level\": 1}",
"productType": "finance",
"btnShow": "测试按钮显示",
"features": "[\"tab1\", \"tab2\"]",
"productDesc": "测试产品描述",
"yield": "10.01%",
"productDetail" : "https://liveimages.videocc.net/product-info/product-detail/4d57ea01de/704007d1fdfd4cb2a5b3d3a842418831.json"
},
{
"productId": 134828,
"userId": "1b448be323",
"channelId": 2272655,
"name": "测试添加金融产品1",
"price": null,
"cover": "",
"link": "http://live.polyv.net",
"status": 1,
"createdTime": 1661390909000,
"lastModified": 1661390909000,
"rank": 55,
"realPrice": 0,
"type": "live",
"linkType": 10,
"pcLink": "",
"mobileLink": "",
"androidLink": null,
"iosLink": null,
"otherLink": null,
"wxMiniprogramLink": "",
"wxMiniprogramOriginalId": "",
"mobileAppLink": "",
"params": "{\"id\": 21, \"color\": \"blue\", \"level\": 1}",
"productType": "finance",
"btnShow": "测试按钮显示",
"features": "[\"tab1\", \"tab2\"]",
"productDesc": "测试产品描述",
"yield": "10.01%",
"productDetail" : "https://liveimages.videocc.net/product-info/product-detail/4d57ea01de/704007d1fdfd4cb2a5b3d3a842418831.json"
}
]
}
Error Example
{
"code": 400,
"status": "error",
"message": "invalid signature.",
"data": ""
}
