How to retrieve contact records from custom object API

Hi

I am using custom objects in hubspot to categorise my contacts, I am using python to retrieve this data in the backend.
This is the request I am using for the custom object

url = ‘https://api.hubapi.com/crm/v3/objects/OBJECTID’

headers = {‘Authorization’: f’Bearer {token}'}

response = requests.get(url,params={‘properties’:[‘enquiryId’,‘enquiry_day’,‘enquiry_source’],‘limit’:100, ‘after’:2},headers=headers)

The issue is I need contactId or contact email when retrieving this data otherwise it will cause me to have orphaned records? How do I get contact Id or contact email to return alongside this data?
I read that the associations API exists to help link objects to custom objects but I’m not sure how this works to retrieve data from the API that connects a custom object with an object.
Can somebody help explain this process to me please? Or offer an alternate solution?

Thank you

Hi @DShallcross

For retrieving a specific record of a custom object, it is necessary to pass the object name in plural form. For instance, if you have a custom object called “car” and you want to retrieve a record with ID 1, the correct URL would be : https://api.hubapi.com/crm/v3/objects/cars/1

I hope this will help you out. Please mark it as Solution Accepted and upvote to help another Community member.
Thanks!

Thanks for the response. I am not looking to retrieve a particular custom object record. I am looking to retrieve contact records associated with the custom object records.

Hi @DShallcross

Use curl attached below :

curl --request GET \
 --url 'https://api.hubapi.com/crm/v3/objects/contacts?limit=10&associations=CUSTOM_OBJECT_NAME&archived=false' \
 --header 'authorization: Bearer YOUR_ACCESS_TOKEN'

I hope this will help you out. Please mark it as Solution Accepted and upvote to help another Community member.
Thanks!

Bump