InsightSocial API
Recipes

Music trend detection

Score how fast a sound is spreading on TikTok and Instagram Reels with a log-weighted heat score you can track day over day. 20 credits per song.

You will build an early-warning detector for sounds that are taking off. A song moves on the creation side first: creators pick it up on TikTok, then it crosses to Instagram Reels, and only later does it reach the charts. Measuring both creation surfaces catches the move while it is still early.

Cost per run

20 credits per song: one page of TikTok videos using the sound (10) and one page of Instagram reels using the audio (10). Finding each track's ids is a one-off: 10 credits on TikTok and 50 on Instagram. Scanning 100 tracks daily costs at least 60,000 credits a month. Scan a shortlist daily and a wider list weekly to keep that down.

How can you catch a rising sound before it charts?

Combine two signals. GET /v1/tiktok/song/videos returns videos that use a TikTok sound, with their view counts. GET /v1/instagram/audio/reels returns reels that use the same track on Instagram. A log-weighted mix of the two, stored per day, shows which songs are accelerating.

What you need

EndpointSignalParameterCredits
GET /v1/tiktok/song/videosVideos that use a TikTok soundclipId10
GET /v1/instagram/audio/reelsReels that use an Instagram audio trackaudio_id10

Resolving the two ids

Both platforms key sounds by id, not by name, and both ids are stable per track. Look them up once and store them.

  • TikTok clipId: GET /v1/tiktok/search/music (10 credits) searches sounds by keyword. Each sound comes back as a post: post.id is the clipId, post.content.text the title, and post.ext.video_count how many videos use it. sort_by=most-used puts the biggest first. GET /v1/tiktok/song (10) confirms an id you already have.
  • Instagram audio_id: the number in an instagram.com/reels/audio/<audio_id>/ URL, or look it up by keyword with GET /v1/instagram/search/music (50 credits, beta).

The code

Python
# music_heat.py
# A cross-platform heat score for one track. Store it per day and watch the delta.
# Run with: INSIGHTSOCIAL_API_KEY=isk_live_... python music_heat.py
import math
import os
from concurrent.futures import ThreadPoolExecutor

import requests

KEY = os.environ["INSIGHTSOCIAL_API_KEY"]
BASE = "https://api.insightsocial.app/v1"

# Resolve both ids once (see above), then keep them.
TIKTOK_CLIP_ID = "7364498342501435408"   # "Espresso", Sabrina Carpenter
INSTAGRAM_AUDIO_ID = "1827465019384726"   # replace with the track's audio id

def get(path, **params):
    res = requests.get(f"{BASE}/{path}", params=params,
                       headers={"x-api-key": KEY}, timeout=120)
    return res.json()

def views_on_page(body):
    """Sum of views on the page, and how many rows showed a view count."""
    if not body["success"]:
        return 0, 0
    views = [i["post"]["engagement"]["views"] for i in body["data"]["items"]]
    known = [v for v in views if v is not None]  # null means hidden, not zero
    return sum(known), len(known)

with ThreadPoolExecutor(max_workers=2) as pool:
    tt = pool.submit(get, "tiktok/song/videos", clipId=TIKTOK_CLIP_ID)
    ig = pool.submit(get, "instagram/audio/reels", audio_id=INSTAGRAM_AUDIO_ID)
    tiktok, instagram = tt.result(), ig.result()

tt_views, tt_count = views_on_page(tiktok)
ig_views, ig_count = views_on_page(instagram)

# One page per platform is a sample, not a census. Weight it, then track the trend.
heat = 0.6 * math.log10(tt_views + 1) + 0.4 * math.log10(ig_views + 1)

print({
    "tiktok_sample_views": tt_views, "tiktok_videos_on_page": tt_count,
    "instagram_sample_views": ig_views, "instagram_reels_on_page": ig_count,
    "heat_score": round(heat, 2),
    "credits_used": tiktok.get("credits_used", 0) + instagram.get("credits_used", 0),
})

What you get back

Example output
{'tiktok_sample_views': 52700000, 'tiktok_videos_on_page': 30, 'instagram_sample_views': 36400000,
 'instagram_reels_on_page': 12, 'heat_score': 7.66, 'credits_used': 20}

The figures are illustrative. Both lists return one page, not every video that uses the sound, so the view sums are a reach sample. A row whose view count is hidden (null) adds nothing to the sum and is not counted in *_on_page. Compare a track's score with its own history, not with an absolute bar.

What to change

  • The two ids. Swap in the track you are watching. Budget 60 credits once per new track if you still need to look up both ids.
  • Add the TikTok usage count. GET /v1/tiktok/song (10 credits) returns the sound as a post, with how many videos use it in post.ext.use_count. It is the cleanest creation-velocity number TikTok publishes, and its day-over-day change is worth adding to the score.
  • See how the sound is being used. Read the captions yourself: post.content.text on each row of tiktok/song/videos. Counting rows by post.published_at day gives you a date histogram of the page.
  • Find candidates to score. GET /v1/tiktok/search/music with sort_by=most-used (10) surfaces the most-used sounds for a keyword. (GET /v1/instagram/music/trending, Instagram's trending chart, is switched off while its source fails; see the changelog.)
  • Deepen the sample. Send pagination.next_cursor back as cursor, with the same id, to read more pages at 10 credits each, and adjust the weights to match.
  • Track the delta, not the level. Store heat_score per track per day. A rising score is the signal. A high, flat score is a song that already broke.

On this page