edit-icon download-icon

Add Images

Last Updated: Aug 02, 2018

Description

This API adds images to a specific Image Search instance. To call this API, you must specify an instance by setting the instanceName parameter and construct the content of the POST body with the relevant parameters.

Request Path

/item/add

Request Parameters

URL Parameters

Name Data type Required Description
instanceName String Yes Name of the instance to which the images will be added.

Body Parameters

Name Data type Required Description
item_id String Yes ID of the product or image.
cat_id String No Category ID.
crop boolean No parameter determines whether Image Search crops the image and uses the cropped region as the effective region. The default value is true.
region String No parameter specifies the crop region when the crop parameter is set to true. The region parameter follows the structure of x1,x2,y1,y2, where x1 and y1 notate the position of the upper-left corner point and x2, and y2 notate the position of the lower-right corner point.
cust_content String Yes Custom content.
pic_list List Yes Image name list.
pic_map Map Yes Contents of all images.

Body Structure

The body structure is as following:

  1. key1,key1_start_offset,key1_end_offset#...#keyn,keyn_start_offset,keyn_end_offset^key1_content...keyn_content

The POST body includes image metadata and image content, which are separated by a circumflex accent (^). The metadata is a set of keys. All keys are separated by number signs (#). Each key includes the key name, start offset value, and end offset value, which are separated by commas (,). The start offset value and end offset value represent the start positon and end position of the cutout in the image content. The pic_list parameter must include only Base64 encoded image names, which are separated by commas (,). The pic_map parameter must include only Base64 encoded image content. Make sure all keys added to the pic_map parameter are paired with the keys added to the pic_list parameter.

Response parameters

Name Data type Description
Success Boolean Whether the request is successful or not.
RequestId String ID of the request.
Code int Error code. If the code is 0, the request is successful. If the code is not 0, the request is failed.
Message String Error information.

Response Structure

  1. {
  2. "Message":"success",
  3. "RequestId":"73B5133C-84EE-4F0A-B972-23CCCBFB7CD5",
  4. "Success":true,
  5. "Code":0
  6. }

Example

The following example shows how to add product photos to an Image Search instance named goodssearch. In this example, product photos shoes1.jpg and shoes2.jpg are added. The content of shoes1.jpg is pic_content1. The content of shoes2.jpg is pic_content2. The product ID (item_id), category ID (cat_id), and custom content (cust_content) are specified as 1000, 0, and {“key1”:”value1”}, respectively.

  1. URL: /item/add?instaneName=goodssearch
  2. POST Body:
  3. cust_content,0,17#item_id,17,21#c2hvZXMyLmpwZw==,21,37#cat_id,37,38#pic_list,38,71#c2hvZXMxLmpwZw==,71,87^{"key1":"value1"}1000cGljX2NvbnRlbnQy0c2hvZXMyLmpwZw==,c2hvZXMxLmpwZw==cGljX2NvbnRlbnQx
  4. Note: c2hvZXMyLmpwZw== represents the Base64 encoded image name shoes1.jpg and c2hvZXMxLmpwZw== represents the Base64 encoded image name shoes2.jpg.
Thank you! We've received your feedback.