Building a Lead Generation Pipeline with APIs
Manual lead research doesn't scale. Here's how to build an automated pipeline that finds businesses, scores their website quality, enriches contact data, and prioritizes outreach — all with API calls.
Why API-Driven Lead Generation?
Most sales teams research leads manually. Open Google, search the business name, click around the website, try to find the owner's email, check their Google rating, see if their site is mobile-friendly. Per lead, this takes 10-15 minutes.
At 100 leads per week, that's 25 hours of manual research. That's a full-time employee doing nothing but Googling businesses.
With APIs, the same process takes 3-5 seconds per lead and costs pennies. Here's how to build a complete pipeline from scratch.
The Pipeline Architecture
A good lead generation pipeline has four stages:
- Discovery — Find businesses in a specific industry and location
- Qualification — Score each business based on their online presence
- Enrichment — Get contact details for the decision maker
- Outreach — Generate personalized messaging for each lead
Each stage maps to a Rebirth API endpoint. Let's build it.
Stage 1: Discovery with Business Lookup
Start by finding all businesses in your target market. The Business Lookup endpoint lets you search by industry and city:
import requests
API_KEY = "rb_live_YOUR_KEY"
HEADERS = {"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}
def discover_leads(industry, city, limit=20):
"""Find businesses by industry and location."""
resp = requests.post(
"https://rebirthapi.com/api/v1/business-lookup",
headers=HEADERS,
json={"query": industry, "city": city, "limit": limit}
)
return resp.json()["results"]
# Find plumbers in Austin
leads = discover_leads("plumbers", "Austin, TX", limit=20)
print(f"Found {len(leads)} plumbing businesses in Austin")
for lead in leads[:3]:
print(f" {lead['name']} — {lead['rating']} stars ({lead['review_count']} reviews)")
print(f" {lead.get('website', 'No website')}")
print(f" {lead.get('phone', 'No phone')}")One API call returns the business name, address, phone, website, rating, review count, and hours. That's already more data than 5 minutes of manual research.
Stage 2: Qualification with Website Audit
Not every business is a good lead. The Website Audit endpoint helps you score each business's online presence and identify pain points you can solve:
def qualify_lead(business):
"""Score a lead based on their website quality."""
if not business.get("website"):
return {**business, "lead_score": 90, "issues": ["No website at all"]}
audit = requests.post(
"https://rebirthapi.com/api/v1/website-audit",
headers=HEADERS,
json={"url": business["website"], "industry": "plumbing"}
).json()
# Calculate lead score — higher = more likely to need help
score = 0
issues = []
if audit["scores"]["speed"] < 50:
score += 25
issues.append(f"Slow website (speed: {audit['scores']['speed']}/100)")
if audit["scores"]["mobile"] < 70:
score += 25
issues.append(f"Poor mobile experience ({audit['scores']['mobile']}/100)")
if audit["scores"]["seo"] < 60:
score += 20
issues.append(f"SEO issues ({audit['scores']['seo']}/100)")
if business.get("rating", 5) < 4.0:
score += 15
issues.append(f"Low Google rating ({business['rating']} stars)")
if business.get("review_count", 0) < 20:
score += 15
issues.append(f"Few reviews ({business.get('review_count', 0)})")
return {
**business,
"audit": audit["scores"],
"lead_score": score,
"issues": issues,
"priority": "hot" if score >= 50 else "warm" if score >= 25 else "cold"
}
# Score all discovered leads
qualified = [qualify_lead(lead) for lead in leads]
# Sort by score — hottest leads first
qualified.sort(key=lambda x: x["lead_score"], reverse=True)
print("\nTop 5 leads by score:")
for lead in qualified[:5]:
print(f" [{lead['priority'].upper()}] {lead['name']} — Score: {lead['lead_score']}")
for issue in lead["issues"]:
print(f" - {issue}")Now you have a ranked list of leads. A plumber with a slow website, poor mobile experience, and 3.2-star rating is a much hotter lead than one with a perfect website and 4.9 stars.
Stage 3: Enrichment
For your hottest leads, you want contact details for the decision maker. The Lead Enrichment endpoint turns an email or domain into a full profile:
def enrich_lead(business):
"""Get decision-maker contact info from the business domain."""
website = business.get("website", "")
if not website:
return business
# Extract domain from website URL
domain = website.replace("https://", "").replace("http://", "").split("/")[0]
enriched = requests.post(
"https://rebirthapi.com/api/v1/lead-enrich",
headers=HEADERS,
json={"domain": domain}
).json()
return {
**business,
"contact": enriched.get("person", {}),
"company_info": enriched.get("company", {})
}
# Enrich only hot and warm leads (save API calls)
hot_leads = [l for l in qualified if l["priority"] in ("hot", "warm")]
enriched_leads = [enrich_lead(lead) for lead in hot_leads]
for lead in enriched_leads[:3]:
contact = lead.get("contact", {})
if contact:
print(f"{lead['name']}")
print(f" Contact: {contact.get('name', 'N/A')} — {contact.get('title', 'N/A')}")
print(f" LinkedIn: {contact.get('linkedin', 'N/A')}")
print(f" Score: {lead['lead_score']} ({lead['priority']})")Stage 4: Personalized Outreach
With all the data you've collected, you can generate hyper-personalized outreach. The SMS Generate endpoint creates industry-aware messages that reference specific issues:
def generate_outreach(lead):
"""Create a personalized outreach message based on lead data."""
# Build context from discovered issues
context_parts = []
if lead.get("issues"):
context_parts.append(f"Their website has issues: {', '.join(lead['issues'][:2])}")
if lead.get("contact", {}).get("name"):
context_parts.append(f"Decision maker: {lead['contact']['name']}")
sms = requests.post(
"https://rebirthapi.com/api/v1/sms-generate",
headers=HEADERS,
json={
"type": "follow_up",
"industry": "plumbing",
"context": ". ".join(context_parts),
"business_name": "YourAgency" # Your company name
}
).json()
return {
"to": lead["name"],
"phone": lead.get("phone", "N/A"),
"message": sms["message"],
"lead_score": lead["lead_score"]
}
# Generate outreach for top 10 leads
outreach = [generate_outreach(lead) for lead in enriched_leads[:10]]
for msg in outreach[:3]:
print(f"To: {msg['to']} ({msg['phone']})")
print(f"Score: {msg['lead_score']}")
print(f"Message: {msg['message']}")
print()Putting It All Together
Here's the complete pipeline in one script. Four API calls per lead, one API key, complete lead intelligence:
import requests
import json
API_KEY = "rb_live_YOUR_KEY"
HEADERS = {"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}
BASE = "https://rebirthapi.com/api/v1"
def run_pipeline(industry, city, limit=20):
print(f"Running pipeline: {industry} in {city}")
# Stage 1: Discover
leads = requests.post(f"{BASE}/business-lookup",
headers=HEADERS,
json={"query": industry, "city": city, "limit": limit}
).json()["results"]
print(f" Found {len(leads)} businesses")
# Stage 2: Qualify (audit websites)
for lead in leads:
if lead.get("website"):
audit = requests.post(f"{BASE}/website-audit",
headers=HEADERS,
json={"url": lead["website"]}
).json()
lead["scores"] = audit.get("scores", {})
lead["issues"] = audit.get("issues", [])
# Score it
score = 0
if lead.get("scores", {}).get("speed", 100) < 50: score += 25
if lead.get("scores", {}).get("mobile", 100) < 70: score += 25
if lead.get("rating", 5) < 4.0: score += 20
if not lead.get("website"): score += 30
lead["lead_score"] = score
# Sort by score
leads.sort(key=lambda x: x["lead_score"], reverse=True)
hot = [l for l in leads if l["lead_score"] >= 40]
print(f" {len(hot)} hot leads identified")
# Stage 3: Enrich top leads
for lead in hot[:10]:
if lead.get("website"):
domain = lead["website"].replace("https://","").replace("http://","").split("/")[0]
enriched = requests.post(f"{BASE}/lead-enrich",
headers=HEADERS, json={"domain": domain}
).json()
lead["contact"] = enriched.get("person", {})
# Stage 4: Generate outreach
for lead in hot[:10]:
sms = requests.post(f"{BASE}/sms-generate",
headers=HEADERS,
json={
"type": "follow_up",
"industry": industry,
"context": f"Business: {lead['name']}. Issues: {', '.join(lead.get('issues', [])[:2])}",
"business_name": "YourAgency"
}
).json()
lead["outreach"] = sms["message"]
return hot
# Run it
results = run_pipeline("HVAC companies", "Dallas, TX", limit=20)
print(f"\nGenerated {len(results)} qualified leads with outreach messages")Cost Analysis
Let's break down the cost for processing 100 leads per week:
| Stage | Calls | Cost/call | Weekly cost |
|---|---|---|---|
| Business Lookup (100 leads) | 5 | $0.15 | $0.75 |
| Website Audit (100 leads) | 100 | $0.10 | $10.00 |
| Lead Enrichment (top 30) | 30 | $0.08 | $2.40 |
| SMS Generate (top 30) | 30 | $0.03 | $0.90 |
| Total | 165 | $14.05/week |
$14.05 per week for 100 fully qualified leads with contact enrichment and personalized outreach messages. Compare that to the $750/week cost of having a human do the same research manually.
Scaling Tips
1. Target Multiple Industries and Cities
Run the pipeline for every industry-city combination you serve. Plumbers in Austin, HVAC in Dallas, dentists in Houston. Each run generates a fresh batch of qualified leads.
2. Schedule Weekly Runs
Set up a cron job or scheduled task to run the pipeline weekly. New businesses appear, existing ones update their websites, and ratings change. Regular runs keep your pipeline fresh.
3. Deduplicate Across Runs
Store discovered businesses in a database and skip duplicates. You don't want to reach out to the same business twice. Use the phone number or website as a unique key.
4. A/B Test Your Outreach
Generate multiple message variants for each lead and track which ones get responses. Over time, you'll learn which messaging resonates best for each industry.
FAQ
How many API calls does this pipeline use per lead?
1-4 calls depending on the stage. Discovery uses 1 call per batch (returns up to 20 results). Website Audit is 1 call per lead. Enrichment and SMS are 1 call each. For a hot lead that goes through all stages, it's 3-4 calls total.
Can I use this for email outreach instead of SMS?
Absolutely. The pipeline gives you the data — business details, website issues, contact info. You can use that to craft personalized emails instead of SMS. The SMS Generate endpoint is just one option for the outreach stage.
What about compliance?
Always follow CAN-SPAM, TCPA, and local regulations for outreach. The pipeline generates the message, but you're responsible for how you deliver it. See our SMS compliance guide for details.
Build Your Lead Pipeline Today
Start with 100 free API calls/month. No credit card required.