This API endpoint allows a merchant to manage product media such as images.

Methods


Entity Properties


product_media.list

product_media.list (string $sku) Retrieve list of product images

Parameters

sku
string
Product SKU.

Return Value

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

Example Request

Get product images by product SKU:
Request
{
    "jsonrpc" : 2.0,
    "id" : 1234,
    "method" : "call",
    "params" : [
        "be1c13ed4e03f0ed7f1e4053dfff9658",
        "product_media.list",
        [
            "product2"
        ]
    ]
}

Example Response

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

codemessage
100Requested store view not found.
101Product not exists.

product_media.types

product_media.types (number $setId) Retrieve product image types

Parameters

setId
integer
Attribute set id.

Return Value

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

Example Request

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

Example Response

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

product_media.create

product_media.create (string $sku, object $data) Upload new product image

Parameters

sku
string
Product SKU.
data
object
Image data.

Return Value

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

Example Request

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

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

Error Codes

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

product_media.update

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

Parameters

sku
string
Product SKU.
file
string
Image file name.
data
object
Image data.

Return Value

true, if the image has been uploaded

Example Request

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

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

Error Codes

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

product_media.remove

product_media.remove (string $sku, string $file) Remove product image

Parameters

sku
string
Product SKU.
file
string
Image file.

Return Value

true, if the image has been removed

Example Request

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

Example Response

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

Error Codes

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

Entity Properties

Image Type Properties

Image Mime Type

Image Data