How to filter GET deals api

Hi,

I’m trying to get all of my deals that are currently in the default pipeline and in the lead stage. I can’t make the call to get all deals since the number of objects is too high. What the correct way of doing this?

Hey, @Anze_Koprivec :waving_hand: Did you get this worked out? If not, the short version is you’ll use pagination and multiple requests.

Quick overview:

  • make a request
  • note the value returned for the property paging.next.after
  • include this value for after in your next call

If it’s helpful, I can create an example using the on-page example for the GET/crm/v3/objects/deals Deals endpoint.

Best,

Jaycee

Hi Jaycee,

yes I’ve tried that solution myself but was just wondering if there is any way to be able to set some filters or query params to the GET call so it automaticly returns the filtered values without me having to try getting all of the deals and then filtering them as the company has way too many deals for that to be efficient.
Thank you for your help.

Kind regards,

Anze

Hi, @Anze_Koprivec! Thanks for clarifying.

We can use the Search Endpoints for this, as it will allow us to use filters in the manner you are describing.

Quick steps:

  • I have a Deals Pipeline called Sales with an internal value of default
  • I have a deal stage in that pipeline called Appointment scheduled with an internal value of appointmentscheduled with six deals in this pipeline and stage currently
  • I’ll use this endpoint POST /crm/v3/objects/deals/search
  • I’ll use filters in the request body + a search operator to return only deals who meet both filters — pipeline and deal stage

Example using my test portal:

  • Request
    POST https://api.hubapi.com/crm/v3/objects/deals/search​
    Body

    {
     "filterGroups":[{
     "filters":[
     {
     "propertyName": "pipeline",
     "operator": "EQ",
     "value": "default"
     },
     {
     "propertyName":"dealstage",
     "operator":"EQ",
     "value": "appointmentscheduled"
     }
    ]
    }
    ]
    }​
    
  • Response

    {
     "total": 6,
     "results": [
     {
     "id": "9435654818",
     "properties": {
     "amount": null,
     "closedate": "2022-08-26T17:28:05.450Z",
     "createdate": "2022-07-08T17:28:15.576Z",
     "dealname": "Test2",
     "dealstage": "appointmentscheduled",
     "hs_lastmodifieddate": "2022-10-24T19:58:04.003Z",
     "hs_object_id": "9435654818",
     "pipeline": "default"
     },
     "createdAt": "2022-07-08T17:28:15.576Z",
     "updatedAt": "2022-10-24T19:58:04.003Z",
     "archived": false
     },
     ...
     "createdAt": "2023-02-02T18:15:18.190Z",
     "updatedAt": "2023-03-17T20:36:09.955Z",
     "archived": false
     }
     ]
    }​
    

I hope this helps!

Best,

Jaycee

How to filter GET deals API with company ids

hi @Jaycee_Lewis thanks for your reply.

Is there any way to get the company id’s in association with the deals with the filtering based on the closed won stage?