Get all metafields for products

ReloadSEO
Shopify Partner
48 0 14

This has been posted before, but the Shopify support hasn't answered it yet... And it is a good and reasonable question. 

 

I want to get all the metafields for all the products.

My understanding is that there is no API like:

/admin/products/metafields.json

The only one is like this:

/admin/products/#productid#/metafields.json

Therefore, the only way is to get all the metafields for all the products is to make one API call per product!

It is also impossible to cache the data, because it takes one API call per product just to check if the metafields for that product have been updated!  For large stores, it is handicapping API applications and forcing one call per product, resulting in extremely time-consuming fetches for tiny amounts of data.

Can you please add an API call that works like this?  /admin/products/metafields.json

It would return all the metafields for all the products, 250 at a time.  We can then page through in a reasonable amount of time.

Or, does anyone know some other workaround to get all the product metafields at once?

Replies 63 (63)
Jamie_D_
Shopify Staff (Retired)
531 1 103

Hey ReloadSEO,

There's currently no way to achieve this through the current API. However, we're aware that this is something that developers are interested in and we're actively looking into finding a solution.

Keep an eye on the API Announcements forum for any updates regarding this.

Cheers,

Jamie

Jamie | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

John81
Tourist
3 0 1

Just run into this problem myself. Haven't been able to find a workaround sorry. I agree with your request to extend the API though and would like to add that /products should be able to return metafields_global_title_tag and metafields_global_description_tag (if it doesn't already, maybe there's a way to specify the fields value of the request for it?).

Thomas47
Shopify Partner
55 0 11

Hi Jamie,

please include the functionality so to get all metafields for certain ids (add ids[] paramter). I'd like to get the metafields for a list of products (i.e. metafields for all products in an order).

Must say I am very disappointed to see this lacking the API and also finding threads that are more than two and a half years old on this topic. 

Please commit to a production date (or sprint, release) for these updates.

Best regards,

Thomas

 

 

Dan_Chow
Shopify Partner
19 0 4

I am also interested in more information here. What is the intended use/meaning of this section of the docs pertaining to metafields? This makes it look like we should expect to be able to obtain product metafields at the /admin/metafields.json resource, and filter for conditions; however when I tried this on my store, only the 'store' metafields were returned. Accessing metafields a single product at a time is not at all an efficient use of the limited API call resource. Really need someway to obtain this information in a single, or a few, calls : 

https://texansaddles-com.myshopify.com/admin/metafields.json?metafield[owner_resource]=product

I was able to pull a single product metafields at the following address, but this is a duplicate of the resource at /admin/products/{id}/metafields.json:

https://texansaddles-com.myshopify.com/admin/metafields.json?metafield[owner_id]=6107959043&metafiel...

From the Docs:

https://docs.shopify.com/api/reference/metafield

GET/admin/metafields.json

Get metafields that belong to a product image

Get all metafields that belong to the images of a product

GET /admin/metafields.json?metafield[owner_id]=850703190&metafield[owner_resource]=product_image

Hide Response

HTTP/1.1 200 OK
{
  "metafields": [
    {
      "id": 625663657,
      "namespace": "translation",
      "key": "title_fr",
      "value": "tbn",
      "value_type": "string",
      "description": "French product image title",
      "owner_id": 850703190,
      "created_at": "2016-03-17T17:04:49-04:00",
      "updated_at": "2016-03-17T17:04:49-04:00",
      "owner_resource": "product_image"
    }
  ]
}
Dan_Chow
Shopify Partner
19 0 4

It was also frustrating to find that the metafields for a product are not included in that product's json when called at /admin/products/{id}.json, or as part of the list from /admin/products.json. This would have been an intuitive way to access metafields associated with products.

Mitchmaster
Tourist
3 0 3

I find it hard to believe that Shopify has been "researching a solution" to this problem for years. It should take 10 minutes of programming to solve given that identical capabilities already exist at other levels of the API. Having to do a separate curl call to find out if each product has a given metafiled makes this useless for a live page - it can take up to a minute to load. Please expedite a solution!

Jonathan-HA
Trailblazer
202 10 55

+1 for this. Would also be nice to be able to specifiy a list of product_ids and get the metafields for them.

We have a CSV exporter app and one of our customers asked if we could include metafields in the report. With the current API implementation, it's too expensive to make an API call for each unique product included in the report.

Co-Founder / Developer at Highview Apps
Our Shopify Apps: EZ Exporter | EZ Inventory | EZ Importer | EZ Notify | EZ Fulfill
bolle
Excursionist
24 1 5

Any updates here?
This is needed, otherwise the metafields are stuck in a far off land with the API call limit.

bolle
Excursionist
24 1 5

Thanks HunkyBill. 

Maybe you could help me figure out the logic for this.

I'm creating a private app for my client. I was hoping to use metafields to allow us to change a binary option (true/false) for each customer.

In my app I list all of the customers in the shop, and ideally I'd like to display this metafield within the list as well.

Ex. First Name, Last Name, Address, Binary Metafield, etc


I obviously have the /customers.json GET working properly with all customer info, now I'm working on the metafields.

How could I grab this metafield for each customer, without making x # of requests (depending on how many customers)?

I hope this isn't an extremely simple solution, but I can't think of any way around the API limit for this. 
I've just started using the Shopify API (yesterday) so I am a bit new at this.

 

Thanks HunkyBill!