Development discussions around Shopify APIs
We can't seem to find the product image urls from the Shopify APIs. It is not in the following tables: product, product_variant or product_option, and it is not listed in the Abandoned Basket API. Where can it be found?
Solved! Go to the solution
This is an accepted solution.
REST - The src property, aka Source, specifies the location of the product image for a Product Image
Product resource > Images property - https://shopify.dev/api/admin/rest/reference/products/product
Get a Product /admin/api/2021-07/products/{product_id}.json
Product Image(s) are also their own stand alone resource(s)
Get all images on a product /admin/api/2021-07/products/{product_id}/images.json
Get a specific Image using the ProductImage ID - /admin/api/2021-07/products/{product_id}/images/{image_id}.json
Retrieve only particular fields from a single product I.E. https://shopify.com/admin/products/123.json?fields=id,images,title :
{
"product": {
"images": [
{
"id": 1234,
"product_id": 123,
"position": 1,
"created_at": "2020-06-23T14:14:53-04:00",
"updated_at": "2020-06-23T14:14:53-04:00",
"alt": null,
"width": 1024,
"height": 1024,
"src": "https://cdn.shopify.com/s/files/1/1234/1234/products/file-name_1024x_<36characterhash>.jpg?v=1",
"variant_ids": [
],
"admin_graphql_api_id": "gid://shopify/ProductImage/123"
}
]
}
}
This is an accepted solution.
REST - The src property, aka Source, specifies the location of the product image for a Product Image
Product resource > Images property - https://shopify.dev/api/admin/rest/reference/products/product
Get a Product /admin/api/2021-07/products/{product_id}.json
Product Image(s) are also their own stand alone resource(s)
Get all images on a product /admin/api/2021-07/products/{product_id}/images.json
Get a specific Image using the ProductImage ID - /admin/api/2021-07/products/{product_id}/images/{image_id}.json
Retrieve only particular fields from a single product I.E. https://shopify.com/admin/products/123.json?fields=id,images,title :
{
"product": {
"images": [
{
"id": 1234,
"product_id": 123,
"position": 1,
"created_at": "2020-06-23T14:14:53-04:00",
"updated_at": "2020-06-23T14:14:53-04:00",
"alt": null,
"width": 1024,
"height": 1024,
"src": "https://cdn.shopify.com/s/files/1/1234/1234/products/file-name_1024x_<36characterhash>.jpg?v=1",
"variant_ids": [
],
"admin_graphql_api_id": "gid://shopify/ProductImage/123"
}
]
}
}
Thanks so much Paul for your help!
GraphQL - Image - https://shopify.dev/api/admin/graphql/reference/common-objects/image
{
products(first:1,query:"id:4596216102958"){
edges {
node {
featuredImage {
id
}
# current max images on a product is 250
images(first:250) {
edges {
node {
id
originalSrc
transformedSrc
}
}
}
}
}
}
}
Note there are also the objects: Media , MediaImage and MediaPreviewImage . Review https://shopify.dev/api/admin/graphql/reference/products-and-collections
Hi Paul,
thanks for showing how this is done in REST and GraphQL.
Sadly the 2021-10 version of the GraphQL API doesn't support the src and url fields anymore. I couldn't find any possible way to get the URL of an image.
I have code copying collections with all their fields. This doesn't seem to work anymore. It looks like, I have to upload the image every time now.
Or do I miss something?
I am seeing this with 2021-10, too, although `src` is deprecated, it says to use `url` instead, but `url` is not available yet. src still works for now, however.
User | RANK |
---|---|
10 | |
4 | |
3 | |
3 | |
3 |
As a business owner, have you ever wondered when your customer's first impression of yo...
By Skye Jun 6, 2023We're excited to announce improvements to the threaded messaging experience in our communi...
By TyW May 31, 2023Thank you to everyone who participated in our AMA with Klaviyo. It was great to see so man...
By Jacqui May 30, 2023