RESOLVED

const associationsResponse = await hubspotClient.crm.associations.getApiAssociations(0, contactId, 2);

i keep getting the errow ’ Property ‘getApiAssociations’ does not exist on type ‘AssociationsDiscovery’.’

what is the correct way to retive associates based on contactId

Hi @SJohnson0 :waving_hand:

You might consider using the HubSpot CRM “Read Contact” endpoint. The documentation gives the following example where Node is the client library in play:

const hubspot = require('@hubspot/api-client');

const hubspotClient = new hubspot.Client({"accessToken":"YOUR_ACCESS_TOKEN"});

const contactId = "12345"; // replace with the relevant contact id
const properties = undefined;
const propertiesWithHistory = undefined;
const associations = [
 "companies,deals" // comma-separated list of target associated object-types
];
const archived = false;

try {
 const apiResponse = await hubspotClient.crm.contacts.basicApi.getById(contactId, properties, propertiesWithHistory, associations, archived);
 console.log(JSON.stringify(apiResponse, null, 2));
} catch (e) {
 e.message === 'HTTP request failed'
 ? console.error(JSON.stringify(e.response, null, 2))
 : console.error(e)
}

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