# How does offset work for allDeals

**URL:** <https://community.hubspot.com/t/how-does-offset-work-for-alldeals/16373>\
**Category:** APIs & Integrations\
**Tags:** object\
**Created:** [September 22, 2019, 4:37pm UTC](https://community.hubspot.com/t/how-does-offset-work-for-alldeals/16373 "2019-09-22T16:37:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rami123](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rami123/32/29572_2.png) [@rami123](https://community.hubspot.com/u/rami123)\
**Post date:** [September 22, 2019, 4:37pm UTC](https://community.hubspot.com/t/how-does-offset-work-for-alldeals/16373/1 "2019-09-22T16:37:41Z")

</div>

Hi,

I am making all deals API call and wanted to understand how the offset works, I understand it has the next page dealid if it has more pages. I has few questions below

- what order is the reponse returned? by create date of the dealid? assuming lower dealid are created first?

- I am getting duplicate dealids in different offset pages, Is dealid not unique?

- is there a way to contol by dates than dealid like since? or from/to dates? That way it is easier to batch teh records than rerun the who thing

- I am setting to stop at hasmore =false|False it goes into infinite loop. I checked by seting hasmore=True it stopped

thanks

---

<div class="post-metadata">

**Author:** ![rami123](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rami123/32/29572_2.png) [@rami123](https://community.hubspot.com/u/rami123)\
**Post date:** [September 22, 2019, 5:38pm UTC](https://community.hubspot.com/t/how-does-offset-work-for-alldeals/16373/2 "2019-09-22T17:38:18Z")

</div>

Hi,

one update -

I am setting to stop at hasmore =false|False it goes into infinite loop. I checked by seting hasmore=True it stopped

This work with hasmore =False, i had it as false.

---

<div class="post-metadata">

**Author:** ![WendyGoh](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/wendygoh/32/42320_2.png) [@WendyGoh](https://community.hubspot.com/u/WendyGoh)\
**Post date:** [September 23, 2019, 4:10am UTC](https://community.hubspot.com/t/how-does-offset-work-for-alldeals/16373/3 "2019-09-23T04:10:45Z")

</div>

Hi @rami123,

I hope all is well with you 😄

Let’s walk through the questions one by one:

#1

The sorting of the deal response would be from the oldest created date to the newest created deal.

#2

I wouldn’t expect to see a duplicate deal id as deal id are unique. Do you mind sharing with me some examples where you’re seeing duplicate deal id? Also, just to clarify you’re using this endpoint: [Get all deals](https://developers.hubspot.com/docs/methods/deals/get-all-deals) to retrieve deals in your account, is that right?

#3

For now, it is not possible to filter deals based on properties. If you haven’t already done so, I’d suggest for you to do an upvote and comment on this idea page: [HubSpot Community - Search contacts, companies and deals by custom pro… - HubSpot Community](https://community.hubspot.com/t5/HubSpot-Ideas/Search-contacts-companies-and-deals-by-custom-properties/idi-p/32113)

#4

I’m not too sure if I’m understanding this, do you mind when you use the condition hasmore = false, the for loop will continue looping? In this case, could you share with me the code that you wrote to loop through the results?

---

<div class="post-metadata">

**Author:** ![rami123](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/rami123/32/29572_2.png) [@rami123](https://community.hubspot.com/u/rami123)\
**Post date:** [September 24, 2019, 9:27pm UTC](https://community.hubspot.com/t/how-does-offset-work-for-alldeals/16373/4 "2019-09-24T21:27:41Z")

</div>

Thanks for quick reply!

#2 & #4 are related. When i had hasmore = False it worked.
