Skip to main content
Question

Fetching More than 10500 products


  • Conversation Starter

Hi everyone,  I want to fetch all the products (in order to collect all the SKUs). But there is an maximum offset value 10000 and limit is 500. So, the possible amount of products to be fetched via API is 10500. is there any way to overcome this? I want to fetch around 20K products (it might grow in the feature).

Fetching based on categories is not working as expected. It ended up in lot of duplicate, limit issue.

Note: Had the same issue with orders. But , fetching the orders based on the createdAt field solved the issue. Products have the same createdAt date.

Thank you and kind regards, 
Raja

  • Going Places
  • April 27, 2025

Hi  ​@Raja ,
Please follow the below instructions to get all products 

  • Send a request to get products with total .
  • Once you got the total number of products, you need to send the products request with sort by id desc with a simple pagination logic
  • curl --location 'https://api.australia-southeast1.gcp.commercetools.com/{project-KEY}/products/search?limit=1' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer XXXXXXXXXXXXXXX' \
    --data ''
  • Apply the simple pagination logic to set the correct offset value 
  • curl --location 'https://api.australia-southeast1.gcp.commercetools.com/{project-key}/products?where=id%3E%22128416c1-e351-41fe-a4fb-7cbffefd0d99%22&sort=id%20asc&limit=500&withTotal=false&skip=1000' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer XXXXXXXXX' \
    --data ''
  • Apply the proper where condition and set the correct skip values.

    Hope the above CURL will help you 

Alex
Forum|alt.badge.img+1
  • Inspiring
  • May 27, 2025

Hi ​@Raja,

Just to complement ​@Phani ‘s response, the place in the docs where this is referenced is: https://docs.commercetools.com/api/general-concepts#iterate-over-all-elements

I think it’s good to also have an eye on the official docs, since things tend to evolve over time and snippets of code might become redundant in the future. 

 

Happy iterating! 😉


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings