# Get association IDs when using get\_page

**URL:** <https://community.hubspot.com/t/get-association-ids-when-using-get-page/93671>\
**Category:** APIs & Integrations\
**Tags:** object\
**Created:** [November 9, 2023, 1:33pm UTC](https://community.hubspot.com/t/get-association-ids-when-using-get-page/93671 "2023-11-09T13:33:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![andriushivehr](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@andriushivehr](https://community.hubspot.com/u/andriushivehr)\
**Post date:** [November 9, 2023, 1:33pm UTC](https://community.hubspot.com/t/get-association-ids-when-using-get-page/93671/1 "2023-11-09T13:33:20Z")

</div>

Hi,

I’m using Hubspot’s Python API to retrieve deal data from the CRM. I want to get the company ID associated with each deal (if there’s any) but I’m running into API errors.

I noticed that function **client.crm.deals.basic\_api.get\_page()** has a parameter called **‘associations’** - which I presume, if used, would include the required associations data in the API response data.

I’ve tried looking for documentation online on how this **‘associations’** argument can be defined within get\_page() but I couldn’t find any information. I’ve tried using **associations=“company”** , **associations=“companies”** but that results in the API call erroring out (“Unable to infer object type from: c”)

I’m currently using a separate API call to get the deal-to-company association (

using **client.crm.associations.batch\_api.read** ) but it would be way better if I could get the associations data without a separate API call

Any advice highly appreciated!

---

<div class="post-metadata">

**Author:** ![PamCotton](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/pamcotton/32/47916_2.png) [@PamCotton](https://community.hubspot.com/u/PamCotton)\
**Post date:** [November 13, 2023, 11:26pm UTC](https://community.hubspot.com/t/get-association-ids-when-using-get-page/93671/2 "2023-11-13T23:26:15Z")

</div>

Hello @andriushivehr thank you for posting in our Community!

I want to share this page with more information about [associations.](https://developers.hubspot.com/docs/api/crm/associations)

To our top experts @TomAshford @coldrickjack [@zach\_threadint](https://community.hubspot.com/t5/user/viewprofilepage/user-id/324811) any recommendations to @andriushivehr matter?

Thank you,

Pam

---

<div class="post-metadata">

**Author:** ![zach\_threadint](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/zach_threadint/32/46318_2.png) [@zach\_threadint](https://community.hubspot.com/u/zach_threadint)\
**Post date:** [November 14, 2023, 1:07am UTC](https://community.hubspot.com/t/get-association-ids-when-using-get-page/93671/3 "2023-11-14T01:07:31Z")

</div>

Hi @andriushivehr 👋

(thanks for the nudge @PamCotton 🙂)

The “associations” argument within HubSpot’s Python API client’s get\_page() method requires a list data type. For example:

`api_response = client.crm.deals.basic_api.get_page(associations=["companies"])`

Keep in mind it’s only possible to return the associated record ID(s) using this feature. You’ll still need to make another request to the Companies API to retrieve any required information stored within the associated Company record.

I hope this proves useful. Please let me know if you have any follow-up questions.

---

<div class="post-metadata">

**Author:** ![andriushivehr](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@andriushivehr](https://community.hubspot.com/u/andriushivehr)\
**Post date:** [November 14, 2023, 9:19am UTC](https://community.hubspot.com/t/get-association-ids-when-using-get-page/93671/4 "2023-11-14T09:19:16Z")

</div>

Thank you [@zach\_threadint](https://community.hubspot.com/t5/user/viewprofilepage/user-id/324811) , this does exactly what I need 🙂

---

<div class="post-metadata">

**Author:** ![andriushivehr](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@andriushivehr](https://community.hubspot.com/u/andriushivehr)\
**Post date:** [November 16, 2023, 11:05am UTC](https://community.hubspot.com/t/get-association-ids-when-using-get-page/93671/5 "2023-11-16T11:05:13Z")

</div>

Hi - I have one more question. Do you have any idea why I could be getting the same association ID returned twice under different association types (labelled/unlabeled)? Below is the API response:

‘associations’: {‘companies’: {‘paging’: None,  
‘results’: [{‘id’: ‘HIDDEN’,  
‘type’: ‘deal\_to\_company’},  
{‘id’: ‘HIDDEN’,  
‘type’: ‘deal\_to\_company\_unlabeled’}]}},

---

<div class="post-metadata">

**Author:** ![zach\_threadint](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/zach_threadint/32/46318_2.png) [@zach\_threadint](https://community.hubspot.com/u/zach_threadint)\
**Post date:** [November 16, 2023, 10:36pm UTC](https://community.hubspot.com/t/get-association-ids-when-using-get-page/93671/6 "2023-11-16T22:36:41Z")

</div>

Hi @andriushivehr 👋

Based on some quick testing, association type “deal\_to\_company” will always represent the “Primary” associated Company. If a “Primary” association has not been defined, this will not be returned by the API. In addition, it’s also possible for the record associated as the “Primary” to have a [custom association label](https://knowledge.hubspot.com/crm-setup/create-and-use-association-labels). As such, the API will also return an association relevant to the custom label feature (in your case, the association is “unlabeled”).

I hope this proves useful. Please let me know if you have any follow-up questions.

---

<div class="post-metadata">

**Author:** ![andriushivehr](https://avatars.discourse-cdn.com/v4/letter/a/dfb087/32.png) [@andriushivehr](https://community.hubspot.com/u/andriushivehr)\
**Post date:** [November 17, 2023, 10:00am UTC](https://community.hubspot.com/t/get-association-ids-when-using-get-page/93671/7 "2023-11-17T10:00:43Z")

</div>

That’s great, thank you so much for the quick reply 🙂
