Hubspot API

Python library

HubSpot API Python Client Libraries for V3 version of the API:

API docs

working code

fetch all companies

from hubspot import HubSpot

api_client = HubSpot(access_token=HUBSPOT_API_KEY)

count = 0

# Contacts
# all_contacts = api_client.crm.contacts.get_all()

# Companies
all = api_client.crm.companies.get_all()


for x in all:
    count += 1
    x = x.to_dict() # convert object to dict
    name = x['properties']['name']
    domain = x['properties']['domain']
    print(f"\n{domain}\t{name}")

print(f"\n\nℹ️ {count} companies.\n\n")

31 Mar 2023

api_client = HubSpot(access_token=HUBSPOT_API_KEY)

count = 0
count_row = 0

test = True
v = True # verbose mode

existing_domains = []
output = []

# FUNCTIONS


# MAIN

domains = [
    "mass.edu",
    "merit.edu",
]

# all_contacts = api_client.crm.contacts.get_all()
all = api_client.crm.companies.get_all()


for x in all:
    x = x.to_dict() # convert object to dict
    count_row += 1
    # print(f"\n\n{x}")
    name = x['properties']['name']
    domain = x['properties']['domain']
    if domain.endswith('.edu'):
        print(f"\n{domain}\t{name}")
        output.append((domain, name))
        existing_domains.append(domain)


print(f"\n\nℹ️    {count} companies.\n\n")

header = ['domain', 'name']

tt.print(
output,
header=header,
style=tt.styles.markdown,
padding=(0, 1),
# alignment="lcr"
)

print(f"\n\n Missing domain in Hubspot:")
for domain in domains: 
    if domain not in existing_domains:
        count += 1
        print(f"\t{domain}")

links

social