stable本次发布有变化全部展示
来自 Shopee 官方资料快照 ·
- 当前资料结构化阅读页
- 固定快照已留存,可追溯
- 官方原文可核对
资料正文
§1 v2.media.init_video_upload
Use this API to initialize a new video upload task and obtain a unique upload session ID.
§2 Overview
Overview
| Field | Value |
|---|---|
| Module | Media |
| API type | Public |
| HTTP method | POST |
| Path | /api/v2/media/init_video_upload |
| Production URL | https://partner.shopeemobile.com/api/v2/media/init_video_upload |
| Sandbox URL | https://partner.test-stable.shopeemobile.com/api/v2/media/init_video_upload |
| Permission | ERP System; Seller In House System; Product Management; Customer Service; Consignment Service System; Shopee Video Management |
§3 Request parameters
Request parameters
| Name | Type | Required | Sample | Description |
|---|---|---|---|---|
| business | int32 | Yes | 3 | Defines the business type of the uploaded image. Supported values: 3 = Video |
| scene | int32 | Yes | 1 | Defines the purpose of the uploaded image under the specified business type. Supported values: - If business = 3 (Video): 1 = Shopee Video |
| file_name | string | Yes | test_video_name.mp4 | Original video file name. |
| file_size | int64 | Yes | 26214400 | Total video file size in bytes. Rules and restrictions by business and scene: - If business = 3 (Video) and scene = 1 (Shopee Video): Maximum 1GB. |
| duration | int32 | Yes | 105 | Video duration in seconds. Rules and restrictions by business and scene: - If business = 3 (Video) and scene = 1 (Shopee Video): 1s~180s. |
§4 Response parameters
Response parameters
| Name | Type | Required | Sample | Description |
|---|---|---|---|---|
| error | string | Indicate error type if hit error. Empty if no error happened. | ||
| message | string | Indicate error details if hit error. Empty if no error happened. | ||
| warning | string | Indicate warning message you should take care. | ||
| request_id | string | e3e3e7f33ee88a7454c64e7a0b546e01 | The identifier for an API request for error tracking. | |
| response | object | |||
| response.video_upload_id | string | sg-11110201-6kh48-mepm7a0ttcw3c3 | Unique upload session ID. | |
| response.part_size | int64 | 10485760 | The size of each part. When uploading video chunks, the video must be split according to this part size for each upload request. |
§5 Common parameters
Common parameters
| Name | Type | Required | Sample | Description |
|---|---|---|---|---|
| partner_id | int | 1 | Partner ID is assigned upon registration is successful. Required for all requests. | |
| timestamp | timestamp | 1610000000 | This is to indicate the timestamp of the request. Required for all requests. Expires in 5 minutes. | |
| sign | string | e318d3e932719916a9f9ebb57e2011961bd47abfa54a36e040d050d8931596e2 | Signature generated by partner_id, api path, timestamp and partner_key via HMAC-SHA256 hashing algorithm. More details: https://open.shopee.com/documents?module=87&type=2&id=58&version=2 |
§6 Request samples
Request samples
§7 Payload
Payload
{
"business": 3,
"scene": 1,
"file_name": "test_video_name.mp4",
"file_size": 26214400,
"duration": 105
}
§8 Java
Java
Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("https://partner.shopeemobile.com/api/v2/media/init_video_upload?partner_id=partner_id&sign=sign×tamp=timestamp")
.header("Content-Type","application/json")
.body("{
\"business\": 3,
\"duration\": 105,
\"file_name\": \"test_video_name.mp4\",
\"file_size\": 26214400,
\"scene\": 1
}")
.asString();
§9 PHP
PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://partner.shopeemobile.com/api/v2/media/init_video_upload?partner_id=partner_id&sign=sign×tamp=timestamp',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => '{
"business": 3,
"duration": 105,
"file_name": "test_video_name.mp4",
"file_size": 26214400,
"scene": 1
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
§10 cURL
cURL
curl --location --request POST 'https://partner.shopeemobile.com/api/v2/media/init_video_upload?partner_id=partner_id&sign=sign×tamp=timestamp' \
--header 'Content-Type: application/json' \
--data-raw '{
"business": 3,
"duration": 105,
"file_name": "test_video_name.mp4",
"file_size": 26214400,
"scene": 1
}'
§11 Python
Python
import requests
import json
url = "https://partner.shopeemobile.com/api/v2/media/init_video_upload?partner_id=partner_id&sign=sign×tamp=timestamp"
payload=json.dumps({
"business": 3,
"duration": 105,
"file_name": "test_video_name.mp4",
"file_size": 26214400,
"scene": 1
})
headers = {
'Content-Type': 'application/json'
}
response = requests.RPCRequest("POST",url,headers=headers, data=payload, allow_redirects=False)
print(response.text)
§12 Response sample
Response sample
§13 JSON
JSON
{
"error": "",
"message": "",
"warning": "",
"request_id": "e3e3e7f33ee88a7454c64e7a0b546e01",
"response": {
"video_upload_id": "sg-11110201-6kh48-mepm7a0ttcw3c3",
"part_size": 10485760
}
}
§14 Error example
Error example
§15 JSON
JSON
{
"error": "error_param",
"message": "The scene value does not match with business.",
"request_id": "e3e3e7f33ee8a17b646c2bf8bdb51d01"
}
§16 Common errors
Common errors
| Error | Description | Solution |
|---|---|---|
| error_auth | partner_id is invalid | |
| error_auth | The App is deleted, and you'll be unable to make any API call. | |
| error_auth | App developer’s permissions for authorizations have been restricted. If you’re a seller, contact the developer for more information. If you’re the developer, refer to the Open Platform Console for details. | |
| error_param | There is no partner_id in query. | |
| error_param | Invalid partner_id. | |
| error_param | no timestamp | |
| error_param | Invalid timestamp | |
| error_param | There is no sign in query. | |
| error_sign | Wrong sign. | |
| invalid_partner_id | Invalid partner_id, please have a check. | |
| error_auth | No permission to current api. | |
| error_api_call_restricted | The App permission for api call have been restricted. If you’re a seller, contact the developer for more information. If you’re the developer, refer to the Open Platform Console for details. | |
| api_suspended | The API is offline. Please call v2 API instead. | |
| error_limit | The total API call number made by your APP has reached the daily API call limit, please try again after 00: 00 (UTC+08:00) | |
| error_rate_limit | Too many requests. You have reached the rate limit. Please try again later. | |
| source_ip_undeclared | Request Source IP ({ip}) is undeclared. Please declare all your IP addresses in the Shopee Open Platform Console > App list > IP Address Whitelist | |
| error_param | Permission denied. This API is currently offline or the request path is incorrect. | |
| error_param | Partner_id is invalid, should be an integer between 0 and 4294967295. | |
| error_param | no timestamp. | |
| error_param | Timestamp is invalid, should be an integer between 0 and 4294967295. | |
| error_param | Timestamp is expired. | |
| error_partner_key_expired | Your API partner key has expired, please reset the Live API Partner Key in Console to get a new valid partner key to call open api. | |
| error_api_permission | This app type has no permission to this API. |
§17 Update log
Update log
| Date | Change |
|---|---|
| - | New API |
