APIs & Integrations

Astroraf
Member

How to get Contacts in Pandas Dataframe using HuSpot Apps

SOLVE

I am trying to figure out how to get the Contacts from Hubspot into a pandas Dataframe using the Private Apps key. I can access the contacts but it keeps telling me the object is not subscriptable. This is my coe thus far.

 

```

access_token_key_contacts = 'xxxxxxxxxxxxxxxx'
api_client_contacts = HubSpot(access_token= access_token_key_contacts)
 
Contacts = api_client_contacts.crm.contacts.get_all()
 
Contact_lst = []
for contact in Contacts:
           Contact_lst.append(contact)
 
```
 
When this is printed out, I get a list of Contacts but then I can't access this information like a normal list of dictionaries in python. 
 
I am not sure what to do at this point. Any and all help will be much appreciated. 
 

 

 

0 Upvotes
1 Accepted solution
JTimmins
Solution
Member

How to get Contacts in Pandas Dataframe using HuSpot Apps

SOLVE

Looks like `contact` is an object, not a dictionary, so you'll need to access it via Python's dot notation. If you print out `contact.__dict__()`, it'll probably show you the objects properties. 

 

You can also print out the object type (`print type(contact)`), and then look up that class in GitHub to see the built-in properties and methods. https://github.com/HubSpot/hubspot-api-python

View solution in original post

1 Reply 1
JTimmins
Solution
Member

How to get Contacts in Pandas Dataframe using HuSpot Apps

SOLVE

Looks like `contact` is an object, not a dictionary, so you'll need to access it via Python's dot notation. If you print out `contact.__dict__()`, it'll probably show you the objects properties. 

 

You can also print out the object type (`print type(contact)`), and then look up that class in GitHub to see the built-in properties and methods. https://github.com/HubSpot/hubspot-api-python