Access shop metafields on product page from a script

Is there a way to access shop metafields on a product page from a script, i.e. a JS resource loaded on a product page?
If not possible to do so directly, what is the best way to make an authenticated call to Shopify APIs to retrieve this information?

For an online sales channel theme, in liquid filter the specific metafield for a resource into json objects.

To then have it in the rendered html, put the json in a script tag or as a value in a data attribute,etc

Alternatively make it it’s own section and call it through the section-rendering ajax api.

Or give it it’s own view template , though with that method the mime type will never be javascript.

Plenty of forum posts on techniques for serving custom javascript/json.

https://shopify.dev/api/liquid/filters/additional-filters#json

https://shopify.dev/docs/themes/sections/section-rendering-api

Make a app where you access that data, either in a scripttag, proxyapp, or your apps urls.

Hi Paul. Thanks for the quick reply. I am indeed building a public app, not a theme - probably should have clarified that in the question. The app adds a script to a store using scriptTagCreate. Then when the script is executed, in it I want to be able to access the shop’s metadata (which I set during the app installation).

What did you mean by “Make a app where you access that data, either in a scripttag, proxyapp, or your apps urls.”? Do you have some more specific pointers?

Thanks!

You need to get that data you set and use it on your side of things to include it in your scripttag.

Your asking a very broad question better served by reviewing the docs first.

https://shopify.dev/apps/metafields

What did you mean by “Make a app where you access that data, either in a scripttag, proxyapp, or your apps urls.”? Do you have some more specific pointers?

Those are different online store integration types see the dev docs

https://shopify.dev/apps/online-store