Skip to main content

An (unofficial) Python wrapper for the Hunter.io API

Project description

PyPI version

PyHunter

A Python wrapper for the Hunter.io v2 API

Installation

Requirements:

  • Python 3 (no Python 2 version)

To install:

pip install pyhunter

For async support:

pip install "pyhunter[test]"

Usage

Import the PyHunter and instantiate it:

from pyhunter import PyHunter
hunter = PyHunter('my_hunter_api_key')

You can configure transport behavior:

hunter = PyHunter(
    'my_hunter_api_key',
    timeout=10,
    max_retries=2,
    retry_backoff=0.5,
)

Async Usage

from pyhunter import AsyncPyHunter

async with AsyncPyHunter('my_hunter_api_key') as hunter:
    result = await hunter.domain_search('instagram.com')

For long-lived clients:

hunter = AsyncPyHunter('my_hunter_api_key')
try:
    data = await hunter.email_count('instagram.com')
finally:
    await hunter.aclose()

Domain Search

Search all email addresses for a given domain:

hunter.domain_search('instagram.com')

Pass the company name instead, along with optional filters:

hunter.domain_search(
    company='Instagram',
    limit=5,
    offset=2,
    emails_type='personal',
    seniority='senior,executive',
    department='sales,marketing',
    required_field='full_name',
    verification_status='valid',
)

Email Finder

Find a specific person's email address:

email, confidence_score = hunter.email_finder('instagram.com', first_name='Kevin', last_name='Systrom')

Use the company name, full name, or LinkedIn handle instead:

hunter.email_finder(company='Instagram', full_name='Kevin Systrom', raw=True)

hunter.email_finder(linkedin_handle='kevinsystrom', max_duration=15)

Email Verifier

Check the deliverability of an email address:

hunter.email_verifier('kevin@instagram.com')

Email Count

Check how many email addresses Hunter has for a given domain:

hunter.email_count('instagram.com')
# or by company name
hunter.email_count(company='Instagram')

Account Information

Check your account information and remaining API calls:

hunter.account_information()

PyHunter adds a calls['left'] field to the response with the number of API calls still available.


NOTE: By default, all calls return the data element of the JSON response. Pass raw=True to get the full HTTP response object, including headers (e.g. X-RateLimit-Remaining) and the complete response body including meta.

Transport and HTTP failures raise typed exceptions:

  • HunterTransportError for connectivity/timeouts
  • HunterApiError for non-2xx and malformed API payloads

Enrichment

Look up all information about a person from their email or LinkedIn handle:

hunter.email_enrichment(email='kevin@instagram.com')
hunter.email_enrichment(linkedin_handle='kevinsystrom')

Look up all information about a company from its domain:

hunter.company_enrichment('instagram.com')

Get combined person + company information in one call:

hunter.combined_enrichment('kevin@instagram.com')

All enrichment methods accept a clearbit_format=True parameter to return data in Clearbit-compatible format.


Discover

Find companies matching a set of criteria:

hunter.discover(query='Tech companies in Europe')

hunter.discover(
    industry={'include': ['Technology', 'Software']},
    headcount=['51-200', '201-500'],
    headquarters_location={'include': [{'country': 'France'}]},
    limit=50,
)

Leads

Get all leads:

hunter.get_leads()

Filter leads:

hunter.get_leads(
    offset=2,
    limit=10,
    lead_list_id=1,
    first_name='Kevin',
    last_name='Systrom',
    email='kevin@instagram.com',
    company='Instagram',
    phone_number='0102030405',
    twitter='kevin',
    position='CEO',
    sync_status='success',
    query='kevin',
)

Get a specific lead by id:

hunter.get_lead(42)

Create a lead:

hunter.create_lead(
    'Quentin', 'Durantay',
    email='quentin.durantay@unicorn.io',
    position='CEO',
    company='Unicorn Consulting',
    company_size=10,
    confidence_score=100,
    website='unicornsaregreat.io',
    country_code='FR',
    postal_code=75000,
    source='theinternet.com',
    linkedin_url='www.linkedin.com/in/masteroftheuniverse',
    phone_number='0102030405',
    twitter='quentindty',
    notes='Met at a conference',
    leads_list_id=1,
    leads_list_ids=[1, 2, 3],
)

Create or update a lead by email (upsert):

hunter.upsert_lead('kevin@instagram.com', first_name='Kevin', last_name='Systrom')

Update a lead by id:

hunter.update_lead(1, position='CEO in chief', notes='Updated notes')

Delete a lead by id:

hunter.delete_lead(42)

Leads Lists

Get all leads lists:

hunter.get_leads_lists()
hunter.get_leads_lists(offset=3, limit=2)

Get a specific leads list by id:

hunter.get_leads_list(42)

Create a leads list:

hunter.create_leads_list('Ultra hot prospects')

Update a leads list:

hunter.update_leads_list(42, 'Ultra mega hot prospects')

Delete a leads list:

hunter.delete_leads_list(42)

Custom Attributes

Manage custom attributes for your leads:

# List all custom attributes
hunter.get_leads_custom_attributes()

# Get a specific custom attribute
hunter.get_leads_custom_attribute(1)

# Create a new custom attribute
hunter.create_leads_custom_attribute('Priority Level')

# Update a custom attribute
hunter.update_leads_custom_attribute(1, 'Deal Priority')

# Delete a custom attribute
hunter.delete_leads_custom_attribute(1)

Campaigns (Email Sequences)

Manage your email sequences:

# List all campaigns
hunter.get_campaigns()
hunter.get_campaigns(started=True, limit=10)

# Get recipients of a campaign
hunter.get_campaign_recipients(42)

# Add recipients to a campaign
hunter.add_campaign_recipients(42, emails=['kevin@instagram.com', 'jack@twitter.com'])
hunter.add_campaign_recipients(42, lead_ids=[1, 2, 3])

# Cancel scheduled emails to recipients
hunter.cancel_campaign_recipients(42, emails=['kevin@instagram.com'])

# Start a campaign
hunter.start_campaign(42)

Logos

Get a company logo by domain (returns bytes):

logo_bytes = hunter.logo('stripe.com')

Async:

from pyhunter import AsyncPyHunter

async with AsyncPyHunter('my_hunter_api_key') as async_hunter:
    logo_bytes = await async_hunter.logo('stripe.com')

Information

If you find a bug or something is missing, feel free to open an issue or a pull request on GitHub.

Contribute

It's my first (ever) open-source library! So it can be improved. Feel very welcome to fork it and ask for pull requests if you find something buggy or lacking ;)

Have a nice day scraping B2B emails with PyHunter!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyhunter-2.1.0.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyhunter-2.1.0-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file pyhunter-2.1.0.tar.gz.

File metadata

  • Download URL: pyhunter-2.1.0.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for pyhunter-2.1.0.tar.gz
Algorithm Hash digest
SHA256 633ba78a05de48cc84b59e0bad8635bc1d000b7c10f63a92ebf27da0dbdf3593
MD5 0631ed7fe2113bf35768984a61b824c7
BLAKE2b-256 e57215b632ca9b52ba08dbe2709a663ff6d9dd86564909d85e5f53f279b20164

See more details on using hashes here.

File details

Details for the file pyhunter-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyhunter-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for pyhunter-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2831ecd01704e859449894da663d0cdbeb36db015416bfdfb17f0e23e9cec608
MD5 c3fc35402b572583f723017b4dca54b5
BLAKE2b-256 5391b7ab6b49f81738311f9b9de6329031bbccfc3609f5f73163a38f14ab810a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page