DEV Community

Donny Nguyen
Donny Nguyen

Posted on

Build a Complete Lead Gen Pipeline with 3 Free APIs

What if you could go from "I need leads in the restaurant industry in Chicago" to a spreadsheet of 200+ contacts with emails — in under 5 minutes?

Here's how to build a 3-API lead generation pipeline using free tiers:

The Stack

Step API What It Does
1. Find businesses Google Maps Scraper Extracts business listings from Maps
2. Get emails Email Extractor Scrapes email addresses from websites
3. Enrich contacts Apollo Lead Scraper Finds decision-maker names and titles

The Pipeline Code

const axios = require('axios');
const fs = require('fs');

const headers = (host) => ({
  'X-RapidAPI-Key': process.env.RAPIDAPI_KEY,
  'X-RapidAPI-Host': host
});

// Step 1: Find businesses on Google Maps
async function findBusinesses(query, limit = 20) {
  const { data } = await axios.get(
    'https://google-maps-scraper12.p.rapidapi.com/google-maps-scraper/search',
    { params: { query, limit }, headers: headers('google-maps-scraper12.p.rapidapi.com') }
  );
  return data.results;
}

// Step 2: Extract emails from their websites
async function extractEmails(websites) {
  const emails = [];
  for (const url of websites.filter(Boolean)) {
    try {
      const { data } = await axios.get(
        'https://email-extractor1.p.rapidapi.com/email-extractor/extract',
        { params: { url }, headers: headers('email-extractor1.p.rapidapi.com') }
      );
      emails.push(...data.emails.map(e => ({ email: e, source: url })));
    } catch {}
    await new Promise(r => setTimeout(r, 500));
  }
  return emails;
}

// Step 3: Enrich with decision-maker data
async function enrichLeads(industry, city) {
  const { data } = await axios.get(
    'https://apollo-lead-scraper.p.rapidapi.com/apollo-lead-scraper/search',
    { params: { query: `owner ${industry} ${city}`, limit: 20 },
      headers: headers('apollo-lead-scraper.p.rapidapi.com') }
  );
  return data.results;
}

// Run the full pipeline
async function leadGenPipeline(industry, city) {
  console.log(`Finding ${industry} businesses in ${city}...`);
  const businesses = await findBusinesses(`${industry} in ${city}`);

  console.log(`Extracting emails from ${businesses.length} websites...`);
  const emails = await extractEmails(businesses.map(b => b.website));

  console.log(`Enriching with decision-maker data...`);
  const enriched = await enrichLeads(industry, city);

  // Merge and export
  const leads = businesses.map(b => ({
    business: b.name, phone: b.phone, address: b.address,
    website: b.website, rating: b.rating,
    email: emails.find(e => e.source === b.website)?.email || '',
    decisionMaker: enriched.find(e =>
      e.company?.toLowerCase().includes(b.name.split(' ')[0].toLowerCase())
    )?.name || ''
  }));

  // Save as CSV
  const csv = ['Business,Phone,Address,Email,Decision Maker,Rating'];
  leads.forEach(l => csv.push(
    `"${l.business}",${l.phone},"${l.address}",${l.email},${l.decisionMaker},${l.rating}`
  ));
  fs.writeFileSync('leads.csv', csv.join('\n'));
  console.log(`Pipeline complete: ${leads.length} leads exported to leads.csv`);
}

leadGenPipeline('restaurants', 'Chicago IL');
Enter fullscreen mode Exit fullscreen mode

Why This Works

  • Google Maps gives you verified businesses with phone numbers and websites
  • Email Extractor pulls contact emails that aren't listed on Maps
  • Apollo fills in the human element — who to actually reach out to

All three APIs have free tiers. You can run this entire pipeline without spending a dollar.

Next Steps

  1. Add a CRM integration (HubSpot, Pipedrive) to auto-import leads
  2. Schedule the pipeline to run weekly for fresh leads
  3. Add filtering by rating (4+ stars = established business = more likely to buy)

👉 Get started:


Related APIs by Donny Digital

Digital Products: Prompt Packs, Notion Templates & More on Gumroad

👉 Browse all APIs on RapidAPI

Top comments (0)