stable本次发布有变化全部展示
来自 TikTok Shop 官方资料快照 ·
- 当前资料结构化阅读页
- 固定快照已留存,可追溯
- 官方原文可核对
资料正文
§1 Path: /product/202404/images/optimize
#§2 Method: [POST]
#§3 Function Description
Optimize images used in your TikTok Shop by changing the background to white. This is especially useful for images displayed in the product image gallery as it enhances product visibility. Note:
- The images to be optimized must first be uploaded to TikTok Shop through the Upload Product Image API. You will not be able to optimize any images that are not hosted by TikTok Shop.
- Images that were previously optimized will not be processed again.
- The optimization is processed asynchronously and typically completes within a few seconds. Therefore, the
optimize_statusreturned in the first API request for an image is alwaysPROCESSING, indicating that optimization is underway. Please call the API again after a few seconds to get the final optimization status.
§4 Common Parameters
For common parameters, refer to How to call TikTok Shop APIs - Common Parameters
| Properties | Location | Type | Require | Sample | Properties description |
|---|---|---|---|---|---|
| shop_cipher | query | string | Y | GCP_XF90igAAAABh00qsWgtvOiGFNqyubMt3 | Use this property to pass shop information in requesting the API. Failure in passing the correct value when requesting the API for cross-border shops will return incorrect response. |
| Get by API Get Authorization Shop | |||||
| content-type | header | string | Y | application/json | Allowed type: application/json |
§5 Request Query Parameters
| Properties | Type | Require | Sample | Properties description |
|---|---|---|---|---|
| app_key | string | Y | 38abcd | Every single app will have a unique key. Please use the specific key assigned to your app. |
| sign | string | Y | 5361235029d141222525e303d742f9e38aea052d10896d3197ab9d6233730b8c | Signature generated by gen algorithm. When you send API requests to TTS, you must sign them so that TTS can identify the senders. |
| timestamp | int | Y | 1623812664 | Unix timestamp GMT (UTC+00:00). This timestamp is used across all API requests. Developers can use this convert to local time. |
§6 Request Body Parameters
| Properties | Type | Require | Sample | Properties description |
|---|---|---|---|---|
| images | []object | N | The list of images to be optimized. | |
| Use the Upload Product Image API to upload the images first and obtain the corresponding image URIs. | ||||
| Max count: 200 | ||||
| ^uri | string | N | tos-maliva-i-o3syd03w52-us/53b55d6e8cdf1f315affa7e70b45707d | The URI of the image. |
| Retrieve the URI from the Upload Product Image API. | ||||
| ^optimization_mode | []string | N | ["WHITE_BACKGROUND"] | The optimization type. |
| Possible values: |
- WHITE_BACKGROUND: Change the background to white. |
§7 Request Sample
Query
https://open-api.tiktokglobalshop.com/product/202404/images/optimize?app_key=123abc&sign=5361235029d141222525e303d742f9e38aea052d10896d3197ab9d6233730b8c×tamp=1625484268&shop_cipher=ROW_RHkDDABBAAB8tKAVoAqsMTjsQZFLyNfY
Body
{"images":[{"uri":"tos-maliva-i-o3syd03w52-us/53b55d6e8cdf1f315affa7e70b45707d","optimization_mode":["WHITE_BACKGROUND"]}]}
§8 Response Parameters
| Properties | Type | Sample | Properties description |
|---|---|---|---|
| code | int | 0 | The success or failure status code returned in API response. |
| message | string | Success | The success or failure messages returned in API response. Reasons of failure will be described in the message. |
| request_id | string | 202203070749000101890810281E8C70B7 | Request log |
| data | object | Specific return information | |
| ^images | []object | The list of images to be optimized. | |
| ^^height | int | 600 | The expected image height after optimization. |
| ^^width | int | 600 | The expected image width after optimization. |
| ^^original_uri | string | tos-maliva-i-o3syd03w52-us/53b55d6e8cdf1f315affa7e70b45707d | The original URI of the image to be optimized. |
| ^^original_url | string | https://p16-graph-va.ibyteimg.com/tos-maliva-i-1por3rr4fy-us/v2/53b55d6e8cdf1f315affa7e70b45707d~tplv-1por3rr4fy-image.webp | The original URL of the image to be optimized. |
| ^^optimized_uri | string | tos-maliva-i-o3syd03w52-us/0266127022264e54ad2f639f5e0fb5e6 | The URI of the image after optimization. |
| Pass this value when creating or editing a product to associate the image with the product. | |||
Applicable only if optimize_statusis SUCCESS. | |||
| ^^optimized_url | string | https://p16-graph-va.ibyteimg.com/tos-maliva-i-1por3rr4fy-us/v2/0266127022264e54ad2f639f5e0fb5e6~tplv-1por3rr4fy-image.webp | The URL of the image after optimization. |
Use this URL in product descriptions by embedding it within an HTML <img> tag.
Applicable only if optimize_statusis SUCCESS. |
^^optimize_status |string |SUCCESS |The optimization status.
Possible values:
- SUCCESS: The image has been successfully optimized.
- IGNORE: The image was previously optimized, so no further action was taken.
- PROCESSING: The optimization is in progress, and typically completes within a few seconds. Call this API again to obtain the final optimization status. |
§9 Response Sample
{"code":0,"data":{"images":[{"height":600,"width":600,"original_uri":"tos-maliva-i-o3syd03w52-us/53b55d6e8cdf1f315affa7e70b45707d","original_url":"https://p16-graph-va.ibyteimg.com/tos-maliva-i-1por3rr4fy-us/v2/53b55d6e8cdf1f315affa7e70b45707d~tplv-1por3rr4fy-image.webp","optimized_uri":"tos-maliva-i-o3syd03w52-us/0266127022264e54ad2f639f5e0fb5e6","optimized_url":"https://p16-graph-va.ibyteimg.com/tos-maliva-i-1por3rr4fy-us/v2/0266127022264e54ad2f639f5e0fb5e6~tplv-1por3rr4fy-image.webp","optimize_status":"SUCCESS"}]},"message":"Success","request_id":"202203070749000101890810281E8C70B7"}
§10 Error Code
For common error codes, refer to How to call TikTok Shop APIs - Common Error Code
| Code | Message |
|---|---|
| 12019065 | The image URI is invalid. Please use the URI generated by the Upload Product Image API. |
| 12019070 | The optimization mode is invalid. |
| 12038007 | The number of image URIs exceeded the limit of 200. |
| 12052722 | The image URI does not exist in TikTok Shop. |
