ListingImage
Overview
A photograph of a listing for sale.
Supported Sizes
The ListingImage resource includes
fields for the following sizes, which are officially supported by Etsy:
Size |
Where We Use It |
75x75 |
small thumbnail |
170x135 |
homepage, treasuries, shop listings |
570xN |
listing page |
fullxfull |
listing page zoom |
Additional sizes are available but do not have specific fields in the
resource. Instead, treat the full size URL as a template. Use the
ImageType methods to retrieve available sizes for listing images;
any of these can be subsituted in place of "fullxfull" in the full size
URL to make a new URL for the listing image of that size.
The 570xN
and fullxfull
image sizes have variable dimensions depending on the original artwork uploaded by the seller:
- For the
570xN
size, the horizontal dimension will be the original artwork's horizontal size, or 570 pixels, whichever is smaller. Likewise for all other *xN images
- For the
fullxfull
size, the horizontal dimension will be the original artwork's horizontal size, or 3000 pixels, whichever is smaller.
- These sizes will have a variable vertical dimension, dependent on the original artwork's aspect ratio.
Resizing, Cropping and Caching Images
If the provided sizes don't suit your application, you are free to download the larger image sizes, resize and cache them for your own use, as long as you adhere to our API Terms of Use.
Uploading Images
Image uploads can be performed using a POST request with the Content-Type: multipart/form-data
header, following RFC1867. This is identical to using curl -F, except that that request needs to be signed using OAuth.
Your OAuth toolkit must support multipart form uploads as described above. Here is example code for PHP using the PECL OAuth 1.1 extension (PECL OAuth 1.0 will not work):
// You must define the constants OAUTH_CONSUMER_KEY and OAUTH_CONSUMER_SECRET
// You must also assign values to the variables $access_token, $access_token_secret,
// $listing_id and $filename, and $mimetype.
// Your image file is assumed to be in the same directory as this code.
$oauth = new OAuth(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET);
$oauth->enableDebug();
$oauth->setToken($access_token, $access_token_secret);
try {
$source_file = dirname(realpath(__FILE__)) ."/$filename";
$url = "https://openapi.etsy.com/v2/listings/".$listing_id."/images";
$params = array('@image' => '@'.$source_file.';type='.$mimetype);
$oauth->fetch($url, $params, OAUTH_HTTP_METHOD_POST);
$json = $oauth->getLastResponse();
print_r(json_decode($json, true));
} catch (OAuthException $e) {
// You may want to recover gracefully here...
print $oauth->getLastResponse()."\n";
print_r($oauth->debugInfo);
die($e->getMessage());
}
Fields
Field |
Visibility Level |
Permission Scope |
Type |
Description |
listing_image_id
|
public |
none |
int |
The numeric ID of the listing image.
|
hex_code
|
public |
none |
string |
The image's average color, in webhex notation.
|
red
|
public |
none |
int |
The image's average red value, 0-255 (RGB color).
|
green
|
public |
none |
int |
The image's average green value, 0-255 (RGB color).
|
blue
|
public |
none |
int |
The image's average blue value, 0-255 (RGB color).
|
hue
|
public |
none |
int |
The image's average hue, 0-360 (HSV color).
|
saturation
|
public |
none |
int |
The image's average saturation, 0-100 (HSV color).
|
brightness
|
public |
none |
int |
The image's average brightness, 0-100 (HSV color).
|
is_black_and_white
|
public |
none |
boolean |
True if the image is in black & white.
|
creation_tsz
|
public |
none |
float |
Creation time, in epoch seconds.
|
listing_id
|
public |
none |
int |
The numeric value of the listing id the image belongs to.
|
rank
|
public |
none |
int |
Display order.
|
url_75x75
|
public |
none |
string |
The url to a 75x75 thumbnail of the image.
|
url_170x135
|
public |
none |
string |
The url to a 170x135 thumbnail of the image.
|
url_570xN
|
public |
none |
string |
The url to a thumbnail of the image, no more than 570px width by variable height.
|
url_fullxfull
|
public |
none |
string |
The url to the full-size image, up to 3000px in each dimension.
|
full_height
|
public |
none |
int |
Height of the image returned by url_fullxfull.
|
full_width
|
public |
none |
int |
Width of the image returned by url_fullxfull.
|
Associations
Association |
Visibility Level |
Permission Scope |
Type |
Description |
Listing |
public |
none |
Listing
|
The listing to which the image belongs.
|
Methods
findAllListingImages
Method Name |
findAllListingImages |
Synopsis |
Retrieves a set of ListingImage objects associated to a Listing.
|
HTTP Method |
GET |
URI |
/listings/:listing_id/images |
Parameters |
Name |
Required |
Default |
Type |
listing_id |
Y |
|
int |
|
Requires OAuth |
N |
Permission Scope |
none |
uploadListingImage
Method Name |
uploadListingImage |
Synopsis |
Upload a new listing image, or re-associate a previously deleted one. You may associate an image
to any listing within the same shop that the image's original listing belongs to.
You MUST pass either a listing_image_id OR an image to this method.
Passing a listing_image_id serves to re-associate an image that was previously deleted.
If you wish to re-associate an image, we strongly recommend using the listing_image_id
argument as opposed to re-uploading a new image each time, to save bandwidth for you as well as us.
Pass overwrite=1 to replace the existing image at a given rank.
When uploading a new listing image with a watermark, pass is_watermarked=1; existing listing images
will not be affected by this parameter.
|
HTTP Method |
POST |
URI |
/listings/:listing_id/images |
Parameters |
|
Requires OAuth |
Y |
Permission Scope |
listings_w
|
getImage_Listing
Method Name |
getImage_Listing |
Synopsis |
Retrieves a Image_Listing by id.
|
HTTP Method |
GET |
URI |
/listings/:listing_id/images/:listing_image_id |
Parameters |
Name |
Required |
Default |
Type |
listing_image_id |
Y |
|
array(int) |
listing_id |
Y |
|
int |
|
Requires OAuth |
N |
Permission Scope |
none |
deleteListingImage
Method Name |
deleteListingImage |
Synopsis |
Deletes a listing image. A copy of the file remains on our servers,
and so a deleted image may be re-associated with the listing without
re-uploading the original image; see uploadListingImage
|
HTTP Method |
DELETE |
URI |
/listings/:listing_id/images/:listing_image_id |
Parameters |
Name |
Required |
Default |
Type |
listing_id |
Y |
|
int |
listing_image_id |
Y |
|
int |
|
Requires OAuth |
Y |
Permission Scope |
listings_w
|