Fetch deals with their properties

Hi!

I’ve got a mission to get all entries of deals for inserting in a database.

Iin order to perform some analysis, my team needs all the properties from each deal.

Right now I have this piece of code:

from hubspot import HubSpot
api = HubSpot('key')
deals = api.crm.deals.basic_api.get_page(limit = 100, properties=properties_list)

But any of the result in the deals object has the properties that I wanted.

Could it be the amount of properties I selected? I’m trying with 60 of them right now.

Hi @FLira2000 ,
You can use the below code for search deals from property:
<?php
$data = ‘{
“filterGroups”:[
{
“filters”:[
{
“propertyName”: “<PROPERTY_NAME>”,
“operator”: “EQ”,
“value”: “<PROPERTY_VALUE>”
}
]
}
]
}’;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, ‘https://api.hubapi.com/crm/v3/objects/deals/search?hapikey=YOUR_HUBSPOT_API_KEY’);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$headers = array();
$headers[] = ‘Content-Type: application/json’;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo ‘Error:’ . curl_error($ch);
}
curl_close($ch);

Hope this helps!

If we were able to answer your query, kindly help the community by marking it as a solution.
Thanks and Regards.

Hi, thanks for the reply, first of all.

But sorry, that’s not what I asked for.

I need all the Deals with their properties, not searching a batch of Deals based on a query.

Currently I have a code which gets all the Deals I have in the CDP, but just one of the properties I asked for is fetched. I’ve already made some transformations in order to see exactly properties I’ve got in the last test, and they are:

'properties': {'amount': None,
 'app': None,
 'ativacao': None,
 'closedate': None,
 'createdate': '2020-01-29T18:49:23.291Z',
 'dealname': 'Dummy name ',
 'dealstage': 'placeholder',
 'hs_lastmodifieddate': '2021-10-01T19:27:51.902Z',
 'hs_object_id': '1487571337',
 'pipeline': 'yet_another_placeholder',
 'sdr': 'sheesh'}

But thanks, again.

Hii could you please share your code? I am still confused about retrieving the closed date from all deals.

@FLira2000 . Take a look at the additional parameters I mention in this post

Hi @dennisedson !

Does API v1 still work? I’m worried that this API will stop working at some point, if it hasn’t already.

@FLira2000 , yep!

I have not seen any evidence that it will be sunset anytime soon.

If you are very worried, you could use the search endpoint and in the json, include an array of all the properties that you want to be returned. This is the recommended method for all of the other objects as the uri will often be too long if you attached them all as query params