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. 40 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

40 credits per song: one page of TikTok videos using the sound (20) and one page of Instagram reels using the audio (20). Finding each track's ids is a one-off: 20 credits on TikTok and 100 on Instagram. Scanning 100 tracks daily costs at least 120,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 soundclipId20
GET /v1/instagram/audio/reelsReels that use an Instagram audio trackaudio_id20

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 (20 credits) searches sounds by keyword and returns each sound with how many videos use it. sort_by=most-used puts the biggest first. GET /v1/tiktok/song (20) 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 (100 credits).

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 = "7401827365519082261"
INSTAGRAM_AUDIO_ID = "1827465019384726"

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):
    if not body["success"]:
        return 0, 0
    items = body["data"].get("items", [])
    total = sum(((i.get("post") or {}).get("engagement") or {}).get("views") or 0 for i in items)
    return total, len(items)

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': 40}

The figures are illustrative. Both lists return one page, not every video that uses the sound, so the view sums are a reach sample. 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 120 credits once per new track if you still need to look up both ids.
  • Add the TikTok usage count. GET /v1/tiktok/song (20 credits) returns how many videos use the sound. 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. use=1 on tiktok/song/videos adds data.adoption.uses, a count of what the captions are doing with the sound. The response also carries a date histogram of the videos on the page.
  • Find candidates to score. GET /v1/instagram/music/trending (100) returns Instagram's chart of trending licensed tracks, and GET /v1/tiktok/search/music with sort_by=most-used (20) surfaces the most-used sounds for a keyword.
  • Deepen the sample. Send the returned cursor back as cursor to read more pages, at 20 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