APIs & Integrations

GKristjansson
Member

Getting all notes

SOLVE

I am trying to extract all notes from my companies HubSpot account. The code returns some things but no notes. This is the code, can anyone tell me why?

 

client = hubspot.Client.create(access_token="access token which I will not post here")

try:
    api_response = client.crm.objects.notes.basic_api.get_page(limit=100, archived=False)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling basic_api->get_page: %s\n" % e)
0 Upvotes
1 Accepted solution
ChrisoKlepke
Solution
Key Advisor | Elite Partner
Key Advisor | Elite Partner

Getting all notes

SOLVE

Hey @GKristjansson , 

 

cool that you're trying to get some data from HubSpot using the Python API library. 

 

You're basically gives you all the note no matter if they were associated with a company or any object for that matter. 

 

What you need to do is request notes by ID individually or a batch read. But you need the IDs of these notes first. To get them from one company you need to call:


api_response = client.crm.companies.associations_api.get_all(company_id=5800956379, to_object_type="NOTES", limit=500)
pprint(api_response)

 

Pasting it here is butchering the tabs but you get the idea.

 

You then receive all the note IDs associated with that company. You then can access them like this in read call:


api_response = client.crm.objects.notes.basic_api.get_by_id(note_id="14935624419", properties=["hs_note_body"], archived=False)
pprint(api_response)

 

Here is important to define what properties you want to access. The content of a note is saved in hs_note_body.

 

If you found this post helpful, consider helping others in the community to find answers faster by marking this as a solution. I'd really appreciate it. 

 

Cheers, 

Chriso

View solution in original post

0 Upvotes
2 Replies 2
ChrisoKlepke
Solution
Key Advisor | Elite Partner
Key Advisor | Elite Partner

Getting all notes

SOLVE

Hey @GKristjansson , 

 

cool that you're trying to get some data from HubSpot using the Python API library. 

 

You're basically gives you all the note no matter if they were associated with a company or any object for that matter. 

 

What you need to do is request notes by ID individually or a batch read. But you need the IDs of these notes first. To get them from one company you need to call:


api_response = client.crm.companies.associations_api.get_all(company_id=5800956379, to_object_type="NOTES", limit=500)
pprint(api_response)

 

Pasting it here is butchering the tabs but you get the idea.

 

You then receive all the note IDs associated with that company. You then can access them like this in read call:


api_response = client.crm.objects.notes.basic_api.get_by_id(note_id="14935624419", properties=["hs_note_body"], archived=False)
pprint(api_response)

 

Here is important to define what properties you want to access. The content of a note is saved in hs_note_body.

 

If you found this post helpful, consider helping others in the community to find answers faster by marking this as a solution. I'd really appreciate it. 

 

Cheers, 

Chriso

0 Upvotes
GKristjansson
Member

Getting all notes

SOLVE

Thank you for the reply! Ok good to know but one question. Is it possible to get all notes from a certain sales person instead of companies?

0 Upvotes