Hello,
I want to access product variant data by handle and variant ID, but not from the product page. Currently, I’m looking for a solution on how to do this.
-
https://store.myshopify.com/products/the-complete-snowboard.json does not work for me because I need the quantity and selling plans values;
-
I do not want to create a custom API request from client-side to server-side using proxy. It can be a lot of requests to the server;
-
The last solution which I’m trying investigate more, but I cannot find enough information, is https://shopify.dev/docs/api/storefront :
-
When does publicAccessToken expire, or does it not expire?
-
https://shopify.dev/docs/api/usage/authentication#access-tokens-for-the-storefront-api states that I need to provide the buyer’s IP via “Shopify-Storefront-Buyer-IP” parameter. How can I obtain the IP? Can I use this service: https://json.geoiplookup.io/? “client.request” does not accept “Shopify-Storefront-Buyer-IP” parameter
-
How much does an API query cost? Is it unlimited, or does a request return a GraphQL throttle error?
My code:
useEffect(() => {
(async function () {
const client = createStorefrontApiClient({
storeDomain: "https://my.myshopify.com",
apiVersion: "2025-01",
publicAccessToken: "123456",
retries: 3,
});
const productQuery = `
query ProductQuery($handle: String!) {
product(handle: $handle) {
id
}
}
`;
try {
const { data } = await client.request(productQuery, {
variables: {
handle: "product-handle",
},
});
} catch (e) {
throw e;
}
})();
}, []);