How to get product meta-fields from Admin API

Hi,

I need to get product meta-fields from the Admin /products.json API but it doesn’t return the meta-fields but I’m able to get products meta-fields from /products/123/metafields.json for a single product it would be heavy to get meta fields data for a product by product so how to get products meta-fields on /products.json API?

And I’m using https://apps.shopify.com/accentuate to set meta fields for products

Thank you

You can’t make a query to /admin/products,json in rest to get metafields into the response. Why is pulling the data from each product not a viable option with the rest api?

Hi Jason,

Can you explain how?
I dont see any parameters that allow this.

Thanks,
Mathieu

Hi @RyanWong

There is an API Endpoint to handle with Metafields:
https://shopify.dev/docs/api/admin-rest/2023-07/resources/metafield#get-metafields?metafield[owner-id]=382285388&metafield[owner-resource]=blog

BTW there is an example of how to get products metafields on the link above.

Basically, you must use “product” on the “owner_resource” param, for example:

Metafield::all(
    $this->test_session, // Session
    [], // Url Ids
    ["metafield" => [
         // Params
        "owner_id" => "632910392", 
        "owner_resource" => "product"]
    ],
);