How to access product's collections from the storefront?

I have a theme app embed extension, and need to validate if X product is present in a Y collection at any moment.

I understand that with liquid I can access to collections data, but I need to be able to validate this for any product in any page in the client side javascript of my extension.

I have tried fetching the /collections/<collection-handle>/products.json endpoint, but the product list is always limited to 30, and even if the list was unlimited, it wouldn’t be ideal to get 1000s of products each time I need to check for the product collections.

I have also tried fetching with product_id: /collections/<collection-handle>/products.json?product_id=<id>, but it doesn’t filter the resulting products at all.

What is the best way to achieve this? Will I need to use the Admin API?

Have you looked at the Storefront API?

Hi @Luke, what would be the difference between using the Storefront API and using the GraphQL API via a proxy in this case? I’m a bit confused because both APIs can be used to access product data.