Products can have multiple images that display when a Products element is used on a page. Images are also used on the product’s detail page:

Images on the product's page
Images on the product's page

​Use the Product Images API to view and manage the images used to display products in a Weebly store.

Fields

The following table shows all fields that exist for this API, those that are returned when you retrieve a list, and those that are required for POST. All fields are returned when you retrieve a single item.

Name Description Type List Required
user_id The unique ID of the authenticated user string X
site_id ID of a Weebly site, unique to the currently authenticated user​ string X
url The url of this image if the site and the product are published. Note that `img_url` is used for a `POST`, while `url` is returned. string X X
product_id ​Unique ID (to this store) for the product. string X
product_image_id ​Unique ID (to this product) for the image. integer X
width The width in pixels of the image. string
height The height in pixels of the image. string
format The format of the image.
Valid values are:
  • jpg
  • png
  • gif
string
created_date Date the iamge was first created. Unix GMT Timestamp
updated_date Date the image was last updated. Unix GMT Timestamp

GET
Retrieve a List of Images for a Product

GET /v1/user/sites/{SITE_ID}/store/products/{PRODUCT_ID}/images

Returns all images for the given product. Only list fields are returned.


scope: read:store-catalog

Example CURL request returning all images:

curl --request GET \
--url https://api.weebly.com/v1/user/sites/987654321/store/products/12/images \
--header 'accept: application/vnd.weebly.v1+json' \
--header 'content-type: application/json' \
--header 'x-weebly-access-token: [YOUR_TOKEN]"

Example response:

[
    {
        "user_id": "123456",
        "site_id": "987654321",
        "url": "http://mysite.weebly.com/uploads/2/0/2/8/20281409/s238965604388839654_p2_i1_w207.jpeg",
        "product_id": "12",
        "product_image_id": 1
    }
    {
        "user_id": "123456",
        "site_id": "987654321",
        "url": "http://mysite.weebly.com/uploads/2/0/2/8/20281409/s238965604388839654_p2_i1_w210.jpeg",
        "product_id": "12",
        "product_image_id": 2
    }
]

GET
Retrieve the Number of Images for a Product

GET /v1/user/sites/{SITE_ID}/store/products/{PRODUCT_ID}/images/count

Returns the number of images for a product.


scope: read:store-catalog

Example CURL request:

curl --request GET \
--url https://api.weebly.com/v1/user/sites/987654321/store/products/12/images/count \
--header 'accept: application/vnd.weebly.v1+json' \
--header 'content-type: application/json' \
--header 'x-weebly-access-token: [YOUR_TOKEN]"

Example response:

{
    "count": 2
}

GET
Retrieve Details for a Product Image

GET /v1/user/sites/{SITE_ID}/store/products/{PRODUCT_ID/images/{IMAGE_ID}

Returns all fields for the given image.


scope: read:store-catalog

Example CURL request:

curl --request GET \
--url https://api.weebly.com/v1/user/sites/987654321/store/products/12/images/1 \
--header 'accept: application/vnd.weebly.v1+json' \
--header 'content-type: application/json' \
--header 'x-weebly-access-token: [YOUR_TOKEN]"

Example response:

See Fields table. All fields for the image are returned.

{
    "user_id": "123456",
    "site_id": "987654321",
    "url": "http://mysite.weebly.com/uploads/2/0/2/8/20281409/s238965604388839654_p2_i1_w207.jpeg",
    "product_id": "12",
    "product_image_id": 1,
    "width": "207",
    "height": "244",
    "format": "jpeg",
    "created_date": 1381276054,
    "updated_date": 1381276054
}

POST
Create a Product Image

POST /v1/user/sites/{SITE_ID}/store/products/{PRODUCT_ID}/images

Creates an image for a product.


scope: write:store-catalog

These fields can be created:

Name Description Type Notes
img_url The url to this image to upload. Note that img_url is used for a POST, while url (where the image resides when published) is returned. string Required

Example CURL request:

curl --request POST \
--url https://api.weebly.com/v1/user/sites/987654321/store/products/12/images \
--header 'accept: application/vnd.weebly.v1+json' \
--header 'content-type: application/json' \
--header 'x-weebly-access-token: [YOUR_TOKEN]"
--data '{
            "img_url": "http://mysite.com/uploads/image.jpeg"
        }'

Example response:

{
    "user_id": "123456",
    "site_id": "987654321",
    "width": null,
    "height": null,
    "format": "jpeg",
    "created_date": 0,
    "updated_date": 0,
    "url": "2/0/2/8/20281409/s238965604388839654_p2_i_w.jpeg",
    "product_id": "12",
    "product_image_id": "3"
}

DELETE
Delete a Product Image

DELETE /v1/user/sites/{SITE_ID}/store/products/{PRODUCT_ID}/images/{IMAGE_ID}

Deletes the given product image.


scope: write:store-catalog

Example CURL request:

curl --request DELETE \
--url https://api.weebly.com/v1/user/sites/987654321/store/products/12/images/2 \
--header 'accept: application/vnd.weebly.v1+json' \
--header 'content-type: application/json' \
--header 'x-weebly-access-token: [YOUR_TOKEN]"

Response There is no response to a delete request.


Help make these docs better!









Tags: