Methods


Entity Properties


product_media.list (string $sku)

Retrieve list of product images

Parameters

orderdescription
0 string - Product SKU.

Return Value

An array of objects. Each object will contain “Image Data”.

Example Request

Get product images by product SKU:

{
    "jsonrpc" : 2.0,
    "id" : 1234,
    "method" : "call",
    "params" : [
        "be1c13ed4e03f0ed7f1e4053dfff9658",
        "product_media.list",
        [
            "product2"
        ]
    ]
}

Example Response

{
    "jsonrpc" : 2.0,
    "id" : 1234,
    "error" : null,
    "result" : [
        {
            "file" : "/b/l/blackberry8100_2.jpg",
            "position" : 1,
            "exclude" : 0,
            "url" : "http://magentohost/media/catalog/product/b/l/blackberry8100_2.jpg",
            "types" : [
                "image", 
                "thumbnail"
            ]
        }
    ]
}

Error Codes

code message
100 Requested store view not found.
101 Product not exists.

product_media.types (number $setId)

Retrieve product image types

Parameters

orderdescription
0 int - Attribute set id.

Return Value

An array of objects. Each object will contain “Image Type Properties”.

Example Request

{
    "jsonrpc" : 2.0,
    "id" : 1234,
    "method" : "call",
    "params" : [
        "be1c13ed4e03f0ed7f1e4053dfff9658",
        "product_media.types",
        [
            4        
        ]
    ]
}

Example Response

{
    "jsonrpc" : 2.0,
    "id" : 1234,
    "error" : null,
    "result" : [
        {
            "code" : "image",
            "scope" : "store"
        },
        {
            "code" : "thumbnail",
            "scope" : "store"
        }
    ]
}

product_media.create (string $sku, object $data)

Upload new product image

Parameters

orderdescription
0 string - Product SKU.
1 object - Image data.

Return Value

Image file name (e.g., “/i/m/image.png”)

Example Request

{
    "jsonrpc" : 2.0,
    "id" : 1234,
    "method" : "call",
    "params" : [
        "be1c13ed4e03f0ed7f1e4053dfff9658",
        "product_media.create",
        [
            "product2",
            {
                "file" : {
                    "content" : "base64 encoded content",
                    "mime": "image/jpeg"
                },
                "position" : 100,
                "types" : [
                    "thumbnail"
                ],
                "exclude" : 0
            }
        ]
    ]
}

Example Response

{
    "jsonrpc" : 2.0,
    "id" : 1234,
    "error" : null,
    "result" : [
        "/i/m/image.png"
    ]
}

Error Codes

code message
100 Requested store view not found.
101 Product not exists.
102 Invalid data given. Details in error message.
104 Image creation failed. Details in error message.
107 Requested product doesn’t support images

product_media.update (string $sku, string $file, object $data)

Update product image

Parameters

orderdescription
0 string - Product SKU.
1 string - Image file name.
2 object - Image data.

Return Value

True, if the image has been uploaded

Example Request

{
    "jsonrpc" : 2.0,
    "id" : 1234,
    "method" : "call",
    "params" : [
        "be1c13ed4e03f0ed7f1e4053dfff9658",
        "product_media.update",
        [
            "product2",
            "/i/m/image.png",
            {
                "file" : {
                    "content" : "base64 encoded content",
                    "mime": "image/jpeg"
                },
                "position" : 100,
                "types" : [
                    "thumbnail"
                ],
                "exclude" : 1
            }
        ]
    ]
}

Example Response

{
    "jsonrpc" : 2.0,
    "id" : 1234,
    "error" : null,
    "result" : 1
}

Error Codes

code message
100 Requested store view not found.
101 Product not exists.
102 Invalid data given. Details in error message.
103 Requested image not exists in product images’ gallery.
104 Image creation failed. Details in error message.
107 Requested product doesn’t support images

product_media.remove (string $sku, string $file)

Remove product image

Parameters

orderdescription
0 string - Product SKU.
1 string - Image file.

Return Value

True, if the image has been removed

Example Request

{
    "jsonrpc" : 2.0,
    "id" : 1234,
    "method" : "call",
    "params" : [
        "be1c13ed4e03f0ed7f1e4053dfff9658",
        "product_media.remove",
        [
            "product2",
            "/b/l/blackberry8100_2.jpg"
        ]
    ]
}

Example Response

{
    "jsonrpc" : 2.0,
    "id" : 1234,
    "error" : null,
    "result" : 1
}

Error Codes

code message
100 Requested store view not found.
101 Product not exists.
106 Image not removed. Details in error message.
107 Requested product doesn’t support images

Entity Properties

Image Type Properties

code
{ "code" : "image" }
A unique identifier for an image type. Allowed: "image", "thumbnail".
scope
{ "scope" : "global" }
The "Scope" property. Allowed: "global", "website", "store".

Image Mime Type

image/jpeg
{ "mime" : "image/jpeg" }
JPEG
image/gif
{ "mime" : "image/gif" }
GIF
image/png
{ "mime" : "image/png" }
PNG

Image Data

file Creating a new file:
{ "file" : { "content" : "base64 encoded content", "mime" : "image/jpeg" }}
Retriving existing file:
{ "file" : "/b/l/blackberry8100_2.jpg" }
position
{ "position" : 3 }
exclude
{ "exclude" : 1 }
Allowed: "0" or "1".
url
{ "url" : "https://shipstream.io/media/catalog/product/b/l/blackberry8100_2.jpg" }
types
{ "types" : ["image", "thumbnail"] }
Allowed: "image", "thumbnail".