Social Media Scraper

Creator Research Guide

How to Build an Influencer Discovery Tool with Python

Calling Social Media Scraper from a standard-library Python script lets you build an influencer discovery tool that searches public Instagram profiles and saves a deduplicated JSON shortlist for manual review. Configure your API key in the terminal to request up to five candidate profiles per run.

Illustration of a code notebook connecting public profile search results to a deduplicated creator shortlist using distinct anonymous cards.
Illustration: Connecting profile search results to a deduplicated creator shortlist.

What a Creator Discovery Prototype and Search API Return

This influencer discovery tool uses instagram.search_profiles as an influencer search API, then reads available profiles for selected handles. The script deduplicates candidates and leaves review_notes blank for your own assessment.

Query and Match Records

Keeps your search query paired with deduplicated public profile matches.

Public Profile Fields

Includes available public handle, bio, follower count, and profile URL fields.

Blank Review Notes

Leaves review_notes empty so reviewers can record fit notes later.

Why Pair Creator Discovery With Manual Creator Review

Broad searches can include accounts outside your campaign brief. Check their public profile details before adding them to a shortlist. Separating search, profile lookup, and manual creator review keeps your list grounded in public records.

Broader Search vs. Profile Detail

Search finds initial public candidates; profile lookups return fuller account details.

Direct Source Links

Public profile URLs let teammates open accounts and check recent posts.

Manual Creator Review

Reviewers check public posts and brief fit by hand before outreach.

How to Build an Influencer Discovery Tool With Python

Use standard library Python with your API key in the environment to call instagram.search_profiles, check up to five candidates, deduplicate creator profiles by ID, and save an influencer shortlist as JSON.

  1. Search Query
  2. Profile Lookup
  3. Deduplicated Shortlist
Workflow from search query to deduplicated shortlist and human review.

Read Key From Environment

Set SOCIALSCRAPER_API_KEY in your shell environment. The script sends it in the x-api-key header when calling instagram.search_profiles.

Search and Deduplicate Creator Profiles

Inspect up to five candidates, deduplicate creator profiles by stable ID, and look up matching handles once.

Save an Influencer Shortlist as JSON

Write the search_record, profile, and review_notes entries to a local JSON file.

How to Run the Python Creator Search Script

Run this standard library Python script to search public profiles, deduplicate candidates, and save a JSON shortlist.

how-to-build-an-influencer-discovery-tool.py
import argparse
import datetime
import json
import os
import pathlib
import urllib.error
import urllib.parse
import urllib.request
import uuid

ORIGIN = "https://socialmediascraper.org"

class NoRedirect(urllib.request.HTTPRedirectHandler):
    def redirect_request(self, *args, **kwargs):
        return None

def fetch(operation, params):
    key = os.environ.get("SOCIALSCRAPER_API_KEY")
    if not key:
        raise SystemExit("Set SOCIALSCRAPER_API_KEY in your environment first.")
    url = ORIGIN + "/v1/" + operation.replace(".", "/")
    request = urllib.request.Request(url + "?" + urllib.parse.urlencode(params), headers={
        "x-api-key": key,
        "Idempotency-Key": str(uuid.uuid4()),
        "Accept": "application/json",
        "User-Agent": "SocialMediaScraperTutorial/1.0",
    })
    try:
        with urllib.request.build_opener(NoRedirect()).open(request, timeout=40) as response:
            payload = json.load(response)
    except urllib.error.HTTPError as error:
        raise SystemExit("Request stopped with HTTP " + str(error.code)) from None
    except (OSError, ValueError):
        raise SystemExit("Request failed; inspect the saved request status before retrying.") from None
    data = payload.get("data")
    if not isinstance(data, dict):
        raise SystemExit("No data object returned; inspect the API response contract.")
    return data

parser = argparse.ArgumentParser()
parser.add_argument("input")
parser.add_argument("--out", default="research-output")
args = parser.parse_args()
destination = pathlib.Path(args.out)
if destination.exists() or destination.with_suffix(".json").exists():
    raise SystemExit("Output exists. Choose another --out before starting a new billed request.")
destination.parent.mkdir(parents=True, exist_ok=True)

search = fetch("instagram.search_profiles", {"query": args.input})
seen = set()
shortlist = []
for item in search.get("items", [])[:5]:
    if not isinstance(item, dict):
        continue
    identity = item.get("id")
    if not identity or identity in seen:
        continue
    seen.add(identity)
    author = item.get("author") or {}
    handle = author.get("handle") if isinstance(author, dict) else None
    if not handle and isinstance(item.get("url"), str):
        url = urllib.parse.urlparse(item["url"])
        if url.hostname in ("instagram.com", "www.instagram.com"):
            parts = url.path.strip("/").split("/")
            if len(parts) == 1 and parts[0]:
                handle = parts[0]
    profile = fetch("instagram.profile", {"handle": handle}) if handle else None
    shortlist.append({"search_record": item, "profile": profile, "review_notes": ""})
result = {"query": args.input, "fetched_at": datetime.datetime.now(datetime.timezone.utc).isoformat(), "shortlist": shortlist}
destination.with_suffix(".json").write_text(json.dumps(result, ensure_ascii=False, indent=2), encoding="utf-8")
print(destination.with_suffix(".json"))

Copy or download the request, Python script, or n8n workflow, then run it in your own environment with an active API key and balance.

What You Can Store in a Creator Shortlist

The JSON file stores each candidate's original search_record, any retrieved profile, and an empty review_notes string. Missing source fields stay null or absent, and profile is null when no usable handle was found.

Search Record Block

Saves the search_record context from the query alongside candidate entries.

Profile Fields Block

Keeps available profile fields as returned. A skipped lookup leaves profile null without invented estimates.

Review Notes Field

Keeps review_notes blank in the saved JSON until a reviewer fills them in.

Sample Creator Schema and Field Types
{
  "query": "string",
  "fetched_at": "string",
  "shortlist": [
    {
      "search_record": {
        "id": "string",
        "title": "string | null",
        "text": "string | null",
        "url": "string | null"
      },
      "profile": {
        "id": "string",
        "handle": "string",
        "display_name": "string | null",
        "bio": "string | null",
        "profile_url": "string | null",
        "metrics": {
          "followers": "number | null",
          "posts": "number | null"
        }
      },
      "review_notes": "string"
    }
  ]
}
This schema is an example field layout for a creator shortlist, not a live or returned result.

How to Filter Candidates for Campaign Shortlists Manually

Filter saved public records for your campaign brief and inspect posts yourself before building outreach. You can add a downstream spreadsheet, filter script, or outreach step after collecting the public records.

Filter Bios for Topic Words

Check saved public bios for niche keywords when preparing a running gear shortlist.

Check Location Words Manually

Read any location text in a public bio and check recent posts yourself rather than treating it as a verified field.

Group Candidates for Manual Review

Collect creators who post reviews or unboxings for manual review before outreach.

What Limits Apply Before Expanding the Search

One search can trigger up to five extra profile requests, so check your API key, account balance, request budget, and existing output file before running a larger batch.

Up to Five Extra Profile Calls

One search inspects up to five candidates and can make up to five extra profile requests.

Key, Balance, and Request Cap

Confirm a valid API key in the environment, enough account balance, and a clear request limit.

Existing Output File Guard

Check whether the output JSON file already exists before writing so you do not overwrite saved work.

What Should You Check Before Building a Creator Shortlist?

Read the API documentation →

How to Continue With Creator Discovery

Open the free profile lookup tool or inspect the API reference to test public profile queries.