Rest API: Load Product Image Metafield

Topic summary

Issue: How to load Shopify product image metafields via the REST Admin API.

Attempts that failed:

  • GET /api/2022-04/products/{product_id}/images/metafields.json
  • GET /api/2022-04/images/{image_id}/metafields.json

Context provided (not solving the metafields question):

  • Endpoints to retrieve image_id via products/variants and product images, e.g. GET /admin/api/{version}/products/{productId}.json and GET /admin/api/{version}/products/{productId}/images/{imageId}.json.

Proposed solutions:

  • Use GraphQL Admin API and the Image.metafield field (suggested as the simpler approach).
  • REST alternative: query metafields filtered by owner_id and owner_resource=product_image:
    • GET /admin/api/{version}/metafields.json?metafield[owner_id]={image_id}&metafield[owner_resource]=product_image
    • Also noted: product-level metafields via GET /admin/api/{version}/products/{productId}/metafields.json and specific metafield via GET /admin/api/{version}/products/{productId}/metafields/{metafieldId}.json.

Notes:

  • REST vs GraphQL: two API paradigms; GraphQL was recommended for maintainability.
  • Outcome: No confirmation that the REST filters returned image metafields; discussion remains open without a verified resolution.
Summarized with AI on February 9. AI used: gpt-5.

Hi @alessandro04 ,

Look at this responses (for Variants images):

Look at this responses (for Product images):

After u get an ‘image_id’ u can request it from [GET] /admin/api/{api-version}/prodcts/{productId}/images/{imageId}.json

NOTE: To simplify this process, use the GraphQL AdminAPI

I hope this helps. If not, describe the problem in a little more detail, with code examples. :wink: