简体   繁体   中英

How can I authenticate Shopify API from within my store's theme?

I want to access the admin/products.json and admin/metafields.json within my theme's javascript, so that I can display certain data outside of the product's page. Is it possible to do this within my theme files, or is it required that I create an external API application?

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

(example URL: https://apikey:password@hostname/admin/resource.json )

I have created a "Private App" API Key/Password through Shopify dashboard. How can I authenticate a GET request within a javascript file that is part of my theme, so I can create variables from the data?

What I'm actually trying to accomplish is showing data (metafields) from certain products on a related product pages. All the info I need is in these 2 JSON files

Creating and external app seems a bit overkill for obtaining data within my shop, but if this is required, how should I go about this? I'm not an expert with APIs or creating apps and I've been reading everything to find a best course of action.

Thanks!

You don't need to make app to fetch data through API within store itself. Just do a ajax request having url "/admin/products.json" and it will return data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM