Site owners can upload images for categories. These images are displayed on category pages in the store.

Category images
Category images

​Use the Category Image API to retrieve image information, as well as to create and delete category images.

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 ​When returned, the URL to the image when on a published site.
​For POST, use image_url instead of url, and send the URL to the image to be uploaded.
string X X
category_id ​Unique ID (to the store) of the category that the image is used for. string X
category_image_id ​Unique (to the category) ID of the image int X
order ​If the category has more than one image associated with it, the place order for this image. string
width ​The width in pixels of this image. string
height ​​The height in pixels of this image. string
format ​The format of the image.
Valid values are:
  • jpeg
  • png
  • gif
created_date Date the image was posted Unix GMT Timestamp
updated_date Date the image was last updated Unix GMT Timestamp

GET
Retrieve a List of Category Images

GET /v1/user/sites/{SITE_ID}/store/categories/{CATEGORY_ID}/images

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


scope: read:store-catalog

Example CURL request returning all category images:

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

Example response:

[
    {
        "user": "123456",
        "site_id": "987654321",
        "url": "http:\/\/testing12345.com\/uploads\/7\/5\/6\/5\/75658535\/s274903847701657561_c2_i1_w547.png",
        "category_id": "2",
        "category_image_id": 1
    },
    {
        "user": "123456",
        "site_id": "987654321",
        "url": "http:\/\/testing12345.com\/uploads\/7\/5\/6\/5\/75658535\/s2749038477065465416516_c2_i1_w532.png",
        "category_id": "2",
        "category_image_id": 2
    }
]

GET
Retrieve the Quantity of Category Images

GET /v1/user/sites/{SITE_ID}/store/categories/{CATEGORY_ID}/images/count

Returns the number images uploaded for this category.


scope: read:store-catalog

Example CURL request:

curl --request GET \
--url https://api.weebly.com/v1/user/sites/987654321/store/categories/7/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 Category Image

GET /v1/user/sites/{SITE_ID}/store/categories/{CATEGORY_ID}/images/{IMAGE_ID}

Returns all fields for the given category image.


scope: read:store-catalog

Example CURL request:

curl --request GET \
--url https://api.weebly.com/v1/user/sites/987654321/store/categories/7/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 category are returned.

{
    "user": "123456",
    "site_id": "987654321",
    "url": "http:\/\/testing12345.com\/uploads\/7\/5\/6\/5\/75658535\/s274903847701657561_c2_i1_w547.png",
    "category_id": "7",
    "category_image_id": 1,
    "width": "547",
    "height": "292",
    "format": "png",
    "created_date": 1458864865,
    "updated_date": 1458864865
}

POST
Create a Category Image

POST /v1/user/sites/{SITE_ID}/store/categories/{CATEGORY_ID/images

Adds an image to a category.


scope: write:store-catalog

These fields can be posted:

Name Description Type Notes
image_url ​The URL to the image to be uploaded. string Required

Example CURL request:

curl --request POST \
--url https://api.weebly.com/v1/user/sites/987654321/store/categories/7/images \
--header 'accept: application/vnd.weebly.v1+json' \
--header 'content-type: application/json' \
--header 'x-weebly-access-token: [YOUR_TOKEN]"
--data '{
            "img_url": "http://www.sea-way.org//blog/google-ocean.jpg"
        }'

Example response:

{
    "user": "123456",
    "site_id": "987654321",
    "url": "http:\/\/testing12345.com\/uploads\/7\/5\/6\/5\/75658535\/s274903847701657561_c3_i1_w480.jpeg",
    "category_id": "7",
    "category_image_id": 3,
    "width": "480",
    "height": "286",
    "format": "jpeg",
    "user_id": "123456",
    "created_date": 1458865615,
    "updated_date": 1458865615
}

DELETE
Delete a Category Image

DELETE /v1/user/sites/{SITE_ID}/store/categories/{CATEGORY_ID}/images/{IMAGE_ID}

Deletes the given category.


scope: write:store-catalog

Example CURL request:

curl --request DELETE \
--url https://api.weebly.com/v1/user/sites/987654321/store/categories/9/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: