Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

How to get collection object in product list api

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)
193 37 55

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.