Hello Is there any API exist to get product details like price by productID ?
AI-generated summary
Main issue: Fetch product details (e.g., price) by product ID in a Shopify context.
- Proposed solution: Use Shopify Admin REST API endpoint GET /products/{product_id}. This requires an Admin access token.
- Constraint: The requester’s calls originate from the storefront, so they cannot generate an Admin access token. They mentioned finding another approach but did not share details.
Storefront/theme workaround (no Admin API):
- Use Liquid in the theme to filter collections.all.products by id and assign the matching product. A user confirmed it works.
- Limitation: By default, only the first 50 products are iterated, so it may miss items. A suggestion is to wrap the lookup in a paginate block (e.g., by 1000) to extend coverage, with a caution about potential performance impacts on large catalogs.
Status/outcome:
- Admin API is viable with proper credentials; not suitable for unauthenticated storefront calls.
- Liquid-based workaround works but has scalability/performance caveats.
- The original poster has not shared their alternative solution; discussion remains open.
Hi @masumluf ,
Hope you are doing well.
You can use the below mentioned API to fetch the product details using product id.
https://shopify.dev/api/admin-rest/2022-04/resources/product#get-products-product-id
Please mark it as a solution and leave a like if you find it helpful.
Cheers!!
Shubham
My api request will come from a store front , so I can not generate access token , i need to call another api to generate api token. so this method wont help me. but I found a solution in another way.
That is great!
Could you share that solution here as well so it will help others who might need it? ![]()
Yes please share the solution you found
Use the below code to get the product information by product id
{% assign product_id = param | times: 1 %}
{% assign products_obj = collections.all.products | where: 'id', product_id %}
{% assign product = products_obj[0] %}
Where param is your product id. Let me know if that’s work for you
@Sha_Hassan This works perfectly for what I needed!
Perfect, @masumluf did it work for you as well?
This method is limited to 50 iterations, therefore it will only check for the 50 first products of the collection. In other words: it might not work.
I think you could still do:
{% paginate collections.all.products by 1000 %}
{% assign product_id = param | times: 1 %}
{% assign products_obj = collections.all.products | where: 'id', product_id %}
{% assign product = products_obj[0] %}
{% endpaginate %}
But this is a “trick” and if the collection starts to get too big this could make performances worst, so use with caution.