InsightSocial API
Recipes

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

EndpointRoleCredits
GET /v1/tiktok/searchTikTok videos about the topic20–840
GET /v1/instagram/search/reelsInstagram reels about the topic20–180
GET /v1/tiktok/profileFull TikTok account20
GET /v1/instagram/profileFull Instagram account, including author.ext.public_email from the bio20

The code

Python
# 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

Example output
{'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: 240

The 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/search with youtube/channel, or twitter/search/tweets with twitter/profile. Both profile calls cost 20.
  • Go deeper than the profile. Feed each account to its profile/full endpoint (100 credits) for recent posts and computed engagement, or feed the top posts to the Video transcription recipe to get what was said.

On this page