Possible to request data from Deals and the associated Line items?

Hi,

I’m trying to automate pulling a report from Hubspot. It seems that there isn’t the capability to do this directly (please correct me if I’m wrong!), so am recreating the report which has fields from Deals and Line items. Is there a way to link these two? i.e. if I specify I want all deals from the past year, is there an easy way to specify and request the line items associated with them? If not, are the id’s for Deals and Line items the same? I’m working in Python, and have been using:

https://api.hubapi.com/crm/v3/objects/deals

https://api.hubapi.com/crm/v3/associations/deals/line_items

Many thanks

Annika

Hello @AWong24

Welcome to the Community!

Adding a couple people in here to see if we can get you an answer

@taran42 , @Mike_Eastwood are both talented folks :grinning_face: . Here’s to hoping they have some advice!

Hello @AWong24 . I am not overly familiar with the Hubspot API v3, as I built my automation with v1, but what you’re looking to do should be possible. There are some bugs in both the v1 and v3 APIs and I know some features in v3 aren’t complete yet (I recently had some issues trying to get Engagements with v3, come to find out Engagements are supported in v3 yet, so resorted back to v1).

For your particular issue, I’ll reference you to a post I made a while back that contains the code I used: https://community.hubspot.com/t5/APIs-Integrations/Not-Getting-All-Contacts/m-p/369466#M36391

Hopefully it can help you out. I know how much of a pain this can be at times. If you are able to get all deals, you should then be able to get all deals, then you should be able to filter those by date for the timeframe you are looking for and then do the same thing for the line items you’re looking for.

Hi @dennisedson and @taran42 ,

Thanks so much for your reply @taran42, it really helped. I’m reading all the deals in, then will use associations to get the line items ids and do the same with them.

One slightly odd thing is happening when specifying the properties to return. It only gives back the first two, so for the below it’ll return closedate and dealstage. The properties are all there and appear if I change the order. Any idea what could be happening there…?

https://api.hubapi.com/deals/v1/deal/paged?&properties=closedate&properties=dealstage&properties=dealname

Thanks!

Annika

Please ignore issue above! Realised what I was doing wrong, I needed to add a ‘&’ at the end of the url so that when the parameters were added on it read through correctly.

Thanks again for your help!

Annika