Api calls limit to retrive related products from deal

Hi!
I have already checked some posts and have some thoughts about what to do, but still need help with resolving the way I should fix it.
I have program that receives data from product by deal id.
Issue related to the deal with 267 products in it.
What i do:
1. I retrive by objectId list of all products ids.
I fetch them by:

https://api.hubapi.com/crm/v3/associations/deal/{objectId}/batch/read

From the response i take array with ids.
And here is the 1st problem - I receive only 100. I see that it can be solved somehow with query parameter after. But how can I understand how much products at all, to function that will by loop get ids products ? Or I miss something here ?

2. Then I make request with each ID to get needed data.
I’m not sure that making promise all with 267 items is good idea, but I don’t know how to do it correctly.
Now I have this:

 const productsRequests = recordIdArr.map((recordId) => {
 return fetch(
 `https://api.hubapi.com/crm/v3/objects/2-45666582/${recordId}${propertiesList}`,
 {
 method: "GET",
 headers: {
 Authorization: `Bearer ${token}`,
 },
 }
 ).then((response) => response.json());
 });

 const productsResponses = await Promise.all(productsRequests);

After that I usually have all data from all products. But how to do it with great amount ?

Appreciate any advice how to resolve this.

Hi @Oldu, I hope that you are well!
Thanks for asking the HubSpot Community!
I’d love to put you in touch with our Top Experts: Hi @sylvain_tirreau, @Anton and @zach_threadint do you have suggestions to help @Oldu, please?
Have a lovely day and thanks so much in advance for your help! :star:
Bérangère

Hey @Oldu,

the

https://api.hubspot.com/crm/v3/associations/deal/{objectId}/batch/read

endpoint is good for getting getting infos about deals, but since you’d like to get the individual line items info, you might wanna use

https://api.hubspot.com/crm/v3/objects/deals/{dealId}/associations/line_items

instead.

The 100 results are derfault as the API is limited to this amount by default.

If you want to increase it, you have to modify the request like

https://api.hubspot.com/crm/v3/objects/deals/{dealId}/associations/line_items?limit=267

Just change the limit number to your desired number of results.

For the second part:

I’d recommend to add a batch-size to the code to minimize the requests.

Hope this helps

best,

Anton