Back to use cases

    Use case / Marketers / Python 3 / Published

    Instagram Influencer Finder: Shortlist Creators by Niche with Python

    Card for Instagram Influencer Finder: Shortlist Creators by Niche with Python

    Instagram Creator Shortlist is a small Instagram influencer finder for marketers. Type a niche keyword and it finds public creators, pulls their recent posts, and writes a ranked shortlist grouped by follower tier, with engagement rate, posting cadence and days since the last post.

    The problem

    Finding creators for a campaign usually means scrolling profiles and copying numbers into a sheet. Follower counts alone are misleading: some big accounts have low engagement or have stopped posting. Marketers need the same few metrics for every candidate, side by side.

    What the app does

    • Takes a niche keyword.
    • Finds matching public creator profiles.
    • Pulls followers and recent posts for up to 10 public creators with at least 1,000 followers.
    • Computes median engagement rate, median likes and comments, posts in the last 30 days and days since last post.
    • Groups creators by tier (nano, micro, mid, macro) and flags stale accounts.
    • Writes Markdown, CSV and a followers vs engagement chart.

    How it works

    1. Search. POST /desearch/instagram/search with the keyword.
    2. Profile. GET /desearch/instagram/profile/{username} for followers and the private flag.
    3. Posts. GET /desearch/instagram/profile/{username}/posts for recent posts, pinned posts excluded.
    4. Compute engagement rate per post as (likes + comments) / followers and take the median.
    5. Write the shortlist, CSVs, chart and a cost log.

    The code

    def collect(query, search_count, max_creators, posts, min_followers):
        key = os.environ.get("DESEARCH_API_KEY")
        if not key:
            sys.exit("Set DESEARCH_API_KEY (create a key at console.desearch.ai).")
        s = requests.Session()
        s.headers.update({"Authorization": key, "Content-Type": "application/json"})
        costs = []
        raw = {"fetched_at": dt.datetime.now(dt.timezone.utc).isoformat(timespec="seconds"), "query": query,
               "params": {"search_count": search_count, "max_creators": max_creators, "posts": posts, "min_followers": min_followers},
               "search": [], "profiles": {}, "posts": {}}
        print(f"1) search Instagram profiles for {query!r}")
        raw["search"] = call(s, costs, f"search {query!r} count={search_count}", "POST", "/desearch/instagram/search",
                             body={"query": query, "count": search_count}) or []
        seen = []
        for r in raw["search"]:
            if r.get("type", "profile") == "profile" and r.get("username") and r["username"] not in seen:
                seen.append(r["username"])
        print(f"2) profile lookup for {len(seen)} usernames")
        for u in seen:
            raw["profiles"][u] = call(s, costs, f"profile {u}", "GET", f"/desearch/instagram/profile/{u}")
        picks = [u for u, p in raw["profiles"].items()
                 if p and not p.get("private") and (p.get("followers") or 0) >= min_followers]
        picks = sorted(picks, key=lambda u: -raw["profiles"][u]["followers"])[:max_creators]
        print(f"3) recent posts for {len(picks)} public creators with >= {min_followers:,} followers")
        for u in picks:
            raw["posts"][u] = call(s, costs, f"posts {u} count={posts}", "GET", f"/desearch/instagram/profile/{u}/posts",
                                   params={"count": posts}) or []
        raw["costs"] = costs
        return raw
    

    The folder has one script, ig_shortlist.py, a sample report in sample-output.md and the chart from that run.

    Endpoints

    • POST /desearch/instagram/search
    • GET /desearch/instagram/profile/{username}
    • GET /desearch/instagram/profile/{username}/posts

    Example output

    From a run on 2026-10-06 for "home gym": 31 calls in about 80 seconds. The shortlist groups creators by follower tier and shows, per creator, median engagement rate, median likes and comments, posts in the last 30 days, median days between posts and a stale flag. The public page shows tier-level results, not personal handles.

    Run it yourself

    The public examples folder linked above includes the script and a README. Install its requirements, set DESEARCH_API_KEY from console.desearch.ai, and use the run command in that README.

    Useful flags: --search-count (default 20), --max-creators (default 10), --posts (per creator, default 12), --min-followers (default 1000), --from-raw FILE (no API calls).

    What it costs

    One run for "home gym" with the defaults made 31 calls and cost $0.331 on 2026-10-06, summed from the X-Desearch-Cost-Usd headers. See pricing.

    Ideas to extend it

    • Run several related keywords and merge the shortlists.
    • Add a TikTok step with the TikTok endpoints.
    • Track the shortlisted creators monthly to see who keeps posting.

    Use with AI agents

    Point an MCP client at the hosted Desearch server. Replace the placeholder with a key from the console. Do not commit the key.

    {
      "mcpServers": {
        "desearch": {
          "url": "https://mcp.desearch.ai/mcp",
          "headers": {
            "Authorization": "Bearer <DESEARCH_API_KEY>"
          }
        }
      }
    }

    Prompt you can paste for this example:

    Use Desearch to find public Instagram creators for the niche I name. Rank a shortlist by follower tier and engagement using only the profiles and posts you retrieve. Do not invent accounts.

    Build your own example.

    Give your agents access to web and social search. Get an API key to start building, or talk to us about your integration.

    Read docs