Hubspot Dataset

Export your Hubspot data into Pandas Dataframes. Quickly make insights from your CRM data.

Authentication

Downloading more than 10,000 rows?

A PetalData API key is required. Email support@petaldata.app to obtain an API key.

Your Hubspot API key must be passed to PetalData. See Hubspot's API key docs for instructions on creating an API key.

import petaldata

petaldata.datasets.hubspot.api_key = "[YOUR HUBSPOT API KEY]"
curl http://localhost:3001/hubspot/contacts.csv?limit=5 \
-H "HUBSPOT_API_KEY: [YOUR HUBSPOT API KEY]" \

Contacts

Contacts are the fundamental building block to HubSpot - they store lead-specific data that makes it possible to leverage much of the functionality in HubSpot, from marketing automation, to lead scoring to smart content.


Initialize Contacts

Initializes a Hubspot Contacts dataset, loading the dataset if it was previously saved to storage.

Arguments

Name Description
base_pickle_filename
optional string
Specifies the name of the Pickle file the Dataset should be loaded from and saved to. If the file doesn't exit, it will be created when the Dataset is saved.

The default is hubspot_contacts.pkl.

import petaldata

petaldata.datasets.hubspot.api_key = "[YOUR HUBSPOT API KEY]"

contacts = petaldata.datasets.hubspot.Contacts()
# Access previously saved contacts via a Pandas Dataframe
df = contacts.df

Download Contacts

Downloads Contacts from Hubspot. Contacts are accessible as a Pandas Dataframe via the Contacts.df attribute after the download completes.

Contacts.df is overwritten with the new downloaded data. The dataframe is not saved automatically following the download - call Contacts.save() to save the dataset.

In-progress downloads are saved as csv files to local storage.

Arguments

Name Description
created_gt
optional datetime
Return contacts created after this value.
created_gte
optional datetime
Return contacts created on or after this value.
updated_gte
optional datetime
Return contacts updated on or after this avlue.
limit
optional integer
Limits the number of contacts returned.
import petaldata

petaldata.datasets.hubspot.api_key = "[YOUR HUBSPOT API KEY]"

contacts = petaldata.datasets.hubspot.Contacts()
contacts.download(limit=5)
# Access downloaded contacts via a Pandas Dataframe
df = contacts.df
curl http://localhost:3001/Hubspot/contacts.csv?limit=5 \
-H "HUBSPOT_API_KEY: [YOUR HUBSPOT API KEY]" \

Save Contacts

Saves a downloaded or upsert-ed contacts dataset to storage as a Pickle file. Contacts.save() overwrites the existing Pickle file if it exists.

Arguments

No arguments.
import petaldata

petaldata.datasets.hubspot.api_key = "[YOUR HUBSPOT API KEY]"

contacts = petaldata.datasets.hubspot.Contacts()
contacts.download(limit=5)
# Saves contacts to a pickle file.
contacts.save()

Upsert Contacts

Updates existing contacts in Contacts.df and inserts new contacts into the dataframe.

Contacts.df is overwritten with the updated data. The dataframe is not saved automatically following the upsert - call Contacts.save() to save the dataset.

Arguments

Name Description
created_gt
optional datetime
Return contacts created after this value. If not provided, only new rows created after Contacts.updated are inserted and existing rows are not updated.
import petaldata
from datetime import datetime, timedelta

petaldata.datasets.hubspot.api_key = "[YOUR HUBSPOT API KEY]"

contacts = petaldata.datasets.hubspot.Contacts()
contacts.upsert(created_gt=datetime.now() - timedelta(days=30))
# Access contacts via a Pandas Dataframe
df = contacts.df

Delete Contacts

Deletes the associated saved Pickle file and the dataframe accessible at Contacts.df. This does not delete data within your Hubspot account.

Arguments

No arguments.
import petaldata

petaldata.datasets.hubspot.api_key = "[YOUR HUBSPOT API KEY]"

contacts = petaldata.datasets.hubspot.Contacts()
contacts.delete()