API Get All Deals with Lead Source

Is there a way for me to get all deals with the lead source property for the deals? The API is returning the lead source when I get a single lead but not in a batch. I tried a few different options but nothing worked.

The below just returns an empty property array.

https://api.hubapi.com/deals/v1/deal/paged?hapikey= <key> &limit=100&includePropertyVersions=true&properties=lead_source

Any help will be much appreciated.

@Bryantworks , would you be able to assist here :folded_hands:

Hi @ganken ,
Hope this code work for you :
Api Documentation :
“Search the CRM - HubSpot docs”
For deal php code fetch result:
<?php
$data = ‘{
“properties”: [ “dealname”, “amount”, “lead_source” ]
“filterGroups”:[
{
“filters”:[
{
“propertyName”: “<deal_key>”,
“operator”: “EQ”,
“value”: “<deal_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.