Get a list of all variant metafields

Hello Shopify community,

is there a way to get a list of all variant metafields and not only the metafields of a single product variant ?

Currently i’m requesting a list of all products what happens very fast, but after that i have to loop through every product and variant to GET request each variants metafields and that takes some time.

I`m using

/admin/metafields.json?metafield[owner_id]=85675678&metafield[owner_resource]=variants

and tried leaving the owner_id blank so id get all metafields of the owner_resource variants, but that didnt work. :confused:

Thanks for your help!

Hi @JasonP99 ,

It’s not possible to get the complete list of all variants’ metafields via the REST API. The endpoints here are built in the way that requires a separate request to retrieve the data for each product variant. You may want to use the GraphQL API instead.

1 Like

Okay, that helped me a lot. Thanks for your answer!

How can I retrieve a metafield of each product variant using variant id?

Hi @kaye_tee ,

You can retrieve a Product Variant’s metafields with the variant ID on both the REST and GraphQL Admin API with the following endpoints and queries as described in our Shopify.dev documentation:

  • Metafield - REST Admin API Reference

    • you can retrieve metafields from any resource that contains metafields by adding /metafields.json to the end of the respective resources endpoint.
    • Example with a Product Variant ID: GET https://{{shop}}.myshopify.com/admin/api/2024-04/variants/<variant_id>/metafields.json
  • ProductVariant - GraphQL Admin API Query

    • you can retrieve metafields from the ProductVariant object directly with the following query:

{> productVariant(id: "gid://shopify/ProductVariant/

I hope this helps, and I hope you have a great day :slightly_smiling_face: