Mass import of email contacts into Hubspot

I’m trying to import a large number of email contacts into Hubspot using their API. Right now I’m using a loop to add each contact one by one. But it’s taking too long and I’m hitting the execution time limit after about 30 seconds. Is there a way to do this in bulk instead? Here’s a simplified version of what I’m currently doing:

for contact in contact_list:
    contact_data = {
        'email': contact['email'],
        'name': contact['full_name']
    }
    hubspot_client = HubspotClient(api_key)
    hubspot_client.create_contact(contact_data)
    contact_id = hubspot_client.get_contact_id(contact['email'])
    hubspot_client.add_to_list(contact_id, target_list_id)

Any suggestions on how to make this more efficient? Thanks!

hey there! I’ve dealt with this before. Instead of looping, try using hubspot’s batch API endpoint. It lets you send up to 100 contacts in one request. way faster! You’ll need to restructure your data a bit, but it’s worth it. Lemme know if u need more help :slight_smile: