Solved

Where can I find Product image URL in the Shopify API?

Hanna6
New Member
4 0 0

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?

Accepted Solution (1)

PaulNewton
Shopify Partner
6339 579 1345

This is an accepted solution.

REST -  The src property,  aka Sourcespecifies 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"
      }
    ]
  }
}

 

Save time & money ,Ask Questions The Smart Way


Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org


View solution in original post

Replies 5 (5)

PaulNewton
Shopify Partner
6339 579 1345

This is an accepted solution.

REST -  The src property,  aka Sourcespecifies 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"
      }
    ]
  }
}

 

Save time & money ,Ask Questions The Smart Way


Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org


Hanna6
New Member
4 0 0

Thanks so much Paul for your help!

PaulNewton
Shopify Partner
6339 579 1345

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 

Save time & money ,Ask Questions The Smart Way


Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org


Andreas_Sch
Excursionist
18 0 5

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?

gwg
Shopify Partner
5 1 1

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.