How to get collection object in product list api

Raj-mindstask
Visitor
1 0 0

Hi there,

 

Currently i fetching product list using collection id. Suppose i have 10 collection and each collection have 100 products to get all product it takes around 20 seconds. so, it is very difficult performance wise.

is there any single API to get all product along with collection information.

 

Thanks 

Reply 1 (1)
GrahamS
Shopify Staff (Retired)
Shopify Staff (Retired)
193 36 53

Hey Raj,

 

This is an instance where GraphQL would be a better choice compared to REST. Rather than querying every collection by id and pulling the associated products, you could do something like 

 

query {
	collections(first: 10) {
		edges {
			node {
				products(first: 100) {
					edges {
						node {
							id
							title
						}
					}
				}
			}
		}
	}
}

 

Against the single GraphQL endpoint. You'll need to adjust for complexity since GraphQL uses a different bucket/rate limiting method compared to REST, but it should still be a faster solution overall.

To learn more visit the Shopify Help Center or the Community Blog.