You want to find the right people to follow, reach out to, or partner with on X/Twitter — but scrolling through search results and manually checking profiles doesn’t scale.

Here’s how to programmatically find relevant accounts in any niche, filter by engagement and follower count, and export a qualified list.


The Approach

Search tweets on the topic → Collect their authors → Enrich with profile details → Filter by criteria → Export

The people worth finding are usually the ones actually posting about your niche, so we start from tweets, with account search as an alternative. We’ll use three FetchLayer endpoints:

  • twitter/search — find recent and top tweets on a keyword and collect who wrote them, or search accounts directly with product: 'People'
  • twitter/user-profile-details — get each author’s full profile (follower counts, bio, location) for filtering
  • twitter/user-tweets — check recent activity and engagement

Step 1: Find Who Is Tweeting About It

Search tweets on the keyword (both Top and Latest) and keep each distinct author:

async function searchTweets(keyword, product, count) {
  const res = await fetch('https://api.fetchlayer.dev/twitter/search', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.FETCHLAYER_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ query: keyword, product, count }),
  });

  const data = await res.json();
  return data.tweets || [];
}

async function findAccounts(keyword, count = 50) {
  const tweets = [
    ...(await searchTweets(keyword, 'Top', count)),
    ...(await searchTweets(keyword, 'Latest', count)),
  ];

  // One entry per author, with how often they came up
  const byHandle = new Map();
  for (const t of tweets) {
    const entry = byHandle.get(t.author.handle) ?? { handle: t.author.handle, mentions: 0 };
    entry.mentions++;
    byHandle.set(t.author.handle, entry);
  }
  return [...byHandle.values()].sort((a, b) => b.mentions - a.mentions);
}

// Find accounts talking about SaaS founding
const accounts = await findAccounts('startup founder SaaS');

Each tweet’s author already carries followersCount, so you can drop obvious misses here. The next step still looks each author up, for the bio, post count and location that filtering needs.

Or: search accounts directly

If you’d rather match on what accounts say about themselves than on what they post, search with product: 'People'. Accounts come back in profiles (and tweets is empty), with the same fields as a profile lookup:

async function findAccountsByBio(keyword, count = 50) {
  const res = await fetch('https://api.fetchlayer.dev/twitter/search', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.FETCHLAYER_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ query: keyword, product: 'People', count }),
  });

  const data = await res.json();
  return (data.profiles || []).map((p) => ({ handle: p.handle, mentions: 0 }));
}

Both lists feed the same enrichment step below. Tweet authors tell you who is active on the topic right now; People search finds accounts whose bio matches, even if they haven’t posted about it lately.


Step 2: Enrich with Profile Data

Get detailed profile info for each account so you can filter intelligently:

async function getProfile(handle) {
  const res = await fetch('https://api.fetchlayer.dev/twitter/user-profile-details', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.FETCHLAYER_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ handle }),
  });

  if (!res.ok) return null;
  const data = await res.json();
  return data.profile;
}

async function enrichAccounts(accounts) {
  const enriched = [];

  for (const account of accounts) {
    const profile = await getProfile(account.handle);
    if (!profile) continue;

    enriched.push({
      handle: profile.handle,
      name: profile.name,
      description: profile.description,
      followersCount: profile.followersCount ?? 0,
      followingCount: profile.followingCount ?? 0,
      tweetsCount: profile.tweetsCount ?? 0,
      verified: profile.verified,
      createdAt: profile.createdAt,
      location: profile.location,
      mentions: account.mentions,
    });
  }

  return enriched;
}

Step 3: Filter by Criteria

Define what “influencer” means for your use case:

function filterInfluencers(profiles, options = {}) {
  const {
    minFollowers = 1000,
    maxFollowers = 500000,
    mustBeVerified = false,
    minTweets = 10,
    maxFollowingRatio = 5, // following <= followers * 5
    excludeKeywords = [], // filter out bios containing these
    requireKeywords = [], // only keep bios containing these
  } = options;

  return profiles.filter(p => {
    if (p.followersCount < minFollowers) return false;
    if (p.followersCount > maxFollowers) return false;
    if (mustBeVerified && !p.verified) return false;
    if (p.tweetsCount < minTweets) return false;

    // Avoid spam/follow-back accounts
    if (p.followingCount > p.followersCount * maxFollowingRatio) return false;

    // Keyword filters on bio
    const bio = (p.description || '').toLowerCase();
    if (excludeKeywords.some(kw => bio.includes(kw.toLowerCase()))) return false;
    if (requireKeywords.length > 0 && !requireKeywords.some(kw => bio.includes(kw.toLowerCase()))) return false;

    return true;
  });
}

Step 4: Full Script

// find-influencers.mjs
const KEYWORD = process.argv[2] || 'SaaS founder';
const MIN_FOLLOWERS = parseInt(process.argv[3]) || 1000;

async function run() {
  console.log(`Searching for "${KEYWORD}" on X/Twitter...`);

  // Step 1: Find accounts
  const accounts = await findAccounts(KEYWORD, 50);
  console.log(`Found ${accounts.length} distinct authors`);

  // Step 2: Enrich with profiles
  const profiles = await enrichAccounts(accounts);
  console.log(`Enriched ${profiles.length} profiles`);

  // Step 3: Filter
  const influencers = filterInfluencers(profiles, {
    minFollowers: MIN_FOLLOWERS,
    excludeKeywords: ['crypto', 'NFT', 'onlyfans'],
  });

  // Sort by follower count
  influencers.sort((a, b) => b.followersCount - a.followersCount);

  // Step 4: Export
  console.log(`\nFound ${influencers.length} qualified accounts:\n`);
  for (const inf of influencers.slice(0, 20)) {
    console.log(`@${inf.handle} — ${inf.followersCount.toLocaleString()} followers${inf.verified ? ' ✓' : ''}`);
    console.log(`  ${inf.description?.slice(0, 120) || '(no bio)'}`);
    console.log(`  ${inf.location || 'No location'} · ${inf.mentions} tweet(s) on this topic`);
    console.log();
  }

  // Export to CSV
  const csv = ['handle,name,followersCount,verified,location,mentions,description']
    .concat(influencers.map(i =>
      `"${i.handle}","${(i.name || '').replace(/"/g, '""')}","${i.followersCount}","${i.verified}","${i.location || ''}","${i.mentions}","${(i.description || '').replace(/"/g, '""')}"`
    ))
    .join('\n');

  const fs = await import('fs');
  fs.writeFileSync(`${KEYWORD.replace(/\s+/g, '-').toLowerCase()}-influencers.csv`, csv);
  console.log(`Exported ${influencers.length} accounts to CSV`);
}

run().catch(console.error);
FETCHLAYER_API_KEY=ss-your-fetchlayer-key node find-influencers.mjs "indie hacker" 500

Advanced: Score by Engagement

Get recent tweets to calculate engagement rate and rank by influence:

async function getEngagementRate(handle) {
  const res = await fetch('https://api.fetchlayer.dev/twitter/user-tweets', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.FETCHLAYER_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ handle, count: 20 }),
  });

  const data = await res.json();
  const tweets = data.tweets || [];
  if (tweets.length === 0) return 0;

  const avgLikes = tweets.reduce((sum, t) => sum + t.counts.likes, 0) / tweets.length;
  return avgLikes;
}

// Enrich with engagement and re-rank
for (const inf of influencers) {
  inf.avgLikes = await getEngagementRate(inf.handle);
}

influencers.sort((a, b) => b.avgLikes - a.avgLikes);

What’s Next