Access Metafields data through rest api python

Hello,

I am trying to access information on a product that is stored in a metafield (named “mm-google-shopping.mpn”) however when trying to use product.metafields there are no methods I can use to fin the values and it just returns “<bound method Metafields.metafields of product(…)>” I have used product.attributes to get all the information stored in a product and the same for the variants but havent had any success on metafields. is there a way to do this without having to set up a whole graphQL system?

Thanks.

PS no python label so posting under liquid sorry

Accessing the metafields requires a second REST API call so instead of accessing them as an attribute you need to call metafields() as a function. The following should return the metafields for a product assuming you have the session setup:

api_product = shopify.Product.find()[0]
api_product.metafields()

Long-term you’ll probably need to move to GraphQL to continue to access it but this should work for now. I hope it help!

1 Like

That works fine thank you very much!

1 Like