# Working example of retrieving associations with the python API

**URL:** <https://community.hubspot.com/t/working-example-of-retrieving-associations-with-the-python-api/82091>\
**Category:** APIs & Integrations\
**Tags:** python\
**Created:** [May 26, 2023, 10:49am UTC](https://community.hubspot.com/t/working-example-of-retrieving-associations-with-the-python-api/82091 "2023-05-26T10:49:43Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![CDahl1](https://avatars.discourse-cdn.com/v4/letter/c/34f0e0/32.png) [@CDahl1](https://community.hubspot.com/u/CDahl1)\
**Post date:** [May 31, 2023, 8:19pm UTC](https://community.hubspot.com/t/working-example-of-retrieving-associations-with-the-python-api/82091/7 "2023-05-31T20:19:23Z")

</div>

Finally figured it out - the documentation is truly bad here - but this works.

```lia-code-sample
# assuming I already retrieved a list of companies
from hubspot.crm.associations import BatchInputPublicObjectId
batch_ids = BatchInputPublicObjectId([{'id': c.id} for c in companies] )
associations = api_client.crm.associations.batch_api.read(from_object_type="company", 
 to_object_type="contacts",
 batch_input_public_object_id=batch_ids)

```

---

_[View the full topic](https://community.hubspot.com/t/working-example-of-retrieving-associations-with-the-python-api/82091)._
