Back to Blog
API & Developer Guides

How to Build a Lead Generation Bot with the Easy Email Finder API

Published February 1, 2026

Automate Your Lead Generation Pipeline

Manual lead research is slow and tedious. A well-built bot can find hundreds of qualified leads while you sleep. In this tutorial, you will build a Python bot that uses the Easy Email Finder API to search for businesses across multiple cities, enrich them with email addresses, and export everything to a clean CSV file.

What We Are Building

Our bot will do the following:

  • Accept a business type and a list of target cities
  • Search Google Places for matching businesses in each city
  • Enrich each business with email and quality signals
  • Save results to a timestamped CSV file
  • Respect rate limits and handle errors gracefully

Prerequisites

You will need Python 3.8 or later and an Easy Email Finder API key. Get your key from the Developer Dashboard.

pip install requests

The Complete Bot

import requests
import csv
import time
from datetime import datetime

API_KEY = "eef_live_your_api_key_here"
BASE = "https://easyemailfinder.com/api/v1"
HEADERS = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
}

def search_businesses(query: str, location: str) -> list:
    """Search for businesses (free endpoint)."""
    resp = requests.post(f"{BASE}/search", headers=HEADERS, json={
        "query": query,
        "location": location,
        "mode": "local"
    })
    resp.raise_for_status()
    return resp.json().get("results", [])

def enrich_batch(websites: list) -> list:
    """Enrich up to 20 websites at once (1 credit each)."""
    resp = requests.post(f"{BASE}/enrich-batch", headers=HEADERS, json={
        "websites": websites[:20]
    })
    resp.raise_for_status()
    return resp.json().get("results", [])

def check_balance() -> int:
    """Check remaining credits."""
    resp = requests.get(f"{BASE}/balance", headers=HEADERS)
    return resp.json().get("credits", 0)

def run_bot(business_type: str, cities: list, output_file: str = None):
    if not output_file:
        timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
        output_file = f"leads_{business_type}_{timestamp}.csv"

    credits = check_balance()
    print(f"Starting with {credits} credits")

    all_leads = []

    for city in cities:
        print(f"\nSearching: {business_type} in {city}")
        businesses = search_businesses(business_type, city)
        print(f"  Found {len(businesses)} businesses")

        # Collect websites for batch enrichment
        websites = [b["website"] for b in businesses if b.get("website")]

        # Process in batches of 20
        for i in range(0, len(websites), 20):
            batch = websites[i:i+20]
            print(f"  Enriching batch {i//20 + 1} ({len(batch)} sites)")

            try:
                results = enrich_batch(batch)
                for r in results:
                    if r.get("email"):
                        all_leads.append(r)
                        print(f"    Found: {r['email']}")
            except requests.exceptions.HTTPError as e:
                print(f"  Error: {e}")
                if e.response.status_code == 429:
                    print("  Rate limited. Waiting 60 seconds...")
                    time.sleep(60)

            # Respect rate limits
            time.sleep(1)

    # Write CSV
    if all_leads:
        keys = ["email", "website", "name", "phone", "address"]
        with open(output_file, "w", newline="") as f:
            writer = csv.DictWriter(f, fieldnames=keys, extrasaction="ignore")
            writer.writeheader()
            writer.writerows(all_leads)
        print(f"\nSaved {len(all_leads)} leads to {output_file}")
    else:
        print("\nNo leads found.")

    remaining = check_balance()
    print(f"Credits remaining: {remaining}")

if __name__ == "__main__":
    run_bot(
        business_type="dentists",
        cities=["Austin, TX", "Dallas, TX", "Houston, TX", "San Antonio, TX"]
    )

How It Works

The bot uses three key API endpoints. First, the free /search endpoint finds businesses by keyword and location. Next, the /enrich-batch endpoint processes up to 20 websites at once, which is significantly faster than calling /enrich individually. Finally, the /balance endpoint tracks credit consumption.

The bot processes websites in batches of 20 (the maximum for /enrich-batch) and includes a 1-second delay between batches to stay well within the API rate limits.

Extending the Bot

You can extend this bot in several ways:

  • Add scheduling: Use cron or a task scheduler to run the bot daily for new leads
  • CRM integration: Push leads directly to HubSpot, Salesforce, or Pipedrive via their APIs
  • Deduplication: Maintain a local database of previously found emails to avoid enriching the same website twice
  • Multi-keyword support: Pass a list of business types and iterate over all keyword-city combinations

Cost Estimation

Each enrichment costs 1 credit ($0.25). If you search 4 cities and find 20 businesses per city with websites, that is 80 enrichments costing $20 total. Since there is no monthly subscription, you only pay for what you use. Check out our cost optimization guide for tips on reducing spend.

Wrapping Up

With under 80 lines of Python, you have a working lead generation bot that can scale to hundreds of cities and thousands of leads. The pay-per-email model means you can start small and scale up as your pipeline grows. For more advanced workflows, explore the full API documentation.

Ready to find business emails?

Try Easy Email Finder free — get 5 credits to start.

Start Finding Emails

Related Posts