Search then enrich
Find the posts about a topic on TikTok and Instagram, collect the accounts that made them, and fetch each account's full profile into one lead list. From 120 credits per run.
You will build a creator-discovery pipeline: search two platforms for posts about a topic, collect the unique accounts behind the top posts, and fetch each account's full profile (followers, bio, bio link, public contact email where one is listed) into one table.
Cost per run
120 to 1,120 credits: two searches (TikTok 10–370, Instagram reels 10–650) plus 10 profile lookups at 10 credits each. Looking up an account again is charged again, so keep the profiles you already fetched. ACCOUNTS_PER_PLATFORM is the price dial.
How do you turn a topic into a list of creators?
Chain two kinds of endpoint. A post search tells you who is posting about the topic right now. A profile call tells you who they are. Search rows carry the author's handle, and the handle is exactly what the profile endpoint takes, so there is no string-massaging in between.
A search result shows that someone posted about the topic. It does not give you their follower count, bio or contact details at a useful depth. The profile does.
What you need
| Endpoint | Role | Credits |
|---|---|---|
GET /v1/tiktok/search | TikTok videos about the topic | 10–370 |
GET /v1/instagram/search/reels | Instagram reels about the topic | 10–650 |
GET /v1/tiktok/profile | Full TikTok account, including the bio link in external_url | 10 |
GET /v1/instagram/profile | Full Instagram account, including external_url and author.ext.public_email from the bio | 10 |
The code
# search_then_enrich.py
# Topic -> top posts -> unique authors -> full profiles.
# Run with: INSIGHTSOCIAL_API_KEY=isk_live_... python search_then_enrich.py
import os
from concurrent.futures import ThreadPoolExecutor
import requests
KEY = os.environ["INSIGHTSOCIAL_API_KEY"]
BASE = "https://api.insightsocial.app/v1"
TOPIC = "home espresso setup"
KEYWORDS = ["espresso"] # a post must mention one of these to count as on-topic
ACCOUNTS_PER_PLATFORM = 5
SEARCH = {"tiktok": "tiktok/search", "instagram": "instagram/search/reels"}
PROFILE = {"tiktok": "tiktok/profile", "instagram": "instagram/profile"}
def get(path, **params):
res = requests.get(f"{BASE}/{path}", params=params,
headers={"x-api-key": KEY}, timeout=120)
return res.json()
def on_topic(post):
text = (post["content"]["text"] or "").lower()
return any(k in text for k in KEYWORDS)
# Step 1: search both platforms.
with ThreadPoolExecutor(max_workers=2) as pool:
found = dict(zip(SEARCH, pool.map(
lambda p: get(SEARCH[p], query=TOPIC), SEARCH)))
# Step 2: unique authors of on-topic posts, in the order the search ranked them.
targets = []
for platform, body in found.items():
if not body["success"]:
print(f"{platform} search: {body['error']['type']}")
continue
handles = []
for item in body["data"]["items"]:
post = item["post"]
handle = post["author"]["username"]
if handle and handle not in handles and on_topic(post):
handles.append(handle)
targets += [(platform, h) for h in handles[:ACCOUNTS_PER_PLATFORM]]
# Step 3: enrich every author with a profile call.
def enrich(target):
platform, handle = target
return platform, handle, get(PROFILE[platform], handle=handle)
with ThreadPoolExecutor(max_workers=10) as pool:
profiles = list(pool.map(enrich, targets))
rows = []
for platform, handle, body in profiles:
if not body["success"]:
continue
author = body["data"]["author"]
rows.append({
"platform": platform,
"handle": handle,
"followers": author["followers"],
"bio": (author["bio"] or "")[:60],
"link": author["external_url"],
"email": (author["ext"] or {}).get("public_email"),
})
rows.sort(key=lambda r: r["followers"] or 0, reverse=True)
for r in rows:
print(r)
spent = sum(b.get("credits_used", 0) for b in found.values()) + \
sum(b.get("credits_used", 0) for _, _, b in profiles)
print(f"credits used: {spent}")What you get back
{'platform': 'tiktok', 'handle': '...', 'followers': 1840000, 'bio': 'coffee nerd. latte art every day', 'link': 'https://linktr.ee/...', 'email': None}
{'platform': 'instagram', 'handle': '...', 'followers': 412000, 'bio': 'Espresso gear reviews', 'link': None, 'email': 'hello@example.com'}
...
credits used: 120The figures are illustrative. email is only present when the account lists one publicly in its bio, and link (the profile's external_url) only when it has a bio link. The keyword check runs on your side, so it costs nothing; posts it drops were still part of the page you paid for.
What to change
TOPICandKEYWORDS. Any subject with public video discussion.KEYWORDSkeeps out posts that only share a word with the topic. Set it to the words that must appear in a caption.ACCOUNTS_PER_PLATFORM. Each extra account costs 10 credits.- Skip the second step on TikTok.
GET /v1/tiktok/search/users?include=profile(10–1,310) searches accounts directly and fills bio, region andexternal_urlon every row in one call. Use it when you want accounts that match a topic, rather than the authors of posts that match it. - More platforms. Add
youtube/searchwithyoutube/channel, ortwitter/search/tweetswithtwitter/profile. Both profile calls cost 20. - Go deeper than the profile. Fetch each account's recent posts (
tiktok/profile/videos,instagram/profile/posts) and score them as in Creator engagement scoring, or feed the top posts to the Video transcription recipe to get what was said.
Related
TikTok analytics dashboard
Build the data layer of a TikTok dashboard for accounts you do not own, with account KPIs, a per-video table with engagement rates and a scored comment feed. 30 to 50 credits per refresh.
Video transcription
One transcribe() function that returns the spoken words of a video on YouTube, TikTok, Instagram, Facebook, X, Reddit or LinkedIn. 30 credits on YouTube, 100 on the others.