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 240 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, public contact email where one is listed) into one table.
Cost per run
240 to 1,220 credits: two searches (TikTok 20–840, Instagram reels 20–180) plus 10 profile lookups at 20 credits each. Looking up an account you already fetched in the last 24 hours is free. 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 | 20–840 |
GET /v1/instagram/search/reels | Instagram reels about the topic | 20–180 |
GET /v1/tiktok/profile | Full TikTok account | 20 |
GET /v1/instagram/profile | Full Instagram account, including author.ext.public_email from the bio | 20 |
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"
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()
# Step 1: search both platforms, keeping on-topic rows only (free).
with ThreadPoolExecutor(max_workers=2) as pool:
found = dict(zip(SEARCH, pool.map(
lambda p: get(SEARCH[p], query=TOPIC, relevance="filter"), SEARCH)))
# Step 2: unique authors, 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"].get("items", []):
handle = ((item.get("post") or {}).get("author") or {}).get("username")
if handle and handle not in handles:
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.get("followers"),
"bio": (author.get("bio") or "")[:60],
"email": (author.get("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', 'email': None}
{'platform': 'instagram', 'handle': '...', 'followers': 412000, 'bio': 'Espresso gear reviews', 'email': 'hello@example.com'}
...
credits used: 240The figures are illustrative. email is only present when the account lists one publicly in its bio.
What to change
TOPIC. Any subject with public video discussion.ACCOUNTS_PER_PLATFORM. Each extra account costs 20 credits, or 0 if you fetched it in the last 24 hours.- Skip the second step on TikTok.
GET /v1/tiktok/search/users?include=profile(20–2000) searches accounts directly and fills bio, region and link on 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. Feed each account to its
profile/fullendpoint (100 credits) for recent posts and computed engagement, 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 and a labelled comment feed. 60 to 260 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. 60 credits on YouTube, 200 on the others.