Building a Talent Pipeline

This recipe shows how to build and maintain a talent pipeline for ongoing recruiting needs using the B2D API.

Overview

What you’ll accomplish:
  1. Search for developers with specific skills across multiple locations
  2. Build a ranked talent database with contact information
  3. Track and monitor top candidates over time
  4. Generate engagement templates for outreach
Total time: ~10 minutes
Credits used: 1 per candidate retrieved

Step 1: Define Your Talent Requirements

Start by searching for developers with specific technical skills and experience levels.
import requests
import json
from datetime import datetime

API_KEY = "YOUR_API_KEY"
headers = {"x-api-key": API_KEY}

# Define search criteria for multiple skill sets
skill_searches = [
    {
        "query": ["github_username"],
        "skills": ["python", "django", "postgresql"],
        "locations": ["United States", "Canada", "United Kingdom"]
    },
    {
        "query": ["github_username"],
        "skills": ["react", "typescript", "node"],
        "locations": ["United States", "Remote"]
    },
    {
        "query": ["github_username"],
        "skills": ["kubernetes", "docker", "terraform"],
        "locations": ["United States", "Europe"]
    }
]

talent_pool = []

Step 2: Search for Candidates by Skills

Use the User endpoint to find developers matching your criteria.
def search_developers_by_criteria(criteria, size=50):
    """Search for developers matching specific criteria"""
    
    all_candidates = []
    
    # Search using different parameters
    # Note: This is a simplified example - in production you'd use 
    # job search endpoint for better skill matching
    
    params = {
        "size": size,
        "required_fields": ["email", "full_name", "github_username"]
    }
    
    # Get sample developers (you'd filter by skills in post-processing
    # or use the job search endpoint with a skill-focused job description)
    response = requests.get(
        "https://api.b2d.ai/user",
        headers=headers,
        params={
            **params,
            "github_username": "torvalds,gvanrossum,antirez"  # Example search
        }
    )
    
    if response.status_code == 200:
        candidates = response.json().get('results', [])
        
        # Filter and score candidates based on criteria
        for candidate in candidates:
            # Check if candidate has relevant skills
            candidate_skills = [s['skill'].lower() for s in candidate.get('skills', [])]
            
            # Calculate match score
            skill_match = sum(1 for skill in criteria['skills'] 
                            if skill in ' '.join(candidate_skills))
            
            if skill_match > 0:
                candidate['match_score'] = skill_match
                candidate['search_criteria'] = criteria['skills']
                all_candidates.append(candidate)
    
    return all_candidates

# Search for each skill set
for criteria in skill_searches:
    print(f"🔍 Searching for {', '.join(criteria['skills'])} developers...")
    candidates = search_developers_by_criteria(criteria)
    talent_pool.extend(candidates)
    print(f"   Found {len(candidates)} matching candidates")

print(f"\n✅ Total talent pool: {len(talent_pool)} developers")

Step 3: Enrich and Rank Candidates

Enhance profiles with additional data and create a ranking system.
def enrich_and_score_candidate(candidate):
    """Add scoring metrics to candidate profile"""
    
    score = 0
    scoring_factors = []
    
    # GitHub activity scoring
    repos = candidate.get('public_repos', 0)
    if repos > 50:
        score += 20
        scoring_factors.append(f"Active: {repos} repos")
    elif repos > 20:
        score += 10
        scoring_factors.append(f"Moderate: {repos} repos")
    
    # Follower influence
    followers = candidate.get('followers', 0)
    if followers > 1000:
        score += 25
        scoring_factors.append(f"Influencer: {followers} followers")
    elif followers > 100:
        score += 15
        scoring_factors.append(f"Known: {followers} followers")
    
    # Recent activity
    if candidate.get('updated_at'):
        last_active = candidate['updated_at']
        if '2025' in last_active:
            score += 20
            scoring_factors.append("Recently active")
    
    # Has contact info
    if candidate.get('email'):
        score += 15
        scoring_factors.append("Email available")
    
    if candidate.get('linkedin_username'):
        score += 10
        scoring_factors.append("LinkedIn available")
    
    # Add scoring to candidate
    candidate['pipeline_score'] = score
    candidate['scoring_factors'] = scoring_factors
    
    return candidate

# Enrich all candidates
enriched_pool = [enrich_and_score_candidate(c) for c in talent_pool]

# Sort by score
enriched_pool.sort(key=lambda x: x.get('pipeline_score', 0), reverse=True)

print("\n🏆 Top 10 Candidates:")
for i, candidate in enumerate(enriched_pool[:10], 1):
    name = candidate.get('full_name', 'N/A')
    username = candidate['github_username']
    score = candidate.get('pipeline_score', 0)
    factors = ', '.join(candidate.get('scoring_factors', []))
    
    print(f"{i}. {name} (@{username})")
    print(f"   Score: {score} | {factors}")

Step 4: Build Talent Database

Create a structured database for ongoing pipeline management.
def create_talent_database(candidates):
    """Create structured database for talent pipeline"""
    
    database = {
        "created": datetime.now().isoformat(),
        "total_candidates": len(candidates),
        "segments": {
            "tier_1": [],  # Score 60+
            "tier_2": [],  # Score 40-59
            "tier_3": [],  # Score 20-39
            "monitoring": []  # Score < 20
        },
        "by_skill": {},
        "by_location": {}
    }
    
    for candidate in candidates:
        score = candidate.get('pipeline_score', 0)
        
        # Segment by tier
        if score >= 60:
            tier = "tier_1"
        elif score >= 40:
            tier = "tier_2"
        elif score >= 20:
            tier = "tier_3"
        else:
            tier = "monitoring"
        
        # Create candidate record
        record = {
            "github_username": candidate['github_username'],
            "full_name": candidate.get('full_name'),
            "email": candidate.get('email'),
            "linkedin": candidate.get('linkedin_username'),
            "location": candidate.get('location'),
            "company": candidate.get('company'),
            "score": score,
            "factors": candidate.get('scoring_factors', []),
            "skills": [s['skill'] for s in candidate.get('skills', [])[:5]],
            "followers": candidate.get('followers', 0),
            "repos": candidate.get('public_repos', 0),
            "last_active": candidate.get('updated_at'),
            "added_to_pipeline": datetime.now().isoformat()
        }
        
        database["segments"][tier].append(record)
        
        # Index by skills
        for skill in record['skills']:
            if skill not in database["by_skill"]:
                database["by_skill"][skill] = []
            database["by_skill"][skill].append(record['github_username'])
        
        # Index by location
        location = candidate.get('country', 'unknown')
        if location not in database["by_location"]:
            database["by_location"][location] = []
        database["by_location"][location].append(record['github_username'])
    
    return database

# Create the database
talent_db = create_talent_database(enriched_pool)

# Save to file
with open("talent_pipeline.json", "w") as f:
    json.dump(talent_db, f, indent=2)

print(f"\n📊 Pipeline Summary:")
print(f"   Tier 1 (60+ score): {len(talent_db['segments']['tier_1'])} candidates")
print(f"   Tier 2 (40-59 score): {len(talent_db['segments']['tier_2'])} candidates")
print(f"   Tier 3 (20-39 score): {len(talent_db['segments']['tier_3'])} candidates")
print(f"   Monitoring (<20 score): {len(talent_db['segments']['monitoring'])} candidates")

Step 5: Generate Engagement Templates

Create personalized outreach templates for different candidate tiers.
def generate_outreach_templates(talent_db):
    """Generate outreach templates for different tiers"""
    
    templates = {}
    
    # Tier 1 - Immediate outreach
    if talent_db['segments']['tier_1']:
        candidate = talent_db['segments']['tier_1'][0]
        templates['tier_1'] = {
            "subject": f"Opportunity for {candidate['skills'][0]} expert",
            "body": f"""Hi {candidate.get('full_name', 'there')},

I came across your impressive work on GitHub, particularly your {candidate['repos']} repositories 
and {candidate['followers']} followers. Your expertise in {', '.join(candidate['skills'][:3])} 
aligns perfectly with what we're building.

Would you be open to a brief conversation about an exciting opportunity on our team?

Best regards,
[Your Name]"""
        }
    
    # Tier 2 - Nurture campaign
    templates['tier_2'] = {
        "subject": "Following your open source work",
        "body": """Hi [Name],

I've been following your contributions to [specific project/repo] and am impressed by your 
work in [technology area]. 

We're building something exciting in this space and I'd love to share what we're working on. 
Even if you're not looking right now, I'd value your thoughts on our technical approach.

Would you be interested in a casual tech discussion over coffee (virtual or in-person)?

Best,
[Your Name]"""
    }
    
    # Tier 3 - Long-term relationship
    templates['tier_3'] = {
        "subject": "Connecting with fellow [technology] developers",
        "body": """Hi [Name],

I noticed we're both working in [technology/framework] and wanted to connect. 
I'm building my network of talented developers and would love to stay in touch 
about industry trends and opportunities.

Feel free to reach out if you ever want to discuss [technology] or explore new opportunities.

Best,
[Your Name]"""
    }
    
    return templates

templates = generate_outreach_templates(talent_db)

print("\n📧 Outreach Templates Generated:")
for tier, template in templates.items():
    print(f"\n{tier.upper()}:")
    print(f"Subject: {template['subject']}")
    print("Preview: " + template['body'][:100] + "...")

Step 6: Monitor and Update Pipeline

Set up monitoring to track candidate changes over time.
def update_pipeline_status(talent_db):
    """Check for updates to candidates in pipeline"""
    
    updates = []
    
    # Check tier 1 candidates for changes
    for candidate in talent_db['segments']['tier_1'][:5]:
        username = candidate['github_username']
        
        # Fetch latest data
        response = requests.get(
            "https://api.b2d.ai/user",
            headers=headers,
            params={"github_username": username}
        )
        
        if response.status_code == 200:
            latest = response.json()['results'][0]
            
            # Check for changes
            changes = []
            if latest.get('company') != candidate.get('company'):
                changes.append(f"Company: {candidate.get('company')}{latest.get('company')}")
            
            if latest.get('location') != candidate.get('location'):
                changes.append(f"Location: {candidate.get('location')}{latest.get('location')}")
            
            if latest.get('followers', 0) > candidate.get('followers', 0) + 100:
                changes.append(f"Followers: +{latest.get('followers', 0) - candidate.get('followers', 0)}")
            
            if changes:
                updates.append({
                    "username": username,
                    "name": candidate.get('full_name'),
                    "changes": changes,
                    "timestamp": datetime.now().isoformat()
                })
    
    return updates

# Check for updates (in production, run this periodically)
print("\n🔄 Checking for pipeline updates...")
updates = update_pipeline_status(talent_db)

if updates:
    print(f"Found {len(updates)} candidate updates:")
    for update in updates:
        print(f"\n👤 {update['name']} (@{update['username']})")
        for change in update['changes']:
            print(f"   • {change}")
else:
    print("No significant changes detected")

Complete Pipeline Script

Here’s a complete script that combines all steps:
import requests
import json
from datetime import datetime
import time

class TalentPipeline:
    def __init__(self, api_key):
        self.api_key = api_key
        self.headers = {"x-api-key": api_key}
        self.base_url = "https://api.b2d.ai"
        
    def build_pipeline(self, search_criteria, output_file="talent_pipeline.json"):
        """Build complete talent pipeline"""
        
        print("🚀 Building Talent Pipeline...\n")
        
        # Step 1: Search for candidates
        candidates = self.search_candidates(search_criteria)
        
        # Step 2: Enrich and score
        candidates = self.enrich_candidates(candidates)
        
        # Step 3: Create database
        database = self.create_database(candidates)
        
        # Step 4: Save results
        with open(output_file, "w") as f:
            json.dump(database, f, indent=2)
        
        print(f"\n✅ Pipeline saved to {output_file}")
        print(f"   Total candidates: {len(candidates)}")
        print(f"   Credits used: {len(candidates)}")
        
        return database
    
    def search_candidates(self, criteria):
        """Search for candidates based on criteria"""
        # Implementation here
        pass
    
    def enrich_candidates(self, candidates):
        """Add scoring and enrichment"""
        # Implementation here
        pass
    
    def create_database(self, candidates):
        """Structure candidates into database"""
        # Implementation here
        pass

# Usage
if __name__ == "__main__":
    pipeline = TalentPipeline("YOUR_API_KEY")
    
    search_criteria = {
        "skills": ["python", "machine learning", "tensorflow"],
        "locations": ["United States", "Remote"],
        "size": 100
    }
    
    talent_db = pipeline.build_pipeline(search_criteria)

Key Benefits

Proactive Recruiting: Build pipeline before positions open
Data-Driven Scoring: Rank candidates objectively
Continuous Monitoring: Track candidate changes over time
Efficient Outreach: Personalized templates by tier
Strategic Insights: Understand talent availability by skill/location

Best Practices

  1. Update Regularly: Refresh pipeline monthly to catch profile changes
  2. Segment Strategically: Use tiers to prioritize outreach efforts
  3. Track Engagement: Record which candidates respond to outreach
  4. Refine Scoring: Adjust scoring factors based on successful hires
  5. Maintain Relationships: Keep warm connections with tier 2-3 candidates

Next Steps

  • Integrate with ATS: Export pipeline to your applicant tracking system
  • Automate Outreach: Set up email campaigns by tier
  • Track Metrics: Measure pipeline conversion rates
  • Expand Search: Add more skills and locations as needed