I have to return all metafields that are created in one store. The API call above just returns me an empty list even though I’ve created metafields and checked “Expose this metafield to Storefront API requests”. It also says that it retrieves a list of metafields from the resource’s endpoint. In this URL I don’t see where i should provide the resource.
Can someone please explain how is this supposed to work? And could this request be used to return metafields for one resource only (for example Customers or Products).
If not is it possible to extract metafield values using this API?
/admin/api/2022-07/customers.json
I see there is a “fields” parameter that is supposed to show only certain fields, but I’m not sure how to make use of it.
You can get a list of Metafields under a specific resource by specifying the resource’s ID in the URL.
For example:
// get list of products
https://your-development-store.myshopify.com/admin/api/2022-07/products.json
// get details of product with ID 2342
https://your-development-store.myshopify.com/admin/api/2022-07/products/2342.json
// get metafields of product with ID 2342
https://your-development-store.myshopify.com/admin/api/2022-07/products/2342/metafields.json
Thank you for the answer. I’m aware of this solution but I’m afraid that this will really slow the execution. You are saying there is no way to return list of all existing metafields and then filtering it by resource? What I mean by this is, I need metafields for all resources that can have metafields (in this case it’s: Article, Blog, Collection, Smart Collection, Customer, Draft Order, Location, Order, Page, Product, Product Image, Product Variant and Shop). And only after I get the whole list of metafields to be able to filter it by the specific resource.