Guide · Python

Find Instagram influencers in a niche with Python

Start from a few creators you already trust, read who they follow, rank every account by how many of them follow it, and spend lookups only where the overlap says it is worth it.

ScrapingBot 11 min read
Endpoints
/following/by_user_id, /user/by_id, /medias/by_user_id
Cost
5 credits per call
Language
Python 3.9+
Needs
requests
On this page

Instagram has no "more accounts like this one" you can call. Keyword search gives you one page of accounts for a word, and that is the end of it. But every creator already keeps a hand-picked list of their niche: the accounts they follow. Read that list for a few creators you trust, count who shows up more than once, and the niche sorts itself to the top.

This guide builds that as one script with three stages: lists, profiles, posts. Every number and output below is real, from one run on December 1, 2026: seven specialty-coffee creators in, a shortlist of 319 creators and brands out, for 5,060 credits and under five minutes of API time.

Before you start

  • A ScrapingBot API key. Create a free account for 100 credits, enough to read about 950 of the accounts one creator follows. No card needed.
  • Python 3.9 or newer and pip install requests. The script keeps its state in SQLite, which ships with Python.
  • Five to ten public accounts from the niche you are after: creators you work with, or the ones your customers mention.

The three stages

StageCallWhat you learnOur run
1. Lists/following/by_user_id, about 50 accounts a pageWho each seed follows, and how many seeds follow each account6,045 follows, 5,242 accounts, 625 credits
2. Profiles/user/by_id, one account a callFollowers, bio, category and link, for the accounts with enough overlap544 lookups, 2,720 credits
3. Posts/medias/by_user_id, 12 posts a callEngagement rate and how recently the account posted, for the ones that fit343 accounts, 1,715 credits

The order matters because the price per account rises at each stage. A list page costs 5 credits for about 50 accounts, a tenth of a credit each. A profile costs 5 credits for one. So the cheap stage decides which accounts get the expensive ones.

Why following lists, and not followers

A follower list is an audience. It is long, it is mostly people who never post about the topic, and a large share of it is closed: when we read a coffee association's followers a week earlier, 101 of 244 accounts were private. Instagram also stops some large accounts' follower lists after about 50 accounts.

A following list is a selection. A creator with 850,000 followers follows about 1,100 accounts, each one chosen. In this run 435 of the 5,242 accounts our seeds follow were private, 8%. Here are five of the 47 accounts on the first page of what @jimseven follows:

{
  "success": true,
  "data": {
    "users": [
      …,
      { "id": "1171482827", "username": "specialtycoffeeassociation", "full_name": "Specialty Coffee Association", "is_private": false, "is_verified": false, … },
      { "id": "614959235", "username": "worldcoffeechampionships", "full_name": "World Coffee Championships", "is_private": false, "is_verified": false, … },
      …,
      { "id": "970093191", "username": "lidltrek", "full_name": "Lidl-Trek", "is_private": false, "is_verified": true, … },
      …,
      { "id": "8159599890", "username": "ruffianpan2", "full_name": "barista-Pan", "is_private": false, "is_verified": false, … },
      { "id": "1593067492", "username": "margarethowellltd", "full_name": "Margaret Howell", "is_private": false, "is_verified": true, … },
      …
    ],
    "user_count": 1123,
    "has_more": true,
    "next_max_id": "QVHIpIkbO-5bwwAAAC8V1Op0BikMKgkF",
    …
  },
  "duration": "3.63",
  "statusCode": 200,
  "creditsUsed": 5
}

Two coffee institutions, a cycling team, a barista and a fashion label. One person's list is a mix of their trade and their hobbies. That is why one seed is not enough, and why the next step works.

Overlap is the free filter

Once several lists are stored, counting how many seeds follow each account costs nothing: it is a GROUP BY on data you already paid for. The cycling team and the fashion label are each followed by one of our seven seeds, the Specialty Coffee Association by three. Benjamin Put, a seven-time Canadian barista champion with 16,104 followers, is followed by five.

To see how much that count is worth, we looked up every account followed by two or more seeds, plus a random sample of 200 public accounts followed by just one, and asked two things of each profile: does a coffee word appear in its name, bio or category, and does it have between 5,000 and 250,000 followers? An account that passes both is a fit.

Followed byAccountsLooked upOn topicFit
1 seed4,68220046%24%
2 seeds39337975%53%
3 seeds11711583%77%
4 or 5 seeds505090%84%

The 200 are the sample; in the other rows, the accounts not looked up were private. A lookup spent on an account that three seeds follow was three times as likely to end in a usable account as one spent on an account a single seed follows. And the single-seed group is where the volume is: looking up all 4,807 public accounts would have cost 24,035 credits. Stopping at two seeds cost 2,720.

The script

Save this as discover.py. It keeps everything in one SQLite file, discover.db, so each stage can be run again without paying twice: an account that has been looked up is never looked up again, and a run that stops halfway, because the credits ran out or you pressed Ctrl-C, stores every answer it has paid for first.

import csv
import re
import sqlite3
import statistics
import sys
import threading
import time
from concurrent.futures import FIRST_COMPLETED, ThreadPoolExecutor, wait
from datetime import datetime, timezone

import requests

API = "https://scrapingbot.io/api/v1/instagram"
HEADERS = {"x-api-key": "YOUR_API_KEY"}
CONCURRENCY = 1  # your plan's limit: Free 1, Starter 10, Startup 50
MIN_SEEDS = 2  # look an account up when at least this many seeds follow it
TRUST = 3  # followed by this many seeds: kept even when no keyword matches
KEYWORDS = ["coffee", "espresso", "barista", "roast", "cafe", "café", "brew"]  # [] turns the topic filter off
MIN_FOLLOWERS, MAX_FOLLOWERS = 5_000, 250_000
POSTS = 12  # recent posts read per account
DB, OUT = "discover.db", "shortlist.csv"
FIELDS = ["username", "full_name", "seeds", "followers", "er_median", "avg_likes", "avg_comments",
          "posts_30d", "last_post", "category", "external_url", "biography", "followed_by", "user_id"]
credits = {"used": 0}
lock = threading.Lock()


class NotFound(Exception):
    pass


class Stop(Exception):
    pass


def call(endpoint, params, tries=4):
    """One Instagram call: 5 credits on success. Failed calls are refunded."""
    error = "no answer"
    for attempt in range(tries):
        try:
            res = requests.post(API, headers=HEADERS, timeout=60,
                                json={"endpoint": endpoint, "params": params})
            body = res.json()
        except (requests.RequestException, ValueError) as err:  # dropped connection or not JSON
            error = str(err)
            time.sleep(2 ** attempt)
            continue
        if body.get("success"):
            with lock:
                credits["used"] += body.get("creditsUsed", 0)
            return body.get("data") or {}
        error = body.get("error")
        if res.status_code == 404:  # no such account: retrying will not help
            raise NotFound(error)
        if res.status_code in (401, 402):  # bad key or out of credits: stop the run
            raise Stop(error)
        if res.status_code == 400:
            raise RuntimeError(error)
        time.sleep(2 ** attempt)  # 408, 429 or 5xx: wait and try again
    raise RuntimeError(f"kept failing: {error}")


def open_db():
    db = sqlite3.connect(DB)
    db.row_factory = sqlite3.Row
    db.executescript("""
        CREATE TABLE IF NOT EXISTS seeds (user_id TEXT PRIMARY KEY, username TEXT, following INTEGER,
            listed INTEGER, read_at TEXT);
        CREATE TABLE IF NOT EXISTS follows (seed_id TEXT, user_id TEXT, PRIMARY KEY (seed_id, user_id));
        CREATE TABLE IF NOT EXISTS accounts (user_id TEXT PRIMARY KEY, username TEXT, full_name TEXT,
            is_private INTEGER, is_verified INTEGER, followers INTEGER, biography TEXT, category TEXT,
            external_url TEXT, profile TEXT, er_median REAL, avg_likes INTEGER, avg_comments INTEGER,
            posts_30d INTEGER, last_post TEXT, posts TEXT);
    """)
    return db


def clean(handle):
    """'jimseven', '@JimSeven' and a profile link all become '@jimseven'. The @ keeps an all-digit handle a handle."""
    h = handle.strip()
    if "instagram.com/" in h:
        h = h.split("instagram.com/")[1].split("/")[0].split("?")[0]
    return "@" + h.lstrip("@").lower()


def on_topic(row):
    """True when a keyword shows up in what we know about the account so far."""
    text = " ".join(str(row[k] or "") for k in ("username", "full_name", "biography", "category")).lower()
    return not KEYWORDS or any(k in text for k in KEYWORDS)


def read_seed(db, handle):
    """Store everyone a seed follows. One call for the seed, then one per page of about 50 accounts."""
    seed = call("/user/by_username", {"username": handle})
    seed_id, counted, max_id, cursors = str(seed["id"]), seed.get("following_count") or 0, None, set()

    def store():  # after every page, so a read that stops early keeps what it paid for
        listed = db.execute("SELECT COUNT(*) FROM follows WHERE seed_id = ?", (seed_id,)).fetchone()[0]
        db.execute("INSERT OR REPLACE INTO seeds VALUES (?, ?, ?, ?, ?)",
                   (seed_id, seed["username"], counted, listed,
                    datetime.now(timezone.utc).isoformat(timespec="seconds")))
        db.commit()
        return listed

    try:
        while True:
            params = {"user_id": seed_id, **({"max_id": max_id} if max_id else {})}
            page = call("/following/by_user_id", params)
            for u in page.get("users") or []:
                if not u.get("id") or not u.get("username"):
                    continue
                db.execute("""INSERT INTO accounts (user_id, username, full_name, is_private, is_verified)
                              VALUES (?, ?, ?, ?, ?) ON CONFLICT (user_id) DO UPDATE SET
                              username = excluded.username, full_name = excluded.full_name,
                              is_private = excluded.is_private""",
                           (str(u["id"]), u["username"], u.get("full_name") or "",
                            int(bool(u.get("is_private"))), int(bool(u.get("is_verified")))))
                db.execute("INSERT OR IGNORE INTO follows VALUES (?, ?)", (seed_id, str(u["id"])))
            store()
            max_id = page.get("next_max_id")
            if not page.get("has_more") or not max_id or max_id in cursors:  # the end, or a cursor going in circles
                break
            cursors.add(max_id)
    finally:  # a second read adds to the first and never removes: `drop` the seed to start its list over
        print(f"@{seed['username']}: {store():,} of {counted:,} accounts listed")


CANDIDATES = """
    SELECT a.*, COUNT(*) AS seeds, GROUP_CONCAT(s.username, ' ') AS followed_by
    FROM follows f JOIN accounts a ON a.user_id = f.user_id JOIN seeds s ON s.user_id = f.seed_id
    WHERE a.user_id NOT IN (SELECT user_id FROM seeds)
    GROUP BY a.user_id HAVING COUNT(*) >= ? ORDER BY seeds DESC, a.username"""


def overlap(db):
    """Free: how many accounts 1, 2, 3... seeds follow, from what is already stored."""
    rows = db.execute(CANDIDATES, (1,)).fetchall()
    seeds = db.execute("SELECT COUNT(*) FROM seeds").fetchone()[0]
    print(f"{len(rows):,} accounts from {seeds} seed{'' if seeds == 1 else 's'}")
    for n in sorted({r["seeds"] for r in rows}):
        group = [r for r in rows if r["seeds"] == n]
        print(f"  followed by {n}: {len(group):>6,}   private {sum(r['is_private'] for r in group):>5,}   "
              f"keyword match {sum(on_topic(r) for r in group) if KEYWORDS else 0:>5,}")


def each(db, rows, work, save):
    """Run work(row) for every row, at most CONCURRENCY calls in flight, and store each answer as it arrives."""
    waiting, running, stopped = iter(rows), {}, None
    with ThreadPoolExecutor(max_workers=CONCURRENCY) as pool:
        while True:
            while not stopped and len(running) < CONCURRENCY:
                row = next(waiting, None)
                if row is None:
                    break
                running[pool.submit(work, row)] = row
            if not running:
                break
            try:
                finished = wait(running, return_when=FIRST_COMPLETED).done
            except KeyboardInterrupt:  # Ctrl-C: start nothing new, store the answers already on their way
                if stopped:
                    raise
                stopped = "interrupted, storing the calls in flight (Ctrl-C again quits now)"
                print(stopped)
                continue
            for future in finished:
                row = running.pop(future)
                try:
                    save(row, future.result())
                    db.commit()
                except Stop as err:  # bad key or no credits left: the other calls in flight are still stored
                    stopped = stopped or err
    if stopped:
        print(f"stopped: {stopped}")


def lookup(row):
    try:
        return call("/user/by_id", {"user_id": row["user_id"]})
    except NotFound:
        return None
    except RuntimeError as err:
        return err


def save_profile(db):
    def save(row, p):
        if isinstance(p, Exception):
            return print(f"@{row['username']}: {p} (not stored, the next run tries again)")
        if p is None:
            return db.execute("UPDATE accounts SET profile = 'gone' WHERE user_id = ?", (row["user_id"],))
        db.execute("""UPDATE accounts SET username = ?, full_name = ?, is_private = ?, followers = ?, biography = ?,
                      category = ?, external_url = ?, profile = 'ok' WHERE user_id = ?""",
                   (p.get("username") or row["username"], p.get("full_name") or "", int(bool(p.get("is_private"))),
                    p.get("follower_count"), p.get("biography") or "", p.get("category") or "",
                    p.get("external_url") or "", row["user_id"]))
    return save


def measure(row):
    """Median engagement on the account's own recent posts, and how active its grid is."""
    try:
        feed = call("/medias/by_user_id", {"user_id": row["user_id"], "count": POSTS})
    except NotFound:
        return None
    except RuntimeError as err:
        return err
    own, dates = [], []
    for edge in feed.get("edges") or []:
        post = edge.get("node") or {}
        if not post.get("taken_at"):
            continue
        dates.append(post["taken_at"])  # activity: every post on the grid, measurable or not
        owner = post.get("owner") or {}
        mine = str(owner["id"]) == row["user_id"] if owner.get("id") else owner.get("username") == row["username"]
        if (not mine or post.get("coauthor_producers")  # a collab: the likes come from two audiences
                or row["user_id"] in [str(i) for i in post.get("timeline_pinned_user_ids") or []]  # pinned, often old
                or post.get("like_and_view_counts_disabled") or post.get("like_count") is None):  # hidden count
            continue
        own.append(post)
    if not own or not row["followers"]:
        return {}
    month_ago = time.time() - 30 * 86400
    rates = [(p["like_count"] + (p.get("comment_count") or 0)) / row["followers"] * 100 for p in own]
    return {"er_median": round(statistics.median(rates), 3),
            "avg_likes": round(statistics.mean(p["like_count"] for p in own)),
            "avg_comments": round(statistics.mean(p.get("comment_count") or 0 for p in own)),
            "posts_30d": sum(d >= month_ago for d in dates),  # of the POSTS latest: 12 means 12 or more
            "last_post": datetime.fromtimestamp(max(dates), timezone.utc).date().isoformat()}


def save_posts(db):
    def save(row, m):
        if isinstance(m, Exception):
            return print(f"@{row['username']}: {m} (not stored, the next run tries again)")
        m = m or {}
        db.execute("""UPDATE accounts SET er_median = ?, avg_likes = ?, avg_comments = ?, posts_30d = ?,
                      last_post = ?, posts = ? WHERE user_id = ?""",
                   (m.get("er_median"), m.get("avg_likes"), m.get("avg_comments"), m.get("posts_30d"),
                    m.get("last_post"), "ok" if m else "none", row["user_id"]))
    return save


def safe(value):
    """Names and bios come from strangers: keep a spreadsheet from reading one as a formula."""
    text = re.sub(r"\s+", " ", str(value if value is not None else "")).strip()
    return "'" + text if text[:1] in ("=", "+", "-", "@") else text


def fits(row):
    return (row["profile"] == "ok" and not row["is_private"] and (on_topic(row) or row["seeds"] >= TRUST)
            and MIN_FOLLOWERS <= (row["followers"] or 0) <= MAX_FOLLOWERS)


def export(db):
    rows = [r for r in db.execute(CANDIDATES, (MIN_SEEDS,)) if fits(r) and r["posts"] == "ok"]
    rows.sort(key=lambda r: (-r["seeds"], -(r["er_median"] or 0)))
    with open(OUT, "w", newline="", encoding="utf-8") as f:
        writer = csv.DictWriter(f, fieldnames=FIELDS)
        writer.writeheader()
        for r in rows:
            writer.writerow({k: safe(r[k]) if isinstance(r[k], str) else r[k] for k in FIELDS})
    print(f"{len(rows):,} accounts in {OUT}")
    for r in rows[:15]:
        print(f"  {r['seeds']} seeds  @{r['username']:<26} {r['followers']:>8,} followers  "
              f"{r['er_median']:>5.2f}%  {r['posts_30d']:>2} posts in 30 days")


if __name__ == "__main__":
    command, args = (sys.argv[1] if len(sys.argv) > 1 else ""), sys.argv[2:]
    db = open_db()
    try:
        if command == "seeds":
            for handle in dict.fromkeys(clean(a) for a in args):
                try:
                    read_seed(db, handle)
                except NotFound:
                    print(f"{handle}: no such account")
                except RuntimeError as err:
                    print(f"{handle}: {err} (name it again to read the whole list)")
            overlap(db)
        elif command == "drop":  # take a seed's votes out; the profiles and posts already read stay
            for handle in dict.fromkeys(clean(a) for a in args):
                seed = db.execute("SELECT user_id FROM seeds WHERE lower(username) = ?", (handle[1:],)).fetchone()
                if seed:
                    db.execute("DELETE FROM follows WHERE seed_id = ?", (seed["user_id"],))
                    db.execute("DELETE FROM seeds WHERE user_id = ?", (seed["user_id"],))
                print(f"{handle}: {'dropped' if seed else 'not a seed here'}")
            overlap(db)
        elif command == "profiles":
            rows = [r for r in db.execute(CANDIDATES, (MIN_SEEDS,)) if not r["profile"] and not r["is_private"]]
            print(f"looking up {len(rows):,} accounts, about {len(rows) * 5:,} credits")
            each(db, rows, lookup, save_profile(db))
            kept = [r for r in db.execute(CANDIDATES, (MIN_SEEDS,)) if fits(r)]
            print(f"{len(kept):,} fit: public, {MIN_FOLLOWERS:,} to {MAX_FOLLOWERS:,} followers, "
                  f"on topic or followed by {TRUST}+ seeds")
        elif command == "posts":
            rows = [r for r in db.execute(CANDIDATES, (MIN_SEEDS,)) if fits(r) and not r["posts"]]
            print(f"reading posts of {len(rows):,} accounts, about {len(rows) * 5:,} credits")
            each(db, rows, measure, save_posts(db))
            export(db)
        else:
            print("usage: discover.py seeds @handle [@handle ...] | drop @handle | profiles | posts")
    except Stop as err:
        print(f"stopped: {err}")
    except KeyboardInterrupt:
        print("interrupted")
    finally:
        db.commit()
        print(f"{credits['used']:,} credits used")

The constants at the top are the decisions:

  • MIN_SEEDS = 2 is the overlap an account needs before it gets a lookup. Raise it to 3 for a short, sure list; the table above says what you give up.
  • KEYWORDS are matched against the handle, name, bio and category, in lower case. Substrings count, so roast also finds "roaster" and "roastery". An empty list turns the filter off.
  • TRUST = 3 keeps an account that three or more seeds follow even when no keyword matches. The run below shows why.
  • MIN_FOLLOWERS and MAX_FOLLOWERS set the size you are after. The cap also removes the celebrities every list contains.
  • CONCURRENCY is how many calls are in flight at once in stages 2 and 3. Keep it at or under your plan's limit: 1 on Free, 10 on Starter, 50 on Startup.
  • POSTS = 12 is one call's worth of recent posts. It also caps what the activity column can see: posts_30d counts posts among those 12, so 12 means "12 or more".

Run it

Stage 1 takes the seeds, as handles or profile links:

python discover.py seeds @jimseven @lancehedrick @morgandrinkscoffee @thecoffeechronicler \
    @goldenbrown.coffee @sprometheus @coffeebae97
@jimseven: 1,123 of 1,124 accounts listed
@lancehedrick: 1,308 of 1,309 accounts listed
@morgandrinkscoffee: 1,226 of 1,227 accounts listed
@thecoffeechronicler: 816 of 817 accounts listed
@goldenbrown.coffee: 976 of 976 accounts listed
@sprometheus: 283 of 283 accounts listed
@coffeebae97: 313 of 314 accounts listed
5,242 accounts from 7 seeds
  followed by 1:  4,682   private   419   keyword match 1,172
  followed by 2:    393   private    14   keyword match   155
  followed by 3:    117   private     2   keyword match    50
  followed by 4:     40   private     0   keyword match    15
  followed by 5:     10   private     0   keyword match     2
625 credits used

That took 2 minutes 53 seconds: list pages are read one after another, because each page hands you the cursor for the next. The last column counts accounts whose handle or name contains a keyword; once profiles are stored, bios and categories count too. Five of the seven reads came back one account short of the count. Instagram leaves an account or two out of a long list now and then, so treat a count of seeds as "at least".

Stage 2 looks up the 544 public accounts that two or more seeds follow:

python discover.py profiles
looking up 544 accounts, about 2,720 credits
343 fit: public, 5,000 to 250,000 followers, on topic or followed by 3+ seeds
2,720 credits used

57 seconds at ten calls at a time. Each lookup returns the profile; the script keeps these fields:

{
  "success": true,
  "data": {
    "id": "12393303",
    "username": "benjaminput",
    "full_name": "Benjamin Put",
    "is_private": false,
    "is_verified": false,
    "follower_count": 16104,
    "following_count": 3105,
    "biography": "🥉3rd 2025, 2016, 2015 WBC\n🏆 4th 2017 WBC\n🏆 5th 2022 WBC\n7x Canada Barista Champ\nCo-Founder Monogram Coffee",
    "category": "",
    "external_url": "",
    …
  },
  "duration": "1.74",
  "statusCode": 200,
  "creditsUsed": 5
}

Stage 3 reads the 12 latest posts of each account that fits and writes the shortlist:

python discover.py posts
reading posts of 343 accounts, about 1,715 credits
319 accounts in shortlist.csv
  5 seeds  @benjaminput                  16,104 followers   2.95%   3 posts in 30 days
  5 seeds  @zerno.grinder                20,395 followers   1.35%   7 posts in 30 days
  5 seeds  @sworksdesign                 23,651 followers   1.31%   3 posts in 30 days
  5 seeds  @coffeecollectif             149,593 followers   0.40%  11 posts in 30 days
  5 seeds  @lembutler                    16,972 followers   0.32%   9 posts in 30 days
  5 seeds  @acaiacoffee                 195,535 followers   0.28%   5 posts in 30 days
  5 seeds  @whereisscottrao              96,827 followers   0.22%   9 posts in 30 days
  5 seeds  @slowpoursupply               39,459 followers   0.16%  10 posts in 30 days
  5 seeds  @baratza                      80,390 followers   0.10%  11 posts in 30 days
  4 seeds  @samosmrke                    28,499 followers   6.97%   0 posts in 30 days
  4 seeds  @mcolonnadashwood             14,102 followers   3.89%   2 posts in 30 days
  4 seeds  @carlos.esco.bar              48,579 followers   3.55%   8 posts in 30 days
  4 seeds  @jgagneastrocoffee            42,460 followers   3.53%   0 posts in 30 days
  4 seeds  @ahnstar_                     39,567 followers   3.45%   1 posts in 30 days
  4 seeds  @jacksimpson32                31,853 followers   2.61%   8 posts in 30 days
1,715 credits used

Another 62 seconds. The first row of shortlist.csv, under its header:

username,full_name,seeds,followers,er_median,avg_likes,avg_comments,posts_30d,last_post,category,external_url,biography,followed_by,user_id
benjaminput,Benjamin Put,5,16104,2.946,632,29,3,2026-11-27,,,"🥉3rd 2025, 2016, 2015 WBC 🏆 4th 2017 WBC 🏆 5th 2022 WBC 7x Canada Barista Champ Co-Founder Monogram Coffee",jimseven lancehedrick morgandrinkscoffee goldenbrown.coffee sprometheus,12393303

er_median is the median of likes plus comments over followers, in percent, across the account's own recent posts. Pinned posts, collabs and posts with hidden like counts are left out of it, for the reasons in the engagement rate guide. Activity is counted separately and leaves nothing out: posts_30d is every post on the grid in the last 30 days among the 12 read, and last_post the newest of them. followed_by names the seeds, so you can see who vouches for whom.

What the run showed

  • The top of the list needs no explaining. Ten accounts are followed by five seeds. Nine are on the shortlist: a seven-time Canadian barista champion, a US barista champion, a coffee writer and consultant, two grinder makers, a maker of coffee scales, a roastery, a brew-gear shop and a maker whose whole bio is "I make stuff". The tenth, a brewing-gear brand with 348,000 followers, is over the follower cap. Nobody typed those names in.
  • A keyword filter misses the people everyone in a niche knows. Of the 165 accounts with three or more seeds that we looked up, 25 had no coffee word anywhere in their profile. At least 11 of those are coffee through and through, among them two espresso machine makers, a grinder burr maker, two brewing-gear brands, two latte art competitors and two champion baristas whose bios are a one-line joke and an empty line. That is what TRUST is for: at three seeds, the seeds know better than the bio. It added 14 accounts to the shortlist.
  • The follower cap does the other half of the filtering. 55 of the 544 accounts had more than 250,000 followers, including a chef with 2.4 million and an actor with 8.2 million that three seeds each follow. 99 had fewer than 5,000.
  • Engagement only compares within a size. The median rate on the shortlist was 0.67%, but 1.13% for the 127 accounts with 5,000 to 20,000 followers, 0.55% for the 100 with 20,000 to 50,000, 0.33% for the 45 with 50,000 to 100,000 and 0.31% for the 47 above that.
  • Check that an account still posts. 59 of the 319 had put nothing on their grid in the last 30 days. 197 had posted four times or more, and for 42 all 12 posts read were inside the month. posts_30d and last_post are there to sort on.
  • 24 accounts that fit had nothing to measure: an empty grid, or only pinned posts, collabs and hidden counts among the latest 12. They are left off the shortlist and stay in the database.

Ask the database your own questions

Everything the script read is in discover.db, so a different cut is a query away and costs nothing. Which seeds pull their weight?

sqlite3 -header -column discover.db "SELECT s.username AS seed, COUNT(*) AS follows,
  SUM(a.er_median IS NOT NULL) AS shortlisted FROM follows f JOIN seeds s ON s.user_id = f.seed_id
  JOIN accounts a ON a.user_id = f.user_id GROUP BY s.user_id ORDER BY shortlisted DESC;"
seed                 follows  shortlisted
-------------------  -------  -----------
lancehedrick         1308     230
morgandrinkscoffee   1226     190
jimseven             1123     129
thecoffeechronicler  816      111
goldenbrown.coffee   976      91
sprometheus          283      73
coffeebae97          313      4

Six seeds move in the same circle. The seventh has coffee in its name too, but follows a different crowd: 4 of the 313 accounts it follows made the shortlist. Take a seed like that out with drop. Its votes go, and every profile and post already read stays in the database:

python discover.py drop @coffeebae97
@coffeebae97: dropped
4,958 accounts from 6 seeds
  followed by 1:  4,419   private   400   keyword match 1,169
  followed by 2:    374   private    14   keyword match   287
  followed by 3:    118   private     2   keyword match    97
  followed by 4:     38   private     0   keyword match    34
  followed by 5:      9   private     0   keyword match     8
0 credits used

The keyword column is higher here than after stage 1 because bios are known now. Running posts again read nothing new and rewrote the shortlist with 317 accounts. Add a replacement with seeds and only the accounts it lifts to two seeds get a lookup.

The accounts above the follower cap are one more query, useful when you want the niche's biggest names instead of its mid-size ones:

sqlite3 -header -column discover.db "SELECT a.username, a.followers, COUNT(*) AS seeds FROM follows f
  JOIN accounts a ON a.user_id = f.user_id WHERE a.followers > 250000 GROUP BY a.user_id
  HAVING COUNT(*) >= 4 ORDER BY seeds DESC, a.followers DESC;"
username        followers  seeds
--------------  ---------  -----
fellowproducts  348302     5
lamarzocco      509456     4
lamarzoccohome  425971     4

Choosing seeds, and how many

We recounted the overlap for every combination of our seven seeds to see what fewer would have found:

SeedsAccounts on their listsFollowed by 2 or moreFollowed by 3 or more
32,440133 (25 to 320)11
53,886337 (154 to 503)72
75,242560167

Averages over all combinations of that size, with the lowest and highest in brackets. The spread is the lesson: three seeds from the same circle found 320 shared accounts, three that barely know each other found 25. Good seeds are close to each other and to what you want more of.

  • Pick seeds that follow a few hundred to a couple of thousand accounts. A list costs about 5 credits per 50 accounts. An account that follows 5,000 costs four times as much to read as one that follows 1,200, and says less with each follow.
  • A private seed gives you nothing. Its following list comes back empty. The script prints "0 of N accounts listed" and moves on.
  • A read that stops early is kept. If the credits run out, a page keeps failing or you press Ctrl-C halfway through a list, the pages already read stay in the database and the line shows how far it got. Name the seed again to read the whole list.
  • Add seeds later. Run seeds again with new handles: they are added to the same database, the counts go up, and profiles only looks up accounts that newly reach MIN_SEEDS. Naming a seed again reads its list again and adds what is new. It never removes a follow, since Instagram leaves a few accounts out of any one read; drop the seed first if you want its list from scratch.
  • Feed the shortlist back in. The accounts with the most seeds make good seeds for a second round, which reaches the niche's next ring.

What it costs

StageCalls in our runCreditsOn Starter ($49.99 for 275,000)
Lists: 7 seeds, 6,045 follows7 lookups and 118 pages62511 cents
Profiles: accounts with 2 or more seeds5442,72049 cents
Posts: accounts that fit3431,71531 cents
Whole run1,0125,06092 cents
For comparison: a profile for every public account on the lists4,80724,035$4.37

That is about 16 credits per shortlisted account. Failed calls are refunded, and a second run only pays for what is new. The 100 free credits cover stage 1 for one seed that follows up to about 950 accounts; the whole pipeline for a niche fits many times over in a month of Starter.

Where to go from here

Common questions

How do I find Instagram influencers in a niche with an API?

Start from a few creators you already know in the niche and read who they follow with /following/by_user_id. Count how many of your seeds follow each account, then look up only the accounts that two or more seeds follow. In our run, seven coffee creators led to 5,242 accounts, 560 of them followed by at least two seeds, and 319 made the final shortlist.

Is there an endpoint that returns accounts similar to another account?

Not on ScrapingBot. Overlap between following lists does the same job with data you can inspect: an account that four of your seven seeds follow is close to them by their own choice. In our run 84% of the accounts followed by four or five seeds were on topic and in the follower range we asked for.

How many seed accounts do I need?

Five to ten that belong to the same niche. From our seven seeds, any three gave 133 accounts followed by at least two of them on average, any five gave 337, and all seven gave 560. A seed whose taste differs adds cost and little else: one of our seven put 4 accounts on the shortlist, against 73 to 230 for the others.

What does Instagram influencer discovery cost per run?

Our run used 5,060 credits: 625 to read seven following lists (6,045 follows), 2,720 for 544 profile lookups and 1,715 to read the recent posts of 343 accounts. That is 92 cents on the Starter plan. Looking up all 4,807 public accounts on those lists would have cost 24,035 credits before reading a single post.

Why read following lists instead of follower lists?

A following list is a creator's own selection: peers, brands they use, people they learn from. A follower list is their audience, and most of it is private or personal accounts. In this run 8% of the accounts our seeds follow were private, against 41% of a follower list we read a week earlier. Instagram also cuts some large accounts' follower lists off after about 50 accounts.

How is the engagement rate calculated?

Likes plus comments divided by followers, as the median over the account's own posts among its 12 most recent. Pinned posts, collab posts and posts with hidden like counts are set aside. Compare accounts of similar size: the median was 1.13% for the 127 shortlisted accounts with 5,000 to 20,000 followers and 0.31% for the 47 with 100,000 to 250,000.

Start scraping in the next five minutes.

100 free credits, no credit card. One API key works for websites, TikTok, Instagram, Google, Amazon and ChatGPT.