How do I only show open Deals in a search ?

New Contributor

I would like to only return all deals that are open for an account.

How would I accomplish this using v3 of the deals search ?

Reply
0 Upvotes
4 Replies 4
Community Manager

Hi @RyanBlack ,

Thank you for sharing your query in the HubSpot Community.

I wanted to tag in some subject matter experts here: @HenryCipolla and @DanielSanchez , woud you mind sharing your advice for @RyanBlack ?

Reply
0 Upvotes
New Contributor

Any updates on this ?

Reply
0 Upvotes
Community Manager

Hey @RyanBlack ,

You can see all deals with the crm associations endpoint

This endpoint does not give the deal stage, though.  I can see how that would be useful information on this endpoint.  Would be worthy of submitting an idea

If you do submit an idea, add link here so we can upvote!

@btsp , how would you approach this problem?

Thanks,

Dennis


We are excited to announce that the Community will be launching a weekly newsletter on November 2, 2020!
Sign up today!
Reply
0 Upvotes
Regular Contributor

Generally speaking, you need something like this:

    params = { 'hapikey': ... }

    data = {
        'filterGroups': [
            {
                'filters': [
                    { 'propertyName': 'dealstage', 'operator': 'NEQ', 'value': <<<internal ID of closed stage from Deal Properties edit screen>>> },
                ]
            }
        ],
        'properties': <<<your list of property names>>>,
        'limit': 100,
        'after': 0,
    }

    response = requests.post('https://api.hubapi.com/crm/v3/objects/deals/search', params=params, data=json.dumps(data))

    ... pagination loop here ...